@dshtrading/client-ui-masters-quotes 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/LICENSE ADDED
@@ -0,0 +1,75 @@
1
+ Copyright (c) 2026 zhu1090093659 (dsh-trading)
2
+
3
+ # PolyForm Noncommercial License 1.0.0
4
+
5
+ <https://polyformproject.org/licenses/noncommercial/1.0.0>
6
+
7
+ ## Acceptance
8
+
9
+ In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
10
+
11
+ ## Copyright License
12
+
13
+ The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to [Distribution License](#distribution-license) and make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license).
14
+
15
+ ## Distribution License
16
+
17
+ The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by [Changes and New Works License](#changes-and-new-works-license).
18
+
19
+ ## Notices
20
+
21
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software. For example:
22
+
23
+ > Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
24
+
25
+ ## Changes and New Works License
26
+
27
+ The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
28
+
29
+ ## Patent License
30
+
31
+ The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
32
+
33
+ ## Noncommercial Purposes
34
+
35
+ Any noncommercial purpose is a permitted purpose.
36
+
37
+ ## Personal Uses
38
+
39
+ Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, is use for a permitted purpose.
40
+
41
+ ## Noncommercial Organizations
42
+
43
+ Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution is use for a permitted purpose regardless of the source of funding or obligations resulting from the funding.
44
+
45
+ ## Fair Use
46
+
47
+ You may have "fair use" rights for the software under the law. These terms do not limit them.
48
+
49
+ ## No Other Rights
50
+
51
+ These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
52
+
53
+ ## Patent Defense
54
+
55
+ If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
56
+
57
+ ## Violations
58
+
59
+ The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
60
+
61
+ ## No Liability
62
+
63
+ ***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
64
+
65
+ ## Definitions
66
+
67
+ The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
68
+
69
+ **You** refers to the individual or entity agreeing to these terms.
70
+
71
+ **Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
72
+
73
+ **Your licenses** are all the licenses granted to you for the software under these terms.
74
+
75
+ **Use** means anything you do with the software requiring one of your licenses.
package/lib/client.js ADDED
@@ -0,0 +1,126 @@
1
+ window.__ModuleLoader__.load({
2
+ id: "@dshtrading/client-ui-masters-quotes",
3
+ factory: (require) => {
4
+ var module = { exports: {} };
5
+ var exports = module.exports;
6
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
7
+ //#region src/client/quotes.ts
8
+ /**
9
+ * 投资大师金句库。
10
+ * i18n-allow: locale 数据常量——本文件是 zh 语料数据(金句文案 + 语言自述名),
11
+ * 非 UI 代码字面量;宿主 UI 文案一律进词典,不在此豁免范围。
12
+ *
13
+ * 收录原则:广为流传、可归于其名(widely-attributed),短线/风控/长线视角
14
+ * 均衡;单句含署名 ≤ 22 个全角字符——活动状态行 white-space: nowrap,超长
15
+ * 会在窄窗口溢出。新增条目按署名人分组追加,保持同款「「quote」——name」格式。
16
+ */
17
+ /** 活动状态行单键覆盖值(chat.deepDiving),随轮换定时器逐条上场。 */
18
+ const QUOTES = [
19
+ "「华尔街没有新鲜事」——利弗莫尔",
20
+ "「利润能自己照顾自己,亏损不会」——利弗莫尔",
21
+ "「大钱靠的不是想,而是坐得住」——利弗莫尔",
22
+ "「股价总是沿阻力最小的路线运行」——利弗莫尔",
23
+ "「市场永远不会错,错的往往是人」——利弗莫尔",
24
+ "「别人贪婪时恐惧,别人恐惧时贪婪」——巴菲特",
25
+ "「只有退潮时,才知道谁在裸泳」——巴菲特",
26
+ "「价格是你付出的,价值是你得到的」——巴菲特",
27
+ "「第一条规则:永远不要亏钱」——巴菲特",
28
+ "「风险来自你不知道自己在做什么」——巴菲特",
29
+ "「不想持有十年,就不要持有十分钟」——巴菲特",
30
+ "「大钱不在买卖里,而在等待里」——巴菲特",
31
+ "「市场总是错的」——索罗斯",
32
+ "「对错不重要,赚亏多少才重要」——索罗斯",
33
+ "「我富有,只因知道自己何时错了」——索罗斯",
34
+ "「承认错误,是值得骄傲的事情」——索罗斯",
35
+ "「经济史是一部假象与谎言的连续剧」——索罗斯",
36
+ "「反过来想,总是反过来想」——芒格",
37
+ "「宁要模糊的正确,不要精确的错误」——芒格",
38
+ "「知道会死在哪里,就永远不去那儿」——芒格",
39
+ "「短期是投票机,长期是称重机」——格雷厄姆",
40
+ "「用五毛钱,买一块钱的东西」——格雷厄姆",
41
+ "「股票背后是公司,看它值多少」——彼得·林奇",
42
+ "「行情在悲观中诞生,在狂热中死亡」——邓普顿",
43
+ "「市场非理性,能久过你撑住」——凯恩斯",
44
+ "「痛苦 + 反思 = 进步」——瑞·达里奥"
45
+ ];
46
+ //#endregion
47
+ //#region src/client/index.ts
48
+ /** Required services:宿主 locale 服务(语言目录 + 词典注册表)。 */
49
+ const inject = ["locale"];
50
+ /** 宿主 client-ui-chat 拥有的 chat 命名空间(其 TurnStatus 的 t 绑定面)。 */
51
+ const CHAT_NS = "chat";
52
+ /** 轮次运行状态行的唯一覆盖键(zh 内置值「深度求索中...」)。 */
53
+ const DEEP_DIVING_KEY = "chat.deepDiving";
54
+ /** 本语言包补位的 locale id(持久化为 locale preference)。 */
55
+ const LOCALE_ID = "zh-masters";
56
+ /** 轮换间隔(ms):长轮次每两分钟换一句,短轮次基本只见首句。 */
57
+ const ROTATE_MS = 12e4;
58
+ /** 语言目录注册项(label 用目标语言自述)。 */
59
+ const LANGUAGE = {
60
+ id: LOCALE_ID,
61
+ label: "中文 · 大师金句",
62
+ fallback: "zh"
63
+ };
64
+ /** 下一句索引:随机且不与当前重复(单句库时原地不动)。 */
65
+ function nextIndex(current, length = QUOTES.length) {
66
+ if (length <= 1) return 0;
67
+ let next = Math.floor(Math.random() * length);
68
+ if (next === current) next = (next + 1) % length;
69
+ return next;
70
+ }
71
+ /**
72
+ * 注册语言目录 + 覆盖 chat.deepDiving + 启动轮换(幂等:可重复 apply)。
73
+ * addLanguage/ register 逐项 try/catch:目录项或 (ns, locale) 被占主(重复
74
+ * 安装/宿主新增同 id 语言)时静默降级,不阻塞其余注册。
75
+ */
76
+ function apply(ctx) {
77
+ const disposers = [];
78
+ let disposed = false;
79
+ ctx.effect(() => {
80
+ try {
81
+ disposers.push(ctx.locale.addLanguage(LANGUAGE));
82
+ } catch (error) {
83
+ console.warn(`[masters-quotes] addLanguage(${LOCALE_ID}) skipped:`, error);
84
+ }
85
+ let index = 0;
86
+ let dictDisposer;
87
+ const show = (i) => {
88
+ const quote = QUOTES[i];
89
+ if (quote === void 0) return;
90
+ dictDisposer?.();
91
+ dictDisposer = void 0;
92
+ try {
93
+ dictDisposer = ctx.locale.register(CHAT_NS, LOCALE_ID, { [DEEP_DIVING_KEY]: quote });
94
+ } catch (error) {
95
+ console.warn(`[masters-quotes] register(${CHAT_NS}, ${LOCALE_ID}) skipped:`, error);
96
+ }
97
+ };
98
+ show(0);
99
+ const timer = setInterval(() => {
100
+ if (typeof document !== "undefined" && document.visibilityState === "hidden") return;
101
+ index = nextIndex(index);
102
+ show(index);
103
+ }, ROTATE_MS);
104
+ return () => {
105
+ clearInterval(timer);
106
+ if (disposed) return;
107
+ disposed = true;
108
+ dictDisposer?.();
109
+ for (const dispose of disposers.reverse()) dispose();
110
+ };
111
+ }, "client-ui-masters-quotes: masters quote language pack");
112
+ }
113
+ //#endregion
114
+ exports.CHAT_NS = CHAT_NS;
115
+ exports.DEEP_DIVING_KEY = DEEP_DIVING_KEY;
116
+ exports.LANGUAGE = LANGUAGE;
117
+ exports.LOCALE_ID = LOCALE_ID;
118
+ exports.ROTATE_MS = ROTATE_MS;
119
+ exports.apply = apply;
120
+ exports.inject = inject;
121
+ exports.nextIndex = nextIndex;
122
+ return module.exports;
123
+ }
124
+ });
125
+
126
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","names":[],"sources":["../src/client/quotes.ts","../src/client/index.ts"],"sourcesContent":["/**\n * 投资大师金句库。\n * i18n-allow: locale 数据常量——本文件是 zh 语料数据(金句文案 + 语言自述名),\n * 非 UI 代码字面量;宿主 UI 文案一律进词典,不在此豁免范围。\n *\n * 收录原则:广为流传、可归于其名(widely-attributed),短线/风控/长线视角\n * 均衡;单句含署名 ≤ 22 个全角字符——活动状态行 white-space: nowrap,超长\n * 会在窄窗口溢出。新增条目按署名人分组追加,保持同款「「quote」——name」格式。\n */\n\n/** 活动状态行单键覆盖值(chat.deepDiving),随轮换定时器逐条上场。 */\nexport const QUOTES: readonly string[] = [\n '「华尔街没有新鲜事」——利弗莫尔',\n '「利润能自己照顾自己,亏损不会」——利弗莫尔',\n '「大钱靠的不是想,而是坐得住」——利弗莫尔',\n '「股价总是沿阻力最小的路线运行」——利弗莫尔',\n '「市场永远不会错,错的往往是人」——利弗莫尔',\n '「别人贪婪时恐惧,别人恐惧时贪婪」——巴菲特',\n '「只有退潮时,才知道谁在裸泳」——巴菲特',\n '「价格是你付出的,价值是你得到的」——巴菲特',\n '「第一条规则:永远不要亏钱」——巴菲特',\n '「风险来自你不知道自己在做什么」——巴菲特',\n '「不想持有十年,就不要持有十分钟」——巴菲特',\n '「大钱不在买卖里,而在等待里」——巴菲特',\n '「市场总是错的」——索罗斯',\n '「对错不重要,赚亏多少才重要」——索罗斯',\n '「我富有,只因知道自己何时错了」——索罗斯',\n '「承认错误,是值得骄傲的事情」——索罗斯',\n '「经济史是一部假象与谎言的连续剧」——索罗斯',\n '「反过来想,总是反过来想」——芒格',\n '「宁要模糊的正确,不要精确的错误」——芒格',\n '「知道会死在哪里,就永远不去那儿」——芒格',\n '「短期是投票机,长期是称重机」——格雷厄姆',\n '「用五毛钱,买一块钱的东西」——格雷厄姆',\n '「股票背后是公司,看它值多少」——彼得·林奇',\n '「行情在悲观中诞生,在狂热中死亡」——邓普顿',\n '「市场非理性,能久过你撑住」——凯恩斯',\n '「痛苦 + 反思 = 进步」——瑞·达里奥',\n]\n","/**\n * client-ui-masters-quotes browser half: 大师金句活动词语言包。\n *\n * 输入框上方的轮次运行状态行由宿主 client-ui-chat 的 TurnStatus 渲染,文案\n * 来自 chat 命名空间的 `chat.deepDiving`(zh 内置值「深度求索中...」)。宿主\n * 词典 (ns, locale) 单一占主——register 同键直接抛错——所以本包走语言包补位\n * (@dshtrading/dsh-i18n 同款范式):注册「中文 · 大师金句」(zh-masters,\n * fallback zh)进语言目录,并在 chat 命名空间只覆盖这一个键;其余全部键位经\n * translate 的逐键 fallback 链(entry ns → fallback → common)回退宿主 zh\n * 词典,选中本语言后 UI 其余部分零漂移。\n *\n * 金句轮换:register 的 publish 会 bump LocaleFace revision,挂载中的\n * TurnStatus 随 re-render 换句。轮换 = dispose 旧词典 + 注册新词典(唯一\n * 公开的重发布路径),每 ROTATE_MS 一跳,页面隐藏时跳过(后台标签页不空转\n * 重渲染)。用户在 Settings → General → Language 选一次本语言,偏好持久化,\n * 之后每个会话自动生效。\n */\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\nimport type { Context as ClientContext } from '@deepseek-ai/cordis'\nimport { QUOTES } from './quotes.ts'\n\n/** Required services:宿主 locale 服务(语言目录 + 词典注册表)。 */\nexport const inject = ['locale']\n\n/** 宿主 client-ui-chat 拥有的 chat 命名空间(其 TurnStatus 的 t 绑定面)。 */\nexport const CHAT_NS = 'chat'\n\n/** 轮次运行状态行的唯一覆盖键(zh 内置值「深度求索中...」)。 */\nexport const DEEP_DIVING_KEY = 'chat.deepDiving'\n\n/** 本语言包补位的 locale id(持久化为 locale preference)。 */\nexport const LOCALE_ID = 'zh-masters'\n\n/** 轮换间隔(ms):长轮次每两分钟换一句,短轮次基本只见首句。 */\nexport const ROTATE_MS = 120_000\n\n/** 语言目录注册项(label 用目标语言自述)。 */\nexport const LANGUAGE: { id: string; label: string; fallback: string } = {\n id: LOCALE_ID,\n label: '中文 · 大师金句', // i18n-allow: 语言自述名按目标语言书写(SDK 契约)\n fallback: 'zh',\n}\n\n/** 下一句索引:随机且不与当前重复(单句库时原地不动)。 */\nexport function nextIndex(current: number, length: number = QUOTES.length): number {\n if (length <= 1) return 0\n let next = Math.floor(Math.random() * length)\n if (next === current) next = (next + 1) % length\n return next\n}\n\n/**\n * 注册语言目录 + 覆盖 chat.deepDiving + 启动轮换(幂等:可重复 apply)。\n * addLanguage/ register 逐项 try/catch:目录项或 (ns, locale) 被占主(重复\n * 安装/宿主新增同 id 语言)时静默降级,不阻塞其余注册。\n */\nexport function apply(ctx: ClientContext): void {\n const disposers: Array<() => void> = []\n let disposed = false\n\n ctx.effect(() => {\n try {\n disposers.push(ctx.locale.addLanguage(LANGUAGE))\n } catch (error) {\n console.warn(`[masters-quotes] addLanguage(${LOCALE_ID}) skipped:`, error)\n }\n\n let index = 0\n let dictDisposer: (() => void) | undefined\n const show = (i: number): void => {\n const quote = QUOTES[i]\n if (quote === undefined) return\n dictDisposer?.()\n dictDisposer = undefined\n try {\n dictDisposer = ctx.locale.register(CHAT_NS, LOCALE_ID, { [DEEP_DIVING_KEY]: quote })\n } catch (error) {\n console.warn(`[masters-quotes] register(${CHAT_NS}, ${LOCALE_ID}) skipped:`, error)\n }\n }\n show(0)\n\n const timer = setInterval(() => {\n if (typeof document !== 'undefined' && document.visibilityState === 'hidden') return\n index = nextIndex(index)\n show(index)\n }, ROTATE_MS)\n\n return () => {\n clearInterval(timer)\n if (disposed) return\n disposed = true\n dictDisposer?.()\n for (const dispose of disposers.reverse()) dispose()\n }\n }, 'client-ui-masters-quotes: masters quote language pack')\n}\n"],"mappings":";;;;;;;;;;;;;;;;;EAWA,MAAa,SAA4B;GACvC;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF;;;;EChBA,MAAa,SAAS,CAAC,QAAQ;;EAG/B,MAAa,UAAU;;EAGvB,MAAa,kBAAkB;;EAG/B,MAAa,YAAY;;EAGzB,MAAa,YAAY;;EAGzB,MAAa,WAA4D;GACvE,IAAI;GACJ,OAAO;GACP,UAAU;EACZ;;EAGA,SAAgB,UAAU,SAAiB,SAAiB,OAAO,QAAgB;GACjF,IAAI,UAAU,GAAG,OAAO;GACxB,IAAI,OAAO,KAAK,MAAM,KAAK,OAAO,IAAI,MAAM;GAC5C,IAAI,SAAS,SAAS,QAAQ,OAAO,KAAK;GAC1C,OAAO;EACT;;;;;;EAOA,SAAgB,MAAM,KAA0B;GAC9C,MAAM,YAA+B,CAAC;GACtC,IAAI,WAAW;GAEf,IAAI,aAAa;IACf,IAAI;KACF,UAAU,KAAK,IAAI,OAAO,YAAY,QAAQ,CAAC;IACjD,SAAS,OAAO;KACd,QAAQ,KAAK,gCAAgC,UAAU,aAAa,KAAK;IAC3E;IAEA,IAAI,QAAQ;IACZ,IAAI;IACJ,MAAM,QAAQ,MAAoB;KAChC,MAAM,QAAQ,OAAO;KACrB,IAAI,UAAU,KAAA,GAAW;KACzB,eAAe;KACf,eAAe,KAAA;KACf,IAAI;MACF,eAAe,IAAI,OAAO,SAAS,SAAS,WAAW,GAAG,kBAAkB,MAAM,CAAC;KACrF,SAAS,OAAO;MACd,QAAQ,KAAK,6BAA6B,QAAQ,IAAI,UAAU,aAAa,KAAK;KACpF;IACF;IACA,KAAK,CAAC;IAEN,MAAM,QAAQ,kBAAkB;KAC9B,IAAI,OAAO,aAAa,eAAe,SAAS,oBAAoB,UAAU;KAC9E,QAAQ,UAAU,KAAK;KACvB,KAAK,KAAK;IACZ,GAAG,SAAS;IAEZ,aAAa;KACX,cAAc,KAAK;KACnB,IAAI,UAAU;KACd,WAAW;KACX,eAAe;KACf,KAAK,MAAM,WAAW,UAAU,QAAQ,GAAG,QAAQ;IACrD;GACF,GAAG,uDAAuD;EAC5D"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { Context } from "@deepseek-ai/cordis";
2
+ //#region src/index.d.ts
3
+ declare const name = "client-ui-masters-quotes";
4
+ declare function apply(_ctx: Context): void;
5
+ //#endregion
6
+ export { apply, name };
package/lib/index.js ADDED
@@ -0,0 +1,5 @@
1
+ //#region src/index.ts
2
+ const name = "client-ui-masters-quotes";
3
+ function apply(_ctx) {}
4
+ //#endregion
5
+ export { apply, name };
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@dshtrading/client-ui-masters-quotes",
3
+ "description": "Masters-quote language-pack plugin for the dsh-trading trading GUI: registers 中文 · 大师金句 (zh-masters, fallback zh) as a selectable language in the host Settings → General → Language row and overrides the single chat.deepDiving key — the turn-status activity line above the composer — with rotating quotes from Livermore, Buffett, Soros, Munger and other investing masters. All other keys fall through the per-key fallback chain to the host zh dictionaries, so the rest of the UI stays pixel-identical.",
4
+ "version": "0.1.2",
5
+ "type": "module",
6
+ "main": "lib/index.js",
7
+ "types": "./lib/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./lib/index.d.ts",
11
+ "default": "./lib/index.js"
12
+ },
13
+ "./client": {
14
+ "types": "./lib/types/client/index.d.ts",
15
+ "default": "./lib/client.js"
16
+ },
17
+ "./package.json": "./package.json"
18
+ },
19
+ "files": [
20
+ "lib"
21
+ ],
22
+ "license": "PolyForm-Noncommercial-1.0.0",
23
+ "peerDependencies": {
24
+ "@deepseek-ai/cordis": ">=4.0.0",
25
+ "@deepseek-ai/dsh-client-locale": ">=0.1.2-rc.1"
26
+ },
27
+ "devDependencies": {
28
+ "@deepseek-ai/cordis": "^4.0.2",
29
+ "@deepseek-ai/dsh-client-locale": "0.1.2-rc.1",
30
+ "tsdown": "^0.22.0",
31
+ "vitest": "^3.0.0"
32
+ },
33
+ "dsh": {
34
+ "client": {
35
+ "inject": [
36
+ "@deepseek-ai/dsh-client-locale"
37
+ ],
38
+ "platform": "web"
39
+ }
40
+ },
41
+ "scripts": {
42
+ "build": "tsdown && tsdown --config tsdown.client.config.mjs",
43
+ "test": "vitest run"
44
+ }
45
+ }