dsh-plugin-usage 0.1.1 → 0.1.2
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 +32 -10
- package/package.json +1 -1
package/lib/client/index.js
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
// Auto-generated module entry wrapping the shared client body
|
|
2
2
|
// (source: src/client/index.js). Do not edit directly.
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
|
|
3
|
+
// Static composition loads bundles as scripts: the file must self-register
|
|
4
|
+
// via window.__ModuleLoader__.load({ id, factory }). The shared body returns
|
|
5
|
+
// a plugin descriptor ({ inject, apply }) for the dynamic-plugin runner;
|
|
6
|
+
// this entry unwraps it, forwards the loader-provided React, and exposes
|
|
7
|
+
// apply/inject for the cordis loader.
|
|
8
|
+
window.__ModuleLoader__.load({
|
|
9
|
+
id: "dsh-plugin-usage",
|
|
10
|
+
factory: (require) => {
|
|
11
|
+
var module = { exports: {} };
|
|
12
|
+
var exports = module.exports;
|
|
13
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
14
|
+
const React = require("react");
|
|
15
|
+
let _usageCtx = null;
|
|
16
|
+
const _usagePlugin = (() => {
|
|
7
17
|
// ============================================================================
|
|
8
18
|
// Token 用量统计 — settings.section Client UI(纯 JS,动态插件沙箱)
|
|
9
19
|
// 可用全局:React / ctx / styles / host / console;浏览器全局 Date / Intl 等。
|
|
@@ -971,7 +981,15 @@ function hostCall(method, args) {
|
|
|
971
981
|
if (typeof host !== 'undefined' && host && typeof host.call === 'function') {
|
|
972
982
|
return Promise.resolve(host.call(method, args))
|
|
973
983
|
}
|
|
974
|
-
|
|
984
|
+
// Static bundle installs have no ctx/host globals: the entry apply() stores
|
|
985
|
+
// the real context in _usageCtx (declared by the build wrapper).
|
|
986
|
+
const scope = (typeof ctx !== 'undefined' && ctx && typeof ctx.get === 'function')
|
|
987
|
+
? ctx
|
|
988
|
+
: (typeof _usageCtx !== 'undefined' ? _usageCtx : null)
|
|
989
|
+
if (scope === null || typeof scope.get !== 'function') {
|
|
990
|
+
return Promise.reject(new Error('context unavailable'))
|
|
991
|
+
}
|
|
992
|
+
const connection = scope.get('connection')
|
|
975
993
|
if (connection === undefined || connection.rpc === undefined) {
|
|
976
994
|
return Promise.reject(new Error('connection service unavailable'))
|
|
977
995
|
}
|
|
@@ -2241,8 +2259,12 @@ function apply(ctx) {
|
|
|
2241
2259
|
|
|
2242
2260
|
return { inject: ['locale'], apply }
|
|
2243
2261
|
|
|
2244
|
-
})();
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
}
|
|
2262
|
+
})();
|
|
2263
|
+
exports.apply = function apply(ctx) {
|
|
2264
|
+
_usageCtx = ctx;
|
|
2265
|
+
return _usagePlugin.apply(ctx);
|
|
2266
|
+
};
|
|
2267
|
+
exports.inject = _usagePlugin.inject ?? [];
|
|
2268
|
+
return module.exports;
|
|
2269
|
+
}
|
|
2270
|
+
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-usage",
|
|
3
3
|
"description": "Token usage statistics for DeepSeek Harness — daily/custom-range views, model filters, call counts and cost, inspired by CC Switch statistics.",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|