@wsxjs/wsx-core 0.0.5 → 0.0.7
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/dist/{chunk-YNUVFDKT.mjs → chunk-VZQT7HU5.mjs} +4 -4
- package/dist/index.js +370 -24
- package/dist/index.mjs +370 -25
- package/dist/jsx-runtime.js +4 -3
- package/dist/jsx-runtime.mjs +1 -1
- package/dist/jsx.mjs +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/jsx-factory.ts +5 -4
- package/src/light-component.ts +351 -0
- package/src/reactive-component.ts +135 -0
- package/types/index.d.ts +5 -0
- package/types/wsx-types.d.ts +4 -2
- package/dist/chunk-3CJEWYVF.mjs +0 -197
- package/dist/chunk-5JVEHB6H.mjs +0 -197
- package/dist/chunk-7E7KJQSW.mjs +0 -210
- package/dist/chunk-A5GYVTI3.mjs +0 -222
- package/dist/chunk-A5GYVTI3.mjs.map +0 -1
- package/dist/chunk-K6N3JDTI.mjs +0 -216
- package/dist/chunk-RVGKV4GP.mjs +0 -79
- package/dist/chunk-S3O776FY.mjs +0 -173
- package/dist/chunk-VNK4B3FW.mjs +0 -217
- package/dist/chunk-YNUVFDKT.mjs.map +0 -1
- package/dist/index.d.mts +0 -235
- package/dist/index.d.ts +0 -235
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/jsx-factory-pFUwL2Dz.d.mts +0 -26
- package/dist/jsx-factory-pFUwL2Dz.d.ts +0 -26
- package/dist/jsx-pFUwL2Dz.d.mts +0 -26
- package/dist/jsx-pFUwL2Dz.d.ts +0 -26
- package/dist/jsx-runtime-pFUwL2Dz.d.mts +0 -26
- package/dist/jsx-runtime-pFUwL2Dz.d.ts +0 -26
- package/dist/jsx-runtime.d.mts +0 -1
- package/dist/jsx-runtime.d.ts +0 -1
- package/dist/jsx-runtime.js.map +0 -1
- package/dist/jsx-runtime.mjs.map +0 -1
- package/dist/jsx.d.mts +0 -66
- package/dist/jsx.d.ts +0 -66
- package/dist/jsx.js.map +0 -1
- package/dist/jsx.mjs.map +0 -1
|
@@ -195,8 +195,9 @@ function jsx(tag, props) {
|
|
|
195
195
|
return h(tag, null);
|
|
196
196
|
}
|
|
197
197
|
const { children, ...restProps } = props;
|
|
198
|
-
if (children !== void 0) {
|
|
199
|
-
|
|
198
|
+
if (children !== void 0 && children !== null) {
|
|
199
|
+
const childrenArray = Array.isArray(children) ? children : [children];
|
|
200
|
+
return h(tag, restProps, ...childrenArray);
|
|
200
201
|
}
|
|
201
202
|
return h(tag, restProps);
|
|
202
203
|
}
|
|
@@ -207,7 +208,7 @@ function jsxs(tag, props) {
|
|
|
207
208
|
const { children, ...restProps } = props;
|
|
208
209
|
if (Array.isArray(children)) {
|
|
209
210
|
return h(tag, restProps, ...children);
|
|
210
|
-
} else if (children !== void 0) {
|
|
211
|
+
} else if (children !== void 0 && children !== null) {
|
|
211
212
|
return h(tag, restProps, children);
|
|
212
213
|
}
|
|
213
214
|
return h(tag, restProps);
|
|
@@ -219,4 +220,3 @@ export {
|
|
|
219
220
|
jsx,
|
|
220
221
|
jsxs
|
|
221
222
|
};
|
|
222
|
-
//# sourceMappingURL=chunk-YNUVFDKT.mjs.map
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
Fragment: () => Fragment,
|
|
24
|
+
LightComponent: () => LightComponent,
|
|
24
25
|
ReactiveDebug: () => ReactiveDebug,
|
|
25
26
|
ReactiveWebComponent: () => ReactiveWebComponent,
|
|
26
27
|
StyleManager: () => StyleManager,
|
|
@@ -439,30 +440,6 @@ var WebComponent = class extends HTMLElement {
|
|
|
439
440
|
}
|
|
440
441
|
};
|
|
441
442
|
|
|
442
|
-
// src/auto-register.ts
|
|
443
|
-
function autoRegister(options = {}) {
|
|
444
|
-
return function(constructor) {
|
|
445
|
-
const tagName = options.tagName || deriveTagName(constructor.name, options.prefix);
|
|
446
|
-
if (!customElements.get(tagName)) {
|
|
447
|
-
customElements.define(tagName, constructor);
|
|
448
|
-
}
|
|
449
|
-
return constructor;
|
|
450
|
-
};
|
|
451
|
-
}
|
|
452
|
-
function registerComponent(constructor, options = {}) {
|
|
453
|
-
const tagName = options.tagName || deriveTagName(constructor.name, options.prefix);
|
|
454
|
-
if (!customElements.get(tagName)) {
|
|
455
|
-
customElements.define(tagName, constructor);
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
function deriveTagName(className, prefix) {
|
|
459
|
-
let kebabCase = className.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
460
|
-
if (!kebabCase.includes("-")) {
|
|
461
|
-
kebabCase = `${kebabCase}-component`;
|
|
462
|
-
}
|
|
463
|
-
return prefix ? `${prefix}${kebabCase}` : kebabCase;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
443
|
// src/utils/logger.ts
|
|
467
444
|
var WSXLogger = class {
|
|
468
445
|
constructor(prefix = "[WSX]", enabled = true, level = "info") {
|
|
@@ -629,13 +606,283 @@ function reactiveWithDebug(obj, onChange, debugName) {
|
|
|
629
606
|
});
|
|
630
607
|
}
|
|
631
608
|
|
|
609
|
+
// src/light-component.ts
|
|
610
|
+
var logger3 = createLogger("LightComponent");
|
|
611
|
+
var LightComponent = class extends HTMLElement {
|
|
612
|
+
constructor(config = {}) {
|
|
613
|
+
super();
|
|
614
|
+
this.connected = false;
|
|
615
|
+
this._isDebugEnabled = false;
|
|
616
|
+
this._reactiveStates = /* @__PURE__ */ new Map();
|
|
617
|
+
this.config = config;
|
|
618
|
+
this._isDebugEnabled = config.debug ?? false;
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* 子类应该重写这个方法来定义观察的属性
|
|
622
|
+
* @returns 要观察的属性名数组
|
|
623
|
+
*/
|
|
624
|
+
static get observedAttributes() {
|
|
625
|
+
return [];
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Web Component生命周期:连接到DOM
|
|
629
|
+
*/
|
|
630
|
+
connectedCallback() {
|
|
631
|
+
this.connected = true;
|
|
632
|
+
try {
|
|
633
|
+
if (this.config.styles) {
|
|
634
|
+
const styleName = this.config.styleName || this.constructor.name;
|
|
635
|
+
this.applyScopedStyles(styleName, this.config.styles);
|
|
636
|
+
}
|
|
637
|
+
const content = this.render();
|
|
638
|
+
this.appendChild(content);
|
|
639
|
+
this.onConnected?.();
|
|
640
|
+
} catch (error) {
|
|
641
|
+
logger3.error(`[${this.constructor.name}] Error in connectedCallback:`, error);
|
|
642
|
+
this.renderError(error);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* Web Component生命周期:从DOM断开
|
|
647
|
+
*/
|
|
648
|
+
disconnectedCallback() {
|
|
649
|
+
this.cleanupReactiveStates();
|
|
650
|
+
this.cleanupStyles();
|
|
651
|
+
this.onDisconnected?.();
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Web Component生命周期:属性变化
|
|
655
|
+
*/
|
|
656
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
657
|
+
this.onAttributeChanged?.(name, oldValue, newValue);
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* 查找组件内的元素
|
|
661
|
+
*
|
|
662
|
+
* @param selector - CSS选择器
|
|
663
|
+
* @returns 元素或null
|
|
664
|
+
*/
|
|
665
|
+
querySelector(selector) {
|
|
666
|
+
return HTMLElement.prototype.querySelector.call(this, selector);
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* 查找组件内的所有匹配元素
|
|
670
|
+
*
|
|
671
|
+
* @param selector - CSS选择器
|
|
672
|
+
* @returns 元素列表
|
|
673
|
+
*/
|
|
674
|
+
querySelectorAll(selector) {
|
|
675
|
+
return HTMLElement.prototype.querySelectorAll.call(this, selector);
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* 创建响应式对象
|
|
679
|
+
*
|
|
680
|
+
* @param obj 要变为响应式的对象
|
|
681
|
+
* @param debugName 调试名称(可选)
|
|
682
|
+
* @returns 响应式代理对象
|
|
683
|
+
*/
|
|
684
|
+
reactive(obj, debugName) {
|
|
685
|
+
const reactiveFn = this._isDebugEnabled ? reactiveWithDebug : reactive;
|
|
686
|
+
const name = debugName || `${this.constructor.name}.reactive`;
|
|
687
|
+
return this._isDebugEnabled ? reactiveFn(obj, () => this.scheduleRerender(), name) : reactiveFn(obj, () => this.scheduleRerender());
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* 创建响应式状态
|
|
691
|
+
*
|
|
692
|
+
* @param key 状态标识符
|
|
693
|
+
* @param initialValue 初始值
|
|
694
|
+
* @returns [getter, setter] 元组
|
|
695
|
+
*/
|
|
696
|
+
useState(key, initialValue) {
|
|
697
|
+
if (!this._reactiveStates.has(key)) {
|
|
698
|
+
const [getter, setter] = createState(initialValue, () => this.scheduleRerender());
|
|
699
|
+
this._reactiveStates.set(key, { getter, setter });
|
|
700
|
+
}
|
|
701
|
+
const state = this._reactiveStates.get(key);
|
|
702
|
+
return [state.getter, state.setter];
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* 调度重渲染
|
|
706
|
+
* 这个方法被响应式系统调用,开发者通常不需要直接调用
|
|
707
|
+
*/
|
|
708
|
+
scheduleRerender() {
|
|
709
|
+
if (this.connected) {
|
|
710
|
+
this.rerender();
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* 重新渲染组件
|
|
715
|
+
*/
|
|
716
|
+
rerender() {
|
|
717
|
+
if (!this.connected) {
|
|
718
|
+
logger3.warn(
|
|
719
|
+
`[${this.constructor.name}] Component is not connected, skipping rerender.`
|
|
720
|
+
);
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
this.innerHTML = "";
|
|
724
|
+
if (this.config.styles) {
|
|
725
|
+
const styleName = this.config.styleName || this.constructor.name;
|
|
726
|
+
const styleElement = document.createElement("style");
|
|
727
|
+
styleElement.setAttribute("data-wsx-light-component", styleName);
|
|
728
|
+
styleElement.textContent = this.config.styles;
|
|
729
|
+
this.appendChild(styleElement);
|
|
730
|
+
}
|
|
731
|
+
try {
|
|
732
|
+
const content = this.render();
|
|
733
|
+
this.appendChild(content);
|
|
734
|
+
if (this.config.styles && this.children.length > 1) {
|
|
735
|
+
const styleElement = this.querySelector(
|
|
736
|
+
`style[data-wsx-light-component="${this.config.styleName || this.constructor.name}"]`
|
|
737
|
+
);
|
|
738
|
+
if (styleElement && styleElement !== this.firstChild) {
|
|
739
|
+
this.insertBefore(styleElement, this.firstChild);
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
} catch (error) {
|
|
743
|
+
logger3.error(`[${this.constructor.name}] Error in rerender:`, error);
|
|
744
|
+
this.renderError(error);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* 渲染错误信息
|
|
749
|
+
*
|
|
750
|
+
* @param error - 错误对象
|
|
751
|
+
*/
|
|
752
|
+
renderError(error) {
|
|
753
|
+
this.innerHTML = "";
|
|
754
|
+
const errorElement = h(
|
|
755
|
+
"div",
|
|
756
|
+
{
|
|
757
|
+
style: "color: red; padding: 10px; border: 1px solid red; background: #ffe6e6; font-family: monospace;"
|
|
758
|
+
},
|
|
759
|
+
[
|
|
760
|
+
h("strong", {}, `[${this.constructor.name}] Component Error:`),
|
|
761
|
+
h("pre", { style: "margin: 10px 0; white-space: pre-wrap;" }, String(error))
|
|
762
|
+
]
|
|
763
|
+
);
|
|
764
|
+
this.appendChild(errorElement);
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* 为Light DOM组件应用样式
|
|
768
|
+
* 直接将样式注入到组件自身,避免全局污染
|
|
769
|
+
*/
|
|
770
|
+
applyScopedStyles(styleName, cssText) {
|
|
771
|
+
const existingStyle = this.querySelector(`style[data-wsx-light-component="${styleName}"]`);
|
|
772
|
+
if (existingStyle) {
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
775
|
+
const styleElement = document.createElement("style");
|
|
776
|
+
styleElement.setAttribute("data-wsx-light-component", styleName);
|
|
777
|
+
styleElement.textContent = cssText;
|
|
778
|
+
this.insertBefore(styleElement, this.firstChild);
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* 获取配置值
|
|
782
|
+
*
|
|
783
|
+
* @param key - 配置键
|
|
784
|
+
* @param defaultValue - 默认值
|
|
785
|
+
* @returns 配置值
|
|
786
|
+
*/
|
|
787
|
+
getConfig(key, defaultValue) {
|
|
788
|
+
return this.config[key] ?? defaultValue;
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* 设置配置值
|
|
792
|
+
*
|
|
793
|
+
* @param key - 配置键
|
|
794
|
+
* @param value - 配置值
|
|
795
|
+
*/
|
|
796
|
+
setConfig(key, value) {
|
|
797
|
+
this.config[key] = value;
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* 清理响应式状态
|
|
801
|
+
*/
|
|
802
|
+
cleanupReactiveStates() {
|
|
803
|
+
this._reactiveStates.clear();
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* 清理组件样式
|
|
807
|
+
*/
|
|
808
|
+
cleanupStyles() {
|
|
809
|
+
const styleName = this.config.styleName || this.constructor.name;
|
|
810
|
+
const existingStyle = this.querySelector(`style[data-wsx-light-component="${styleName}"]`);
|
|
811
|
+
if (existingStyle) {
|
|
812
|
+
existingStyle.remove();
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* 获取属性值
|
|
817
|
+
*
|
|
818
|
+
* @param name - 属性名
|
|
819
|
+
* @param defaultValue - 默认值
|
|
820
|
+
* @returns 属性值
|
|
821
|
+
*/
|
|
822
|
+
getAttr(name, defaultValue = "") {
|
|
823
|
+
return this.getAttribute(name) || defaultValue;
|
|
824
|
+
}
|
|
825
|
+
/**
|
|
826
|
+
* 设置属性值
|
|
827
|
+
*
|
|
828
|
+
* @param name - 属性名
|
|
829
|
+
* @param value - 属性值
|
|
830
|
+
*/
|
|
831
|
+
setAttr(name, value) {
|
|
832
|
+
this.setAttribute(name, value);
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* 移除属性
|
|
836
|
+
*
|
|
837
|
+
* @param name - 属性名
|
|
838
|
+
*/
|
|
839
|
+
removeAttr(name) {
|
|
840
|
+
this.removeAttribute(name);
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* 检查是否有属性
|
|
844
|
+
*
|
|
845
|
+
* @param name - 属性名
|
|
846
|
+
* @returns 是否存在
|
|
847
|
+
*/
|
|
848
|
+
hasAttr(name) {
|
|
849
|
+
return this.hasAttribute(name);
|
|
850
|
+
}
|
|
851
|
+
};
|
|
852
|
+
|
|
853
|
+
// src/auto-register.ts
|
|
854
|
+
function autoRegister(options = {}) {
|
|
855
|
+
return function(constructor) {
|
|
856
|
+
const tagName = options.tagName || deriveTagName(constructor.name, options.prefix);
|
|
857
|
+
if (!customElements.get(tagName)) {
|
|
858
|
+
customElements.define(tagName, constructor);
|
|
859
|
+
}
|
|
860
|
+
return constructor;
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
function registerComponent(constructor, options = {}) {
|
|
864
|
+
const tagName = options.tagName || deriveTagName(constructor.name, options.prefix);
|
|
865
|
+
if (!customElements.get(tagName)) {
|
|
866
|
+
customElements.define(tagName, constructor);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
function deriveTagName(className, prefix) {
|
|
870
|
+
let kebabCase = className.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
871
|
+
if (!kebabCase.includes("-")) {
|
|
872
|
+
kebabCase = `${kebabCase}-component`;
|
|
873
|
+
}
|
|
874
|
+
return prefix ? `${prefix}${kebabCase}` : kebabCase;
|
|
875
|
+
}
|
|
876
|
+
|
|
632
877
|
// src/reactive-component.ts
|
|
633
878
|
var ReactiveWebComponent = class extends WebComponent {
|
|
634
879
|
constructor(config = {}) {
|
|
635
880
|
super(config);
|
|
636
881
|
this._isDebugEnabled = false;
|
|
882
|
+
this._preserveFocus = true;
|
|
637
883
|
this._reactiveStates = /* @__PURE__ */ new Map();
|
|
638
884
|
this._isDebugEnabled = config.debug ?? false;
|
|
885
|
+
this._preserveFocus = config.preserveFocus ?? true;
|
|
639
886
|
}
|
|
640
887
|
/**
|
|
641
888
|
* 创建响应式对象
|
|
@@ -673,6 +920,104 @@ var ReactiveWebComponent = class extends WebComponent {
|
|
|
673
920
|
this.rerender();
|
|
674
921
|
}
|
|
675
922
|
}
|
|
923
|
+
/**
|
|
924
|
+
* 重写 rerender 方法以支持焦点保持
|
|
925
|
+
*/
|
|
926
|
+
rerender() {
|
|
927
|
+
if (!this.connected) {
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
930
|
+
let focusData = null;
|
|
931
|
+
if (this._preserveFocus) {
|
|
932
|
+
const activeElement = this.shadowRoot.activeElement;
|
|
933
|
+
focusData = this.saveFocusState(activeElement);
|
|
934
|
+
}
|
|
935
|
+
super.rerender();
|
|
936
|
+
if (this._preserveFocus && focusData) {
|
|
937
|
+
this.restoreFocusState(focusData);
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
/**
|
|
941
|
+
* 保存焦点状态
|
|
942
|
+
*/
|
|
943
|
+
saveFocusState(activeElement) {
|
|
944
|
+
if (!activeElement) {
|
|
945
|
+
return null;
|
|
946
|
+
}
|
|
947
|
+
const focusData = {
|
|
948
|
+
tagName: activeElement.tagName.toLowerCase(),
|
|
949
|
+
className: activeElement.className
|
|
950
|
+
};
|
|
951
|
+
if (activeElement.hasAttribute("contenteditable")) {
|
|
952
|
+
const selection = window.getSelection();
|
|
953
|
+
if (selection && selection.rangeCount > 0) {
|
|
954
|
+
const range = selection.getRangeAt(0);
|
|
955
|
+
focusData.selectionStart = range.startOffset;
|
|
956
|
+
focusData.selectionEnd = range.endOffset;
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
if (activeElement instanceof HTMLInputElement || activeElement instanceof HTMLSelectElement) {
|
|
960
|
+
focusData.value = activeElement.value;
|
|
961
|
+
if ("selectionStart" in activeElement) {
|
|
962
|
+
focusData.selectionStart = activeElement.selectionStart;
|
|
963
|
+
focusData.selectionEnd = activeElement.selectionEnd;
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
return focusData;
|
|
967
|
+
}
|
|
968
|
+
/**
|
|
969
|
+
* 恢复焦点状态
|
|
970
|
+
*/
|
|
971
|
+
restoreFocusState(focusData) {
|
|
972
|
+
if (!focusData) return;
|
|
973
|
+
try {
|
|
974
|
+
let targetElement = null;
|
|
975
|
+
if (focusData.className) {
|
|
976
|
+
targetElement = this.shadowRoot.querySelector(
|
|
977
|
+
`.${focusData.className.split(" ")[0]}`
|
|
978
|
+
);
|
|
979
|
+
}
|
|
980
|
+
if (!targetElement) {
|
|
981
|
+
targetElement = this.shadowRoot.querySelector(focusData.tagName);
|
|
982
|
+
}
|
|
983
|
+
if (targetElement) {
|
|
984
|
+
targetElement.focus({ preventScroll: true });
|
|
985
|
+
if (focusData.selectionStart !== void 0) {
|
|
986
|
+
if (targetElement instanceof HTMLInputElement) {
|
|
987
|
+
targetElement.setSelectionRange(
|
|
988
|
+
focusData.selectionStart,
|
|
989
|
+
focusData.selectionEnd
|
|
990
|
+
);
|
|
991
|
+
} else if (targetElement instanceof HTMLSelectElement) {
|
|
992
|
+
targetElement.value = focusData.value;
|
|
993
|
+
} else if (targetElement.hasAttribute("contenteditable")) {
|
|
994
|
+
this.setCursorPosition(targetElement, focusData.selectionStart);
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
} catch {
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
/**
|
|
1002
|
+
* 设置光标位置
|
|
1003
|
+
*/
|
|
1004
|
+
setCursorPosition(element, position) {
|
|
1005
|
+
try {
|
|
1006
|
+
const selection = window.getSelection();
|
|
1007
|
+
if (selection) {
|
|
1008
|
+
const range = document.createRange();
|
|
1009
|
+
const textNode = element.childNodes[0];
|
|
1010
|
+
if (textNode) {
|
|
1011
|
+
const maxPos = Math.min(position, textNode.textContent?.length || 0);
|
|
1012
|
+
range.setStart(textNode, maxPos);
|
|
1013
|
+
range.setEnd(textNode, maxPos);
|
|
1014
|
+
selection.removeAllRanges();
|
|
1015
|
+
selection.addRange(range);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
} catch {
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
676
1021
|
/**
|
|
677
1022
|
* 获取所有响应式状态的快照(用于调试)
|
|
678
1023
|
*/
|
|
@@ -736,6 +1081,7 @@ function createReactiveComponent(ComponentClass, config) {
|
|
|
736
1081
|
// Annotate the CommonJS export names for ESM import in node:
|
|
737
1082
|
0 && (module.exports = {
|
|
738
1083
|
Fragment,
|
|
1084
|
+
LightComponent,
|
|
739
1085
|
ReactiveDebug,
|
|
740
1086
|
ReactiveWebComponent,
|
|
741
1087
|
StyleManager,
|