dsh-composer-ease 0.0.0-stage → 0.9.66

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.
@@ -0,0 +1,76 @@
1
+ // ── 模块:装载与卸载 ────────────────────────────────
2
+ // apply:单例守卫、输入触发源注册、七个事件监听与卸载。
3
+ // 本文件是 lib/client.js 的片段,由 tools/build-client.mjs 按序拼回;不要直接改生成物 lib/client.js。
4
+
5
+ function apply(ctx) {
6
+ // 先跑设置迁移:旧版默认值(引号=标红提示)不该一直粘住,否则「打引号不配对」会当成没修好
7
+ migrateSettings()
8
+ // 单例:同一页面被重复装载(HMR/重复注册)时,一次按键会被两套监听各处理一遍 → 引号/括号翻倍。
9
+ if (typeof window !== 'undefined' && window.__DSH_COMPOSER_PRO_APPLIED__) {
10
+ try { console.warn('[dsh-composer-ease] already applied, skip duplicate mount') } catch (e) {}
11
+ return function () {}
12
+ }
13
+ if (typeof window !== 'undefined') window.__DSH_COMPOSER_PRO_APPLIED__ = true
14
+ try {
15
+ var strays = document.querySelectorAll('#dsh-cp-popup, #dsh-cp-ghost')
16
+ for (var si = 0; si < strays.length; si++) strays[si].parentNode && strays[si].parentNode.removeChild(strays[si])
17
+ } catch (e) {}
18
+ /* 宿主输入触发源:照官方用法 ctx.inject([...], scope => …) —— 注入后的服务在 scope 上。
19
+ * 前提:package.json 的 dsh.client.inject 与 exports.inject 都要声明 inputTriggers
20
+ *(实测:只在其中一处声明时,apply 里取到的是 undefined)。 */
21
+ var unwatchTriggers = []
22
+ try { if (typeof window !== 'undefined') window.__DSE_TRIGGER_SOURCES__ = 0 } catch (e) {}
23
+ var mountSources = function (svc) {
24
+ if (!svc || typeof svc.registerSource !== 'function') return
25
+ buildTriggerSources(ctx).forEach(function (src) {
26
+ try {
27
+ var off = svc.registerSource(src)
28
+ unwatchTriggers.push(off)
29
+ try { window.__DSE_TRIGGER_SOURCES__ = (window.__DSE_TRIGGER_SOURCES__ || 0) + 1 } catch (e) {}
30
+ } catch (e) {
31
+ try { console.warn('[dsh-composer-ease] registerSource 失败:', src.name, e && e.message) } catch (e2) {}
32
+ }
33
+ })
34
+ }
35
+ try {
36
+ if (ctx && typeof ctx.inject === 'function') {
37
+ ctx.inject(['inputTriggers'], function (scope) { mountSources(scope && scope.inputTriggers) })
38
+ } else {
39
+ mountSources((ctx && typeof ctx.get === 'function') ? ctx.get('inputTriggers') : null)
40
+ }
41
+ } catch (e) {
42
+ try { console.warn('[dsh-composer-ease] 触发源注册异常:', e && e.message) } catch (e2) {}
43
+ }
44
+ var d = document
45
+ d.addEventListener('keydown', onKeyDown, true) // capture:先于 Lexical 自己的键位
46
+ d.addEventListener('beforeinput', onBeforeInput, true)
47
+ // ── 引号未闭合的标红提示(VS Code 的 squiggle 口径,不阻断输入)──────────
48
+ if (document.getElementById && !document.getElementById('dce-quote-style')) {
49
+ var st = document.createElement('style')
50
+ st.id = 'dce-quote-style'
51
+ // 波浪线不再画在框底:那条线离文字约 27px,看着像给整个框描边,与「这个词有问题」无关。
52
+ // 现在由 paintQuoteWarn() 用覆盖层逐行画在**文字框底边**上;这里只留行内提示文字。
53
+ // 不再用 ::after 显示文字提示:标红只是一个位置信号,句子内容不该被这句话挤动。
54
+ st.textContent = '[data-dce-quote-warn="1"]{background:none!important}'
55
+ try { document.head && document.head.appendChild(st) } catch (e) {}
56
+ }
57
+ d.addEventListener('input', onInput, true)
58
+ d.addEventListener('focusout', onBlurOut, true)
59
+ d.addEventListener('compositionstart', onCompositionStart, true)
60
+ d.addEventListener('compositionend', onCompositionEnd, true)
61
+ return function () {
62
+ d.removeEventListener('keydown', onKeyDown, true)
63
+ d.removeEventListener('beforeinput', onBeforeInput, true)
64
+ d.removeEventListener('input', onInput, true)
65
+ d.removeEventListener('focusout', onBlurOut, true)
66
+ d.removeEventListener('compositionstart', onCompositionStart, true)
67
+ d.removeEventListener('compositionend', onCompositionEnd, true)
68
+ for (var ui = 0; ui < unwatchTriggers.length; ui++) { try { unwatchTriggers[ui]() } catch (e) {} }
69
+ if (typeof window !== 'undefined') { window.__DSH_COMPOSER_PRO_APPLIED__ = false; window.__DSE_TRIGGER_SOURCES__ = 0 }
70
+ closePopup()
71
+ }
72
+ }
73
+
74
+ exports.apply = apply
75
+ exports.inject = ['inputTriggers'] // 宿主输入触发服务:不声明则 scope 里拿不到(官方用法同)
76
+ exports.__helpers__ = { decideType: decideType, buildTypeEdits: buildTypeEdits, autoCloseMode: autoCloseMode, setAutoCloseMode: setAutoCloseMode, shouldAutoCloseBefore: shouldAutoCloseBefore, AC_MODES: AC_MODES, AC_BEFORE_QUOTES: AC_BEFORE_QUOTES, AC_BEFORE_BRACKETS: AC_BEFORE_BRACKETS, pairStrict: pairStrict, setPairStrict: setPairStrict, migrateSettings: migrateSettings, resetSettings: resetSettings, fwHalf: fwHalf, setFwHalf: setFwHalf, repairWrapDup: repairWrapDup, unclosedQuoteCount: unclosedQuoteCount, expandSnippet: expandSnippet, isKindOn: isKindOn, toggleKind: toggleKind, kindPresetLabel: kindPresetLabel, cycleKindPreset: cycleKindPreset, quoteMode: quoteMode, setQuoteMode: setQuoteMode, lintQuotes: lintQuotes, quoteCount: quoteCount, buildTriggerSources: buildTriggerSources, settingsRows: settingsRows, looseScore: looseScore, typoScore: typoScore, rescueRows: rescueRows, inCommentLine: inCommentLine, PAIRS: PAIRS, PAIRED_CHAR: PAIRED_CHAR, CLOSERS: CLOSERS, shouldPair: shouldPair, tokenBefore: tokenBefore, keyAction: keyAction, docWords: docWords, langHint: langHint, inferLang: inferLang, inferLangVote: inferLangVote, watermarkFor: watermarkFor, conversationText: conversationText, contextWords: contextWords, contextReset: function () { ctxCache.at = 0; ctxCache.words = [] }, caretChar: caretChar, caretOffset: caretOffset, flatText: flatText }
@@ -0,0 +1,17 @@
1
+ // dsh-composer-ease —— 浏览器半边:键位层 + 补全弹层。
2
+ // 形态:宿主模块图里的一个 bundle(照 dsh-skill-meter / dsh-model-priority 的头尾抄结构),
3
+ // 不 require 任何第三方包(动态包里也只拿得到宿主 react,本件用不到)。
4
+ // 行为参照 VSCode(MIT):自动配对、环绕选区、输入闭合符跳过、删除空对、Ctrl+Space 补全。
5
+ // **未复制 VSCode 源码**,只对齐交互;出处见 README 的「来源」节。
6
+ // 补全两类(加第 2 类):
7
+ // 1) 本文词(VSCode 的 word based suggestions 口径):草稿里出现过的标识符,本地即时算,不等网络;
8
+ // 2) 语言词表:HTML 标签 / JS·Python·Java 关键字 / CSS 属性名,服务端 lib/words.js 供,
9
+ // 数据借自 monaco-editor、codemirror、MDN BCD(均为宽松许可,源地址与 commit 见 words.js 头部与 THIRD-PARTY.md)。
10
+ // 触发:'/' 与 '@',以及**打满两个标识符字符就自动弹**(VSCode 手感);Tab/Enter 接受、Esc 关、上下选。
11
+ window.__ModuleLoader__.load({
12
+ id: 'dsh-composer-ease',
13
+ factory: function (require) {
14
+ var module = { exports: {} }
15
+ var exports = module.exports
16
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' })
17
+
@@ -0,0 +1,3 @@
1
+ return module.exports
2
+ },
3
+ })