uicore-ts 1.1.228 → 1.1.237
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/compiledScripts/UIBaseButton.js +7 -3
- package/compiledScripts/UIBaseButton.js.map +2 -2
- package/compiledScripts/UIButton.js.map +1 -1
- package/compiledScripts/UILayoutCycleTracer.d.ts +80 -0
- package/compiledScripts/UILayoutCycleTracer.js +194 -0
- package/compiledScripts/UILayoutCycleTracer.js.map +7 -0
- package/compiledScripts/UITextView.js +13 -15
- package/compiledScripts/UITextView.js.map +2 -2
- package/compiledScripts/UIView.js +18 -1
- package/compiledScripts/UIView.js.map +2 -2
- package/package.json +1 -1
- package/scripts/UIBaseButton.ts +32 -121
- package/scripts/UIButton.ts +0 -1
- package/scripts/UILayoutCycleTracer.ts +248 -0
- package/scripts/UITextView.ts +15 -15
- package/scripts/UIView.ts +26 -1
|
@@ -192,9 +192,13 @@ class UIBaseButton extends import_UIView.UIView {
|
|
|
192
192
|
didReceiveBroadcastEvent(event) {
|
|
193
193
|
super.didReceiveBroadcastEvent(event);
|
|
194
194
|
if (event.name == import_UIView.UIView.broadcastEventName.PageDidScroll || event.name == import_UIView.UIView.broadcastEventName.AddedToViewTree) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
this.
|
|
195
|
+
const wasHovered = this._hovered;
|
|
196
|
+
const wasHighlighted = this._highlighted;
|
|
197
|
+
this._hovered = import_UIObject.NO;
|
|
198
|
+
this._highlighted = import_UIObject.NO;
|
|
199
|
+
if (wasHovered || wasHighlighted) {
|
|
200
|
+
this.updateContentForCurrentState();
|
|
201
|
+
}
|
|
198
202
|
}
|
|
199
203
|
}
|
|
200
204
|
toggleSelectedState() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/UIBaseButton.ts"],
|
|
4
|
-
"sourcesContent": ["import { UIColor } from \"./UIColor\"\nimport { IS, nil, NO, YES } from \"./UIObject\"\nimport { UIView, UIViewBroadcastEvent } from \"./UIView\"\n\n\nexport class UIBaseButton extends UIView {\n \n _selected: boolean = NO\n _highlighted: boolean = NO\n \n override _isPointerInside: boolean\n \n \n _isToggleable: boolean = NO\n _hovered?: boolean\n _focused?: boolean\n \n \n constructor(elementID?: string, elementType?: string) {\n \n super(elementID, undefined, elementType)\n \n // Instance variables\n \n \n this._isPointerInside = NO\n \n \n const setHovered = () => {\n this.hovered = YES\n }\n this.addTargetForControlEvent(UIView.controlEvent.PointerHover, setHovered)\n \n const setNotHovered = () => {\n \n this.hovered = NO\n \n }\n \n this.addTargetForControlEvents([\n UIView.controlEvent.PointerLeave, UIView.controlEvent.PointerCancel, UIView.controlEvent.MultipleTouches\n ], setNotHovered)\n \n \n let highlightingTime: number\n const setHighlighted = () => {\n this.highlighted = YES\n highlightingTime = Date.now()\n }\n this.addTargetForControlEvent(UIView.controlEvent.PointerDown, setHighlighted)\n this.addTargetForControlEvent(UIView.controlEvent.PointerEnter, setHighlighted)\n \n const setNotHighlighted = () => {\n this.highlighted = NO\n }\n const setNotHighlightedWithMinimumDuration = () => {\n const minimumDurationInMilliseconds = 50\n const elapsedTime = Date.now() - highlightingTime\n if (minimumDurationInMilliseconds < elapsedTime) {\n this.highlighted = NO\n }\n else {\n setTimeout(() => {\n this.highlighted = NO\n }, minimumDurationInMilliseconds - elapsedTime)\n }\n }\n this.addTargetForControlEvents([\n UIView.controlEvent.PointerLeave, UIView.controlEvent.PointerCancel, UIView.controlEvent.MultipleTouches\n ], setNotHighlighted)\n this.addTargetForControlEvent(UIView.controlEvent.PointerUp, setNotHighlightedWithMinimumDuration)\n \n // Handle enter key press\n this.addTargetForControlEvent(UIView.controlEvent.EnterDown, () => {\n \n setHighlighted()\n setNotHighlightedWithMinimumDuration()\n \n })\n \n \n this.addTargetForControlEvent(\n UIView.controlEvent.Focus,\n (sender: UIView, event: Event) => {\n \n this.focused = YES\n \n }\n )\n \n this.addTargetForControlEvent(\n UIView.controlEvent.Blur,\n (sender: UIView, event: Event) => {\n \n this.focused = NO\n \n }\n )\n \n \n this.pausesPointerEvents = YES\n this.tabIndex = 1\n \n this.style.cursor = \"pointer\"\n \n //this.style.outline = \"none\";\n \n \n this.nativeSelectionEnabled = NO\n \n \n this.addTargetForControlEvents([\n UIView.controlEvent.EnterDown, UIView.controlEvent.PointerUpInside\n ], () => {\n \n if (this.isToggleable) {\n \n this.toggleSelectedState()\n \n }\n \n })\n \n }\n \n public set hovered(hovered: boolean) {\n this._hovered = hovered\n this.updateContentForCurrentState()\n }\n \n public get hovered(): boolean {\n return this._hovered ?? NO\n }\n \n public set highlighted(highlighted: boolean) {\n this._highlighted = highlighted\n this.updateContentForCurrentState()\n }\n \n public get highlighted(): boolean {\n return this._highlighted\n }\n \n public set focused(focused: boolean) {\n this._focused = focused\n if (focused) {\n this.focus()\n }\n else {\n this.blur()\n }\n this.updateContentForCurrentState()\n }\n \n public get focused(): boolean {\n return this._focused ?? NO\n }\n \n public set selected(selected: boolean) {\n this._selected = selected\n this.updateContentForCurrentState()\n }\n \n public get selected(): boolean {\n return this._selected\n }\n \n \n updateContentForCurrentState() {\n \n let updateFunction: Function = this.updateContentForNormalState\n if (this.selected && this.highlighted) {\n updateFunction = this.updateContentForSelectedAndHighlightedState\n }\n else if (this.selected) {\n updateFunction = this.updateContentForSelectedState\n }\n else if (this.focused) {\n updateFunction = this.updateContentForFocusedState\n }\n else if (this.highlighted) {\n updateFunction = this.updateContentForHighlightedState\n }\n else if (this.hovered) {\n updateFunction = this.updateContentForHoveredState\n }\n \n if (!IS(updateFunction)) {\n this.backgroundColor = UIColor.nilColor\n }\n else {\n updateFunction.call(this)\n }\n \n }\n \n updateContentForNormalState() {\n \n \n }\n \n updateContentForHoveredState() {\n \n this.updateContentForNormalState()\n \n }\n \n updateContentForFocusedState() {\n \n this.updateContentForHoveredState()\n \n }\n \n updateContentForHighlightedState() {\n \n \n }\n \n updateContentForSelectedState() {\n \n \n }\n \n updateContentForSelectedAndHighlightedState() {\n \n this.updateContentForSelectedState()\n \n }\n \n \n override set enabled(enabled: boolean) {\n super.enabled = enabled\n this.updateContentForCurrentEnabledState()\n }\n \n override get enabled() {\n return super.enabled\n }\n \n override updateContentForCurrentEnabledState() {\n \n if (this.enabled) {\n this.alpha = 1\n }\n else {\n this.alpha = 0.5\n }\n \n this.userInteractionEnabled = this.enabled\n \n }\n \n \n override addStyleClass(styleClassName: string) {\n \n super.addStyleClass(styleClassName)\n \n if (this.styleClassName != styleClassName) {\n \n this.updateContentForCurrentState.call(this)\n \n }\n \n }\n \n \n override didReceiveBroadcastEvent(event: UIViewBroadcastEvent) {\n \n super.didReceiveBroadcastEvent(event)\n \n if (event.name == UIView.broadcastEventName.PageDidScroll || event.name ==\n UIView.broadcastEventName.AddedToViewTree) {\n \n this.hovered = NO\n \n this.highlighted = NO\n \n this.updateContentForCurrentState()\n \n }\n \n \n }\n \n \n toggleSelectedState() {\n \n \n this.selected = !this.selected\n \n \n }\n \n set isToggleable(isToggleable: boolean) {\n \n this._isToggleable = isToggleable\n \n }\n \n get isToggleable() {\n \n return this._isToggleable\n \n }\n \n \n override layoutSubviews() {\n \n super.layoutSubviews()\n \n const bounds = this.bounds\n \n \n }\n \n \n override sendControlEventForKey(eventKey: string, nativeEvent: Event) {\n \n if (eventKey == UIView.controlEvent.PointerUpInside && !this.highlighted) {\n \n // Do not send the event in this case\n //super.sendControlEventForKey(eventKey, nativeEvent);\n \n const asd = 1\n \n }\n else {\n \n super.sendControlEventForKey(eventKey, nativeEvent)\n \n }\n \n }\n \n \n static getEventCoordinatesInDocument(touchOrMouseEvent: any) {\n // http://www.quirksmode.org/js/events_properties.html\n var posx = 0\n var posy = 0\n var e = touchOrMouseEvent\n if (!e) {\n e = window.event\n }\n if (e.pageX || e.pageY) {\n posx = e.pageX\n posy = e.pageY\n }\n else if (e.clientX || e.clientY) {\n posx = e.clientX + document.body.scrollLeft\n + document.documentElement.scrollLeft\n posy = e.clientY + document.body.scrollTop\n + document.documentElement.scrollTop\n }\n // posx and posy contain the mouse position relative to the document\n \n const coordinates = { \"x\": posx, \"y\": posy }\n \n return coordinates\n \n }\n \n \n static getElementPositionInDocument(el: { tagName: string; offsetLeft: number; scrollLeft: number; clientLeft: number; offsetTop: number; scrollTop: number; clientTop: number; offsetParent: any }) {\n //https://www.kirupa.com/html5/getting_mouse_click_position.htm\n var xPosition = 0\n var yPosition = 0\n \n while (el) {\n if (el.tagName == \"BODY\") {\n \n // Coordinates in document are coordinates in body, therefore subtracting the scroll position of the body is not needed\n \n // // deal with browser quirks with body/window/document and page scroll\n // var xScrollPos = el.scrollLeft || document.documentElement.scrollLeft;\n // var yScrollPos = el.scrollTop || document.documentElement.scrollTop;\n //\n // xPosition += (el.offsetLeft - xScrollPos + el.clientLeft);\n // yPosition += (el.offsetTop - yScrollPos + el.clientTop);\n }\n else {\n xPosition += (el.offsetLeft - el.scrollLeft + el.clientLeft)\n yPosition += (el.offsetTop - el.scrollTop + el.clientTop)\n }\n \n el = el.offsetParent\n }\n return {\n x: xPosition,\n y: yPosition\n }\n }\n \n static convertCoordinatesFromDocumentToElement(x: number, y: number, element: any) {\n const elementPositionInDocument = this.getElementPositionInDocument(element)\n const coordinatesInElement = { \"x\": x - elementPositionInDocument.x, \"y\": y - elementPositionInDocument.y }\n return coordinatesInElement\n }\n \n static getEventCoordinatesInElement(touchOrMouseEvent: any, element: any) {\n const coordinatesInDocument = this.getEventCoordinatesInDocument(touchOrMouseEvent)\n const coordinatesInElement = this.convertCoordinatesFromDocumentToElement(\n coordinatesInDocument.x,\n coordinatesInDocument.y,\n element\n )\n return coordinatesInElement\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\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\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\n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AE3D,UAAM,yBAAyB,KAAK;AAEpC,QAAI,MAAM,QAAQ,qBAAO,mBAAmB,iBAAiB,MAAM,QAC/D,qBAAO,mBAAmB,iBAAiB;AAE3C,WAAK,
|
|
4
|
+
"sourcesContent": ["import { UIColor } from \"./UIColor\"\nimport { IS, nil, NO, YES } from \"./UIObject\"\nimport { UIView, UIViewBroadcastEvent } from \"./UIView\"\n\n\nexport class UIBaseButton extends UIView {\n \n _selected: boolean = NO\n _highlighted: boolean = NO\n \n override _isPointerInside: boolean\n \n \n _isToggleable: boolean = NO\n _hovered?: boolean\n _focused?: boolean\n \n \n constructor(elementID?: string, elementType?: string) {\n \n super(elementID, undefined, elementType)\n \n // Instance variables\n \n \n this._isPointerInside = NO\n \n \n const setHovered = () => {\n this.hovered = YES\n }\n this.addTargetForControlEvent(UIView.controlEvent.PointerHover, setHovered)\n \n const setNotHovered = () => {\n \n this.hovered = NO\n \n }\n \n this.addTargetForControlEvents([\n UIView.controlEvent.PointerLeave, UIView.controlEvent.PointerCancel, UIView.controlEvent.MultipleTouches\n ], setNotHovered)\n \n \n let highlightingTime: number\n const setHighlighted = () => {\n this.highlighted = YES\n highlightingTime = Date.now()\n }\n this.addTargetForControlEvent(UIView.controlEvent.PointerDown, setHighlighted)\n this.addTargetForControlEvent(UIView.controlEvent.PointerEnter, setHighlighted)\n \n const setNotHighlighted = () => {\n this.highlighted = NO\n }\n const setNotHighlightedWithMinimumDuration = () => {\n const minimumDurationInMilliseconds = 50\n const elapsedTime = Date.now() - highlightingTime\n if (minimumDurationInMilliseconds < elapsedTime) {\n this.highlighted = NO\n }\n else {\n setTimeout(() => {\n this.highlighted = NO\n }, minimumDurationInMilliseconds - elapsedTime)\n }\n }\n this.addTargetForControlEvents([\n UIView.controlEvent.PointerLeave, UIView.controlEvent.PointerCancel, UIView.controlEvent.MultipleTouches\n ], setNotHighlighted)\n this.addTargetForControlEvent(UIView.controlEvent.PointerUp, setNotHighlightedWithMinimumDuration)\n \n // Handle enter key press\n this.addTargetForControlEvent(UIView.controlEvent.EnterDown, () => {\n \n setHighlighted()\n setNotHighlightedWithMinimumDuration()\n \n })\n \n \n this.addTargetForControlEvent(\n UIView.controlEvent.Focus,\n (sender: UIView, event: Event) => {\n \n this.focused = YES\n \n }\n )\n \n this.addTargetForControlEvent(\n UIView.controlEvent.Blur,\n (sender: UIView, event: Event) => {\n \n this.focused = NO\n \n }\n )\n \n \n this.pausesPointerEvents = YES\n this.tabIndex = 1\n \n this.style.cursor = \"pointer\"\n \n //this.style.outline = \"none\";\n \n \n this.nativeSelectionEnabled = NO\n \n \n this.addTargetForControlEvents([\n UIView.controlEvent.EnterDown, UIView.controlEvent.PointerUpInside\n ], () => {\n \n if (this.isToggleable) {\n \n this.toggleSelectedState()\n \n }\n \n })\n \n }\n \n public set hovered(hovered: boolean) {\n this._hovered = hovered\n this.updateContentForCurrentState()\n }\n \n public get hovered(): boolean {\n return this._hovered ?? NO\n }\n \n public set highlighted(highlighted: boolean) {\n this._highlighted = highlighted\n this.updateContentForCurrentState()\n }\n \n public get highlighted(): boolean {\n return this._highlighted\n }\n \n public set focused(focused: boolean) {\n this._focused = focused\n if (focused) {\n this.focus()\n }\n else {\n this.blur()\n }\n this.updateContentForCurrentState()\n }\n \n public get focused(): boolean {\n return this._focused ?? NO\n }\n \n public set selected(selected: boolean) {\n this._selected = selected\n this.updateContentForCurrentState()\n }\n \n public get selected(): boolean {\n return this._selected\n }\n \n \n updateContentForCurrentState() {\n \n let updateFunction: Function = this.updateContentForNormalState\n if (this.selected && this.highlighted) {\n updateFunction = this.updateContentForSelectedAndHighlightedState\n }\n else if (this.selected) {\n updateFunction = this.updateContentForSelectedState\n }\n else if (this.focused) {\n updateFunction = this.updateContentForFocusedState\n }\n else if (this.highlighted) {\n updateFunction = this.updateContentForHighlightedState\n }\n else if (this.hovered) {\n updateFunction = this.updateContentForHoveredState\n }\n \n if (!IS(updateFunction)) {\n this.backgroundColor = UIColor.nilColor\n }\n else {\n updateFunction.call(this)\n }\n \n }\n \n updateContentForNormalState() {\n \n \n }\n \n updateContentForHoveredState() {\n \n this.updateContentForNormalState()\n \n }\n \n updateContentForFocusedState() {\n \n this.updateContentForHoveredState()\n \n }\n \n updateContentForHighlightedState() {\n \n \n }\n \n updateContentForSelectedState() {\n \n \n }\n \n updateContentForSelectedAndHighlightedState() {\n \n this.updateContentForSelectedState()\n \n }\n \n \n override set enabled(enabled: boolean) {\n super.enabled = enabled\n this.updateContentForCurrentEnabledState()\n }\n \n override get enabled() {\n return super.enabled\n }\n \n override updateContentForCurrentEnabledState() {\n \n if (this.enabled) {\n this.alpha = 1\n }\n else {\n this.alpha = 0.5\n }\n \n this.userInteractionEnabled = this.enabled\n \n }\n \n \n override addStyleClass(styleClassName: string) {\n \n super.addStyleClass(styleClassName)\n \n if (this.styleClassName != styleClassName) {\n \n this.updateContentForCurrentState.call(this)\n \n }\n \n }\n \n \n override didReceiveBroadcastEvent(event: UIViewBroadcastEvent) {\n \n super.didReceiveBroadcastEvent(event)\n \n if (event.name == UIView.broadcastEventName.PageDidScroll || event.name ==\n UIView.broadcastEventName.AddedToViewTree) {\n \n const wasHovered = this._hovered\n const wasHighlighted = this._highlighted\n \n this._hovered = NO\n this._highlighted = NO\n \n if (wasHovered || wasHighlighted) {\n this.updateContentForCurrentState()\n }\n \n }\n \n \n }\n \n \n toggleSelectedState() {\n \n \n this.selected = !this.selected\n \n \n }\n \n set isToggleable(isToggleable: boolean) {\n \n this._isToggleable = isToggleable\n \n }\n \n get isToggleable() {\n \n return this._isToggleable\n \n }\n \n \n override layoutSubviews() {\n \n super.layoutSubviews()\n \n const bounds = this.bounds\n \n \n }\n \n \n override sendControlEventForKey(eventKey: string, nativeEvent: Event) {\n \n if (eventKey == UIView.controlEvent.PointerUpInside && !this.highlighted) {\n \n // Do not send the event in this case\n //super.sendControlEventForKey(eventKey, nativeEvent);\n \n const asd = 1\n \n }\n else {\n \n super.sendControlEventForKey(eventKey, nativeEvent)\n \n }\n \n }\n \n \n static getEventCoordinatesInDocument(touchOrMouseEvent: any) {\n // http://www.quirksmode.org/js/events_properties.html\n var posx = 0\n var posy = 0\n var e = touchOrMouseEvent\n if (!e) {\n e = window.event\n }\n if (e.pageX || e.pageY) {\n posx = e.pageX\n posy = e.pageY\n }\n else if (e.clientX || e.clientY) {\n posx = e.clientX + document.body.scrollLeft\n + document.documentElement.scrollLeft\n posy = e.clientY + document.body.scrollTop\n + document.documentElement.scrollTop\n }\n // posx and posy contain the mouse position relative to the document\n \n const coordinates = { \"x\": posx, \"y\": posy }\n \n return coordinates\n \n }\n \n \n static getElementPositionInDocument(el: { tagName: string; offsetLeft: number; scrollLeft: number; clientLeft: number; offsetTop: number; scrollTop: number; clientTop: number; offsetParent: any }) {\n //https://www.kirupa.com/html5/getting_mouse_click_position.htm\n var xPosition = 0\n var yPosition = 0\n \n while (el) {\n if (el.tagName == \"BODY\") {\n \n // Coordinates in document are coordinates in body, therefore subtracting the scroll position of the body is not needed\n \n // // deal with browser quirks with body/window/document and page scroll\n // var xScrollPos = el.scrollLeft || document.documentElement.scrollLeft;\n // var yScrollPos = el.scrollTop || document.documentElement.scrollTop;\n //\n // xPosition += (el.offsetLeft - xScrollPos + el.clientLeft);\n // yPosition += (el.offsetTop - yScrollPos + el.clientTop);\n }\n else {\n xPosition += (el.offsetLeft - el.scrollLeft + el.clientLeft)\n yPosition += (el.offsetTop - el.scrollTop + el.clientTop)\n }\n \n el = el.offsetParent\n }\n return {\n x: xPosition,\n y: yPosition\n }\n }\n \n static convertCoordinatesFromDocumentToElement(x: number, y: number, element: any) {\n const elementPositionInDocument = this.getElementPositionInDocument(element)\n const coordinatesInElement = { \"x\": x - elementPositionInDocument.x, \"y\": y - elementPositionInDocument.y }\n return coordinatesInElement\n }\n \n static getEventCoordinatesInElement(touchOrMouseEvent: any, element: any) {\n const coordinatesInDocument = this.getEventCoordinatesInDocument(touchOrMouseEvent)\n const coordinatesInElement = this.convertCoordinatesFromDocumentToElement(\n coordinatesInDocument.x,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A,OAAO,6BAA6B,IAAiK;AAEjM,QAAI,YAAY;AAChB,QAAI,YAAY;AAEhB,WAAO,IAAI;AACP,UAAI,GAAG,WAAW,QAAQ;AAAA,MAU1B,OACK;AACD,qBAAc,GAAG,aAAa,GAAG,aAAa,GAAG;AACjD,qBAAc,GAAG,YAAY,GAAG,YAAY,GAAG;AAAA,MACnD;AAEA,WAAK,GAAG;AAAA,IACZ;AACA,WAAO;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,IACP;AAAA,EACJ;AAAA,EAEA,OAAO,wCAAwC,GAAW,GAAW,SAAc;AAC/E,UAAM,4BAA4B,KAAK,6BAA6B,OAAO;AAC3E,UAAM,uBAAuB,EAAE,KAAK,IAAI,0BAA0B,GAAG,KAAK,IAAI,0BAA0B,EAAE;AAC1G,WAAO;AAAA,EACX;AAAA,EAEA,OAAO,6BAA6B,mBAAwB,SAAc;AACtE,UAAM,wBAAwB,KAAK,8BAA8B,iBAAiB;AAClF,UAAM,uBAAuB,KAAK;AAAA,MAC9B,sBAAsB;AAAA,MACtB,sBAAsB;AAAA,MACtB;AAAA,IACJ;AACA,WAAO;AAAA,EACX;AAGJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/UIButton.ts"],
|
|
4
|
-
"sourcesContent": ["import { UIBaseButton } from \"./UIBaseButton\"\nimport { UIColor } from \"./UIColor\"\nimport { UIImageView } from \"./UIImageView\"\nimport { IS, IS_NOT, IS_NOT_NIL, nil, NO, ValueOf, YES } from \"./UIObject\"\nimport { UIRectangle } from \"./UIRectangle\"\nimport { UITextView } from \"./UITextView\"\n\n\nexport interface UIButtonColorSpecifier {\n \n titleLabel: UIButtonElementColorSpecifier;\n background: UIButtonElementColorSpecifier;\n \n}\n\n\nexport interface UIButtonElementColorSpecifier {\n \n normal: UIColor;\n hovered?: UIColor;\n highlighted: UIColor;\n focused?: UIColor;\n selected: UIColor;\n selectedAndHighlighted?: UIColor;\n \n}\n\n\nexport class UIButton extends UIBaseButton {\n \n _contentPadding = 0\n _titleLabel: UITextView = nil\n _imageView: UIImageView\n \n usesAutomaticTitleFontSize = NO\n minAutomaticFontSize?: number\n maxAutomaticFontSize?: number = 25\n \n colors: UIButtonColorSpecifier = {\n \n titleLabel: {\n \n normal: UIColor.whiteColor,\n highlighted: UIColor.whiteColor,\n selected: UIColor.whiteColor\n \n },\n \n background: {\n \n normal: UIColor.blueColor,\n highlighted: UIColor.greenColor,\n selected: UIColor.redColor\n \n }\n \n }\n \n \n constructor(\n elementID?: string,\n elementType?: string,\n titleType: string | ValueOf<typeof UITextView.type> = UITextView.type.span\n ) {\n \n super(elementID, elementType)\n \n // Instance variables\n \n this._imageView = new UIImageView(this.elementID + \"ImageView\")\n this._imageView.hidden = YES\n this.addSubview(this.imageView)\n \n this.imageView.fillMode = UIImageView.fillMode.aspectFitIfLarger\n \n \n if (IS_NOT_NIL(titleType)) {\n \n this._titleLabel = new UITextView(this.elementID + \"TitleLabel\", titleType)\n this.titleLabel!.style.whiteSpace = \"nowrap\"\n this.addSubview(this.titleLabel!)\n \n this.titleLabel!.userInteractionEnabled = NO\n \n }\n \n this.contentPadding = 10\n \n this.imageView.userInteractionEnabled = NO\n if (this.titleLabel) {\n this.titleLabel.textAlignment = UITextView.textAlignment.center\n this.titleLabel.nativeSelectionEnabled = NO\n }\n \n }\n \n \n get contentPadding() {\n return this._contentPadding.integerValue\n }\n \n set contentPadding(contentPadding) {\n this._contentPadding = contentPadding\n this.setNeedsLayout()\n }\n \n \n public override set hovered(hovered: boolean) {\n this._hovered = hovered\n this.updateContentForCurrentState()\n }\n \n public override get hovered(): boolean {\n return this._hovered ?? NO\n }\n \n public override set highlighted(highlighted: boolean) {\n this._highlighted = highlighted\n this.updateContentForCurrentState()\n }\n \n public override get highlighted(): boolean {\n return this._highlighted\n }\n \n public override set focused(focused: boolean) {\n this._focused = focused\n if (focused) {\n this.focus()\n }\n else {\n this.blur()\n }\n this.updateContentForCurrentState()\n }\n \n public override get focused(): boolean {\n return this._focused ?? NO\n }\n \n public override set selected(selected: boolean) {\n this._selected = selected\n this.updateContentForCurrentState()\n }\n \n public override get selected(): boolean {\n return this._selected\n }\n \n \n override updateContentForCurrentState() {\n \n let updateFunction: Function = this.updateContentForNormalState\n if (this.selected && this.highlighted) {\n updateFunction = this.updateContentForSelectedAndHighlightedState\n }\n else if (this.selected) {\n updateFunction = this.updateContentForSelectedState\n }\n else if (this.focused) {\n updateFunction = this.updateContentForFocusedState\n }\n else if (this.highlighted) {\n updateFunction = this.updateContentForHighlightedState\n }\n else if (this.hovered) {\n updateFunction = this.updateContentForHoveredState\n }\n \n if (!IS(updateFunction)) {\n if (this.titleLabel) {\n this.titleLabel.textColor = UIColor.nilColor\n }\n this.backgroundColor = UIColor.nilColor\n }\n else {\n updateFunction.call(this)\n }\n \n this.updateContentForCurrentEnabledState()\n \n }\n \n override updateContentForNormalState() {\n \n this.backgroundColor = this.colors.background.normal\n if (this.titleLabel) {\n this.titleLabel.textColor = this.colors.titleLabel.normal\n }\n \n }\n \n override updateContentForHoveredState() {\n \n this.updateContentForNormalState()\n \n if (this.colors.background.hovered) {\n this.backgroundColor = this.colors.background.hovered\n }\n \n if (this.colors.titleLabel.hovered && this.titleLabel) {\n this.titleLabel.textColor = this.colors.titleLabel.hovered\n }\n \n }\n \n override updateContentForFocusedState() {\n \n this.updateContentForHoveredState()\n \n if (this.colors.background.focused) {\n this.backgroundColor = this.colors.background.focused\n }\n \n if (this.colors.titleLabel.focused && this.titleLabel) {\n this.titleLabel.textColor = this.colors.titleLabel.focused\n }\n \n }\n \n override updateContentForHighlightedState() {\n \n this.backgroundColor = this.colors.background.highlighted\n if (this.titleLabel) {\n this.titleLabel.textColor = this.colors.titleLabel.highlighted\n }\n \n }\n \n override updateContentForSelectedState() {\n \n this.backgroundColor = this.colors.background.selected\n if (this.titleLabel) {\n this.titleLabel.textColor = this.colors.titleLabel.selected\n }\n \n }\n \n override updateContentForSelectedAndHighlightedState() {\n \n this.updateContentForSelectedState()\n \n if (this.colors.background.selectedAndHighlighted) {\n this.backgroundColor = this.colors.background.selectedAndHighlighted\n }\n \n if (this.colors.titleLabel.selectedAndHighlighted && this.titleLabel) {\n this.titleLabel.textColor = this.colors.titleLabel.selectedAndHighlighted\n }\n \n }\n \n \n override set enabled(enabled: boolean) {\n \n // @ts-ignore\n super.enabled = enabled\n \n this.updateContentForCurrentState()\n \n }\n \n override get enabled() {\n \n // @ts-ignore\n return super.enabled\n \n }\n \n override updateContentForCurrentEnabledState() {\n \n if (this.enabled) {\n this.alpha = 1\n }\n else {\n this.alpha = 0.5\n }\n \n this.userInteractionEnabled = this.enabled\n \n }\n \n \n override addStyleClass(styleClassName: string) {\n \n super.addStyleClass(styleClassName)\n \n if (this.styleClassName != styleClassName) {\n \n this.updateContentForCurrentState.call(this)\n \n }\n \n }\n \n \n get titleLabel(): UITextView {\n return this._titleLabel\n }\n \n get imageView() {\n \n return this._imageView\n \n }\n \n \n override layoutSubviews() {\n \n super.layoutSubviews()\n \n let bounds = this.bounds\n \n this.hoverText = this.hoverText ?? this.titleLabel?.text ?? \"\"\n \n // Image only if text is not present\n if (IS_NOT(this.imageView.hidden) && !IS(this.titleLabel?.text)) {\n \n this.imageView.frame = bounds\n \n }\n \n // Text only if image is not present\n if (IS(this.imageView.hidden) && this.titleLabel?.text) {\n \n this.titleLabel.style.left = this.contentPadding + \"px\"\n this.titleLabel.style.right = this.contentPadding + \"px\"\n // this.titleLabel.style.marginLeft = \"\"\n // this.titleLabel.style.right = this.contentPadding\n this.titleLabel.style.bottom = \"0px\"\n this.titleLabel.style.top = \"0px\"\n this.titleLabel.frame = new UIRectangle(nil, nil, nil, nil)\n \n if (this.usesAutomaticTitleFontSize) {\n \n const hidden = this.titleLabel.hidden\n \n this.titleLabel.hidden = YES\n \n this.titleLabel.fontSize = 15\n \n this.titleLabel.fontSize = UITextView.automaticallyCalculatedFontSize(\n new UIRectangle(\n 0,\n 0,\n this.bounds.height,\n this.titleLabel.viewHTMLElement.offsetWidth\n ),\n this.titleLabel.intrinsicContentSize(),\n this.titleLabel.fontSize,\n this.minAutomaticFontSize,\n this.maxAutomaticFontSize\n )\n \n this.titleLabel.hidden = hidden\n \n }\n \n \n }\n \n // Image and text both present\n if (IS_NOT(this.imageView.hidden) && this.titleLabel?.text) {\n \n //const imageShareOfWidth = 0.25\n \n bounds = bounds.rectangleWithInset(this.contentPadding)\n \n const imageFrame = bounds.copy()\n imageFrame.width = bounds.height - this.contentPadding * 0.5\n this.imageView.frame = imageFrame\n \n this.titleLabel.style.left = imageFrame.max.x + this.contentPadding + \"px\"\n this.titleLabel.style.right = this.contentPadding + \"px\"\n this.titleLabel.style.bottom = \"0px\"\n this.titleLabel.style.top = \"0px\"\n \n if (this.usesAutomaticTitleFontSize) {\n \n const hidden = this.titleLabel.hidden\n \n this.titleLabel.hidden = YES\n \n this.titleLabel.fontSize = 15\n \n this.titleLabel.fontSize = UITextView.automaticallyCalculatedFontSize(\n new UIRectangle(\n 0,\n 0,\n this.bounds.height,\n this.titleLabel.viewHTMLElement.offsetWidth\n ),\n this.titleLabel.intrinsicContentSize(),\n this.titleLabel.fontSize,\n this.minAutomaticFontSize,\n this.maxAutomaticFontSize\n )\n \n this.titleLabel.hidden = hidden\n \n }\n \n }\n \n this.applyClassesAndStyles()\n \n }\n \n override initViewStyleSelectors() {\n \n this.initStyleSelector(\".\" + this.styleClassName, \"background-color: lightblue;\")\n \n // var selectorWithoutImage = \".\" + this.styleClassName + \" .\" + this.imageView.styleClassName + \" + .\" +\n // this.titleLabel.styleClassName;\n \n // this.initStyleSelector(\n // selectorWithoutImage,\n // \"left: \" + this.contentPadding + \";\" +\n // \"right: \" + this.contentPadding + \";\" +\n // \"top: 50%;\" +\n // \"transform: translateY(-50%);\");\n \n }\n \n \n}\n\n"],
|
|
4
|
+
"sourcesContent": ["import { UIBaseButton } from \"./UIBaseButton\"\nimport { UIColor } from \"./UIColor\"\nimport { UIImageView } from \"./UIImageView\"\nimport { IS, IS_NOT, IS_NOT_NIL, nil, NO, ValueOf, YES } from \"./UIObject\"\nimport { UIRectangle } from \"./UIRectangle\"\nimport { UITextView } from \"./UITextView\"\n\n\nexport interface UIButtonColorSpecifier {\n \n titleLabel: UIButtonElementColorSpecifier;\n background: UIButtonElementColorSpecifier;\n \n}\n\n\nexport interface UIButtonElementColorSpecifier {\n \n normal: UIColor;\n hovered?: UIColor;\n highlighted: UIColor;\n focused?: UIColor;\n selected: UIColor;\n selectedAndHighlighted?: UIColor;\n \n}\n\n\nexport class UIButton extends UIBaseButton {\n \n _contentPadding = 0\n _titleLabel: UITextView = nil\n _imageView: UIImageView\n \n usesAutomaticTitleFontSize = NO\n minAutomaticFontSize?: number\n maxAutomaticFontSize?: number = 25\n \n colors: UIButtonColorSpecifier = {\n \n titleLabel: {\n \n normal: UIColor.whiteColor,\n highlighted: UIColor.whiteColor,\n selected: UIColor.whiteColor\n \n },\n \n background: {\n \n normal: UIColor.blueColor,\n highlighted: UIColor.greenColor,\n selected: UIColor.redColor\n \n }\n \n }\n \n \n constructor(\n elementID?: string,\n elementType?: string,\n titleType: string | ValueOf<typeof UITextView.type> = UITextView.type.span\n ) {\n \n super(elementID, elementType)\n \n // Instance variables\n \n this._imageView = new UIImageView(this.elementID + \"ImageView\")\n this._imageView.hidden = YES\n this.addSubview(this.imageView)\n \n this.imageView.fillMode = UIImageView.fillMode.aspectFitIfLarger\n \n \n if (IS_NOT_NIL(titleType)) {\n \n this._titleLabel = new UITextView(this.elementID + \"TitleLabel\", titleType)\n this.titleLabel!.style.whiteSpace = \"nowrap\"\n this.addSubview(this.titleLabel!)\n \n this.titleLabel!.userInteractionEnabled = NO\n \n }\n \n this.contentPadding = 10\n \n this.imageView.userInteractionEnabled = NO\n if (this.titleLabel) {\n this.titleLabel.textAlignment = UITextView.textAlignment.center\n this.titleLabel.nativeSelectionEnabled = NO\n }\n \n }\n \n \n get contentPadding() {\n return this._contentPadding.integerValue\n }\n \n set contentPadding(contentPadding) {\n this._contentPadding = contentPadding\n this.setNeedsLayout()\n }\n \n \n public override set hovered(hovered: boolean) {\n this._hovered = hovered\n this.updateContentForCurrentState()\n }\n \n public override get hovered(): boolean {\n return this._hovered ?? NO\n }\n \n public override set highlighted(highlighted: boolean) {\n this._highlighted = highlighted\n this.updateContentForCurrentState()\n }\n \n public override get highlighted(): boolean {\n return this._highlighted\n }\n \n public override set focused(focused: boolean) {\n this._focused = focused\n if (focused) {\n this.focus()\n }\n else {\n this.blur()\n }\n this.updateContentForCurrentState()\n }\n \n public override get focused(): boolean {\n return this._focused ?? NO\n }\n \n public override set selected(selected: boolean) {\n this._selected = selected\n this.updateContentForCurrentState()\n }\n \n public override get selected(): boolean {\n return this._selected\n }\n \n \n override updateContentForCurrentState() {\n \n let updateFunction: Function = this.updateContentForNormalState\n if (this.selected && this.highlighted) {\n updateFunction = this.updateContentForSelectedAndHighlightedState\n }\n else if (this.selected) {\n updateFunction = this.updateContentForSelectedState\n }\n else if (this.focused) {\n updateFunction = this.updateContentForFocusedState\n }\n else if (this.highlighted) {\n updateFunction = this.updateContentForHighlightedState\n }\n else if (this.hovered) {\n updateFunction = this.updateContentForHoveredState\n }\n \n if (!IS(updateFunction)) {\n if (this.titleLabel) {\n this.titleLabel.textColor = UIColor.nilColor\n }\n this.backgroundColor = UIColor.nilColor\n }\n else {\n updateFunction.call(this)\n }\n \n this.updateContentForCurrentEnabledState()\n \n }\n \n override updateContentForNormalState() {\n \n this.backgroundColor = this.colors.background.normal\n if (this.titleLabel) {\n this.titleLabel.textColor = this.colors.titleLabel.normal\n }\n \n }\n \n override updateContentForHoveredState() {\n \n this.updateContentForNormalState()\n \n if (this.colors.background.hovered) {\n this.backgroundColor = this.colors.background.hovered\n }\n \n if (this.colors.titleLabel.hovered && this.titleLabel) {\n this.titleLabel.textColor = this.colors.titleLabel.hovered\n }\n \n }\n \n override updateContentForFocusedState() {\n \n this.updateContentForHoveredState()\n \n if (this.colors.background.focused) {\n this.backgroundColor = this.colors.background.focused\n }\n \n if (this.colors.titleLabel.focused && this.titleLabel) {\n this.titleLabel.textColor = this.colors.titleLabel.focused\n }\n \n }\n \n override updateContentForHighlightedState() {\n \n this.backgroundColor = this.colors.background.highlighted\n if (this.titleLabel) {\n this.titleLabel.textColor = this.colors.titleLabel.highlighted\n }\n \n }\n \n override updateContentForSelectedState() {\n \n this.backgroundColor = this.colors.background.selected\n if (this.titleLabel) {\n this.titleLabel.textColor = this.colors.titleLabel.selected\n }\n \n }\n \n override updateContentForSelectedAndHighlightedState() {\n \n this.updateContentForSelectedState()\n \n if (this.colors.background.selectedAndHighlighted) {\n this.backgroundColor = this.colors.background.selectedAndHighlighted\n }\n \n if (this.colors.titleLabel.selectedAndHighlighted && this.titleLabel) {\n this.titleLabel.textColor = this.colors.titleLabel.selectedAndHighlighted\n }\n \n }\n \n \n override set enabled(enabled: boolean) {\n \n // @ts-ignore\n super.enabled = enabled\n \n this.updateContentForCurrentState()\n \n }\n \n override get enabled() {\n \n // @ts-ignore\n return super.enabled\n \n }\n \n override updateContentForCurrentEnabledState() {\n \n if (this.enabled) {\n this.alpha = 1\n }\n else {\n this.alpha = 0.5\n }\n \n this.userInteractionEnabled = this.enabled\n \n }\n \n \n override addStyleClass(styleClassName: string) {\n \n super.addStyleClass(styleClassName)\n \n if (this.styleClassName != styleClassName) {\n \n this.updateContentForCurrentState.call(this)\n \n }\n \n }\n \n \n get titleLabel(): UITextView {\n return this._titleLabel\n }\n \n get imageView() {\n \n return this._imageView\n \n }\n \n \n override layoutSubviews() {\n \n super.layoutSubviews()\n \n let bounds = this.bounds\n \n this.hoverText = this.hoverText ?? this.titleLabel?.text ?? \"\"\n \n // Image only if text is not present\n if (IS_NOT(this.imageView.hidden) && !IS(this.titleLabel?.text)) {\n \n this.imageView.frame = bounds\n \n }\n \n // Text only if image is not present\n if (IS(this.imageView.hidden) && this.titleLabel?.text) {\n \n this.titleLabel.style.left = this.contentPadding + \"px\"\n this.titleLabel.style.right = this.contentPadding + \"px\"\n // this.titleLabel.style.marginLeft = \"\"\n // this.titleLabel.style.right = this.contentPadding\n this.titleLabel.style.bottom = \"0px\"\n this.titleLabel.style.top = \"0px\"\n this.titleLabel.frame = new UIRectangle(nil, nil, nil, nil)\n \n if (this.usesAutomaticTitleFontSize) {\n \n const hidden = this.titleLabel.hidden\n \n this.titleLabel.hidden = YES\n \n this.titleLabel.fontSize = 15\n \n this.titleLabel.fontSize = UITextView.automaticallyCalculatedFontSize(\n new UIRectangle(\n 0,\n 0,\n this.bounds.height,\n this.titleLabel.viewHTMLElement.offsetWidth\n ),\n this.titleLabel.intrinsicContentSize(),\n this.titleLabel.fontSize,\n this.minAutomaticFontSize,\n this.maxAutomaticFontSize\n )\n \n this.titleLabel.hidden = hidden\n \n }\n \n \n }\n \n // Image and text both present\n if (IS_NOT(this.imageView.hidden) && this.titleLabel?.text) {\n \n //const imageShareOfWidth = 0.25\n \n bounds = bounds.rectangleWithInset(this.contentPadding)\n \n const imageFrame = bounds.copy()\n imageFrame.width = bounds.height - this.contentPadding * 0.5\n this.imageView.frame = imageFrame\n \n this.titleLabel.style.left = imageFrame.max.x + this.contentPadding + \"px\"\n this.titleLabel.style.right = this.contentPadding + \"px\"\n this.titleLabel.style.bottom = \"0px\"\n this.titleLabel.style.top = \"0px\"\n \n if (this.usesAutomaticTitleFontSize) {\n \n const hidden = this.titleLabel.hidden\n \n this.titleLabel.hidden = YES\n \n this.titleLabel.fontSize = 15\n \n this.titleLabel.fontSize = UITextView.automaticallyCalculatedFontSize(\n new UIRectangle(\n 0,\n 0,\n this.bounds.height,\n this.titleLabel.viewHTMLElement.offsetWidth\n ),\n this.titleLabel.intrinsicContentSize(),\n this.titleLabel.fontSize,\n this.minAutomaticFontSize,\n this.maxAutomaticFontSize\n )\n \n this.titleLabel.hidden = hidden\n \n }\n \n }\n \n this.applyClassesAndStyles()\n \n }\n \n override initViewStyleSelectors() {\n \n this.initStyleSelector(\".\" + this.styleClassName, \"background-color: lightblue;\")\n \n // var selectorWithoutImage = \".\" + this.styleClassName + \" .\" + this.imageView.styleClassName + \" + .\" +\n // this.titleLabel.styleClassName;\n \n // this.initStyleSelector(\n // selectorWithoutImage,\n // \"left: \" + this.contentPadding + \";\" +\n // \"right: \" + this.contentPadding + \";\" +\n // \"top: 50%;\" +\n // \"transform: translateY(-50%);\");\n \n }\n \n \n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA6B;AAC7B,qBAAwB;AACxB,yBAA4B;AAC5B,sBAA8D;AAC9D,yBAA4B;AAC5B,wBAA2B;AAuBpB,MAAM,iBAAiB,iCAAa;AAAA,EA+BvC,YACI,WACA,aACA,YAAsD,6BAAW,KAAK,MACxE;AAEE,UAAM,WAAW,WAAW;AAnChC,2BAAkB;AAClB,uBAA0B;AAG1B,sCAA6B;AAE7B,gCAAgC;AAEhC,kBAAiC;AAAA,MAE7B,YAAY;AAAA,QAER,QAAQ,uBAAQ;AAAA,QAChB,aAAa,uBAAQ;AAAA,QACrB,UAAU,uBAAQ;AAAA,MAEtB;AAAA,MAEA,YAAY;AAAA,QAER,QAAQ,uBAAQ;AAAA,QAChB,aAAa,uBAAQ;AAAA,QACrB,UAAU,uBAAQ;AAAA,MAEtB;AAAA,IAEJ;AAaI,SAAK,aAAa,IAAI,+BAAY,KAAK,YAAY,WAAW;AAC9D,SAAK,WAAW,SAAS;AACzB,SAAK,WAAW,KAAK,SAAS;AAE9B,SAAK,UAAU,WAAW,+BAAY,SAAS;AAG/C,YAAI,4BAAW,SAAS,GAAG;AAEvB,WAAK,cAAc,IAAI,6BAAW,KAAK,YAAY,cAAc,SAAS;AAC1E,WAAK,WAAY,MAAM,aAAa;AACpC,WAAK,WAAW,KAAK,UAAW;AAEhC,WAAK,WAAY,yBAAyB;AAAA,IAE9C;AAEA,SAAK,iBAAiB;AAEtB,S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B,KAAK;AAAA,UACL,KAAK;AAAA,QACT;AAEA,aAAK,WAAW,SAAS;AAAA,MAE7B;AAAA,IAEJ;AAEA,SAAK,sBAAsB;AAAA,EAE/B;AAAA,EAES,yBAAyB;AAE9B,SAAK,kBAAkB,MAAM,KAAK,gBAAgB,8BAA8B;AAAA,EAYpF;AAGJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UILayoutCycleTracer
|
|
3
|
+
*
|
|
4
|
+
* A development-only utility that detects and reports layout cycles in the
|
|
5
|
+
* UIView layout system.
|
|
6
|
+
*
|
|
7
|
+
* A layout cycle occurs when layouting a view causes another setNeedsLayout()
|
|
8
|
+
* call on the same view (or an ancestor) within the same layout pass, causing
|
|
9
|
+
* the loop in layoutViewsIfNeeded() to iterate multiple times.
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* UILayoutCycleTracer.enable() — start tracing
|
|
13
|
+
* UILayoutCycleTracer.disable() — stop tracing
|
|
14
|
+
* UILayoutCycleTracer.isEnabled — check current state
|
|
15
|
+
*
|
|
16
|
+
* When a cycle is detected, a detailed report is printed to the console
|
|
17
|
+
* including:
|
|
18
|
+
* - Which view was re-queued
|
|
19
|
+
* - Its full superview chain
|
|
20
|
+
* - The call stack at the point of the re-queue (setNeedsLayout call)
|
|
21
|
+
* - How many times the view has been laid out in this pass
|
|
22
|
+
*
|
|
23
|
+
* Integration:
|
|
24
|
+
* Call UILayoutCycleTracer.willBeginLayoutPass() at the start of
|
|
25
|
+
* layoutViewsIfNeeded(), UILayoutCycleTracer.didLayoutView(view) after each
|
|
26
|
+
* view is laid out, and UILayoutCycleTracer.viewDidCallSetNeedsLayout(view)
|
|
27
|
+
* from setNeedsLayout() while a pass is active.
|
|
28
|
+
*/
|
|
29
|
+
export declare class UILayoutCycleTracer {
|
|
30
|
+
static _isEnabled: boolean;
|
|
31
|
+
static _isPassActive: boolean;
|
|
32
|
+
static _layoutCountsThisPass: Map<any, number>;
|
|
33
|
+
static _setNeedsLayoutCallsThisPass: Map<any, {
|
|
34
|
+
count: number;
|
|
35
|
+
stacks: string[];
|
|
36
|
+
}>;
|
|
37
|
+
static _currentIteration: number;
|
|
38
|
+
static _totalReportsThisPass: number;
|
|
39
|
+
static reportThreshold: number;
|
|
40
|
+
static maxReportsPerPass: number;
|
|
41
|
+
static _noiseFramePrefixes: string[];
|
|
42
|
+
static get isEnabled(): boolean;
|
|
43
|
+
static enable(reportThreshold?: number): void;
|
|
44
|
+
static disable(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Called at the very start of each layoutViewsIfNeeded() invocation.
|
|
47
|
+
*/
|
|
48
|
+
static willBeginLayoutPass(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Called after each iteration increment in the layoutViewsIfNeeded() while loop.
|
|
51
|
+
*/
|
|
52
|
+
static willBeginIteration(iteration: number): void;
|
|
53
|
+
/**
|
|
54
|
+
* Called after a view's layoutIfNeeded() completes.
|
|
55
|
+
*/
|
|
56
|
+
static didLayoutView(view: any): void;
|
|
57
|
+
/**
|
|
58
|
+
* Called from setNeedsLayout() when a view enters the queue.
|
|
59
|
+
* If a layout pass is currently active, this is a potential cycle.
|
|
60
|
+
*/
|
|
61
|
+
static viewDidCallSetNeedsLayout(view: any): void;
|
|
62
|
+
/**
|
|
63
|
+
* Called at the end of a layout pass.
|
|
64
|
+
*/
|
|
65
|
+
static didFinishLayoutPass(iterationCount: number): void;
|
|
66
|
+
/**
|
|
67
|
+
* Strips the "Error" header line and any leading framework/tracer noise
|
|
68
|
+
* frames from a raw Error.stack string, so the first frame shown is always
|
|
69
|
+
* the application code that triggered the re-queue.
|
|
70
|
+
*/
|
|
71
|
+
static _cleanStack(rawStack: string): string;
|
|
72
|
+
static _viewIdentifier(view: any): string;
|
|
73
|
+
static _superviewChain(view: any): string;
|
|
74
|
+
static _reportCycle(view: any, layoutCountThisPass: number, cleanStack: string): void;
|
|
75
|
+
}
|
|
76
|
+
declare global {
|
|
77
|
+
interface Window {
|
|
78
|
+
UILayoutCycleTracer?: typeof UILayoutCycleTracer;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var UILayoutCycleTracer_exports = {};
|
|
20
|
+
__export(UILayoutCycleTracer_exports, {
|
|
21
|
+
UILayoutCycleTracer: () => UILayoutCycleTracer
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(UILayoutCycleTracer_exports);
|
|
24
|
+
const _UILayoutCycleTracer = class {
|
|
25
|
+
static get isEnabled() {
|
|
26
|
+
return _UILayoutCycleTracer._isEnabled;
|
|
27
|
+
}
|
|
28
|
+
static enable(reportThreshold = 1) {
|
|
29
|
+
;
|
|
30
|
+
Error.stackTraceLimit = 100;
|
|
31
|
+
_UILayoutCycleTracer.reportThreshold = reportThreshold;
|
|
32
|
+
_UILayoutCycleTracer._isEnabled = true;
|
|
33
|
+
console.log(
|
|
34
|
+
`%c[UILayoutCycleTracer] Layout cycle tracing ENABLED (threshold=${reportThreshold}, Error.stackTraceLimit=100)`,
|
|
35
|
+
"color: #4CAF50; font-weight: bold"
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
static disable() {
|
|
39
|
+
;
|
|
40
|
+
Error.stackTraceLimit = 10;
|
|
41
|
+
_UILayoutCycleTracer._isEnabled = false;
|
|
42
|
+
console.log(
|
|
43
|
+
"%c[UILayoutCycleTracer] Layout cycle tracing DISABLED",
|
|
44
|
+
"color: #9E9E9E; font-weight: bold"
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
static willBeginLayoutPass() {
|
|
48
|
+
if (!_UILayoutCycleTracer._isEnabled) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
_UILayoutCycleTracer._isPassActive = true;
|
|
52
|
+
_UILayoutCycleTracer._layoutCountsThisPass = /* @__PURE__ */ new Map();
|
|
53
|
+
_UILayoutCycleTracer._setNeedsLayoutCallsThisPass = /* @__PURE__ */ new Map();
|
|
54
|
+
_UILayoutCycleTracer._currentIteration = 0;
|
|
55
|
+
_UILayoutCycleTracer._totalReportsThisPass = 0;
|
|
56
|
+
}
|
|
57
|
+
static willBeginIteration(iteration) {
|
|
58
|
+
if (!_UILayoutCycleTracer._isEnabled) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
_UILayoutCycleTracer._currentIteration = iteration;
|
|
62
|
+
if (iteration > 0 && _UILayoutCycleTracer._totalReportsThisPass > 0) {
|
|
63
|
+
console.warn(
|
|
64
|
+
`%c[UILayoutCycleTracer] Layout pass iteration ${iteration + 1} \u2014 views were re-queued during the previous iteration`,
|
|
65
|
+
"color: #FF9800; font-weight: bold"
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
static didLayoutView(view) {
|
|
70
|
+
var _a;
|
|
71
|
+
if (!_UILayoutCycleTracer._isEnabled || !_UILayoutCycleTracer._isPassActive) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const previous = (_a = _UILayoutCycleTracer._layoutCountsThisPass.get(view)) != null ? _a : 0;
|
|
75
|
+
_UILayoutCycleTracer._layoutCountsThisPass.set(view, previous + 1);
|
|
76
|
+
}
|
|
77
|
+
static viewDidCallSetNeedsLayout(view) {
|
|
78
|
+
var _a, _b;
|
|
79
|
+
if (!_UILayoutCycleTracer._isEnabled || !_UILayoutCycleTracer._isPassActive) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const layoutCount = (_a = _UILayoutCycleTracer._layoutCountsThisPass.get(view)) != null ? _a : 0;
|
|
83
|
+
if (layoutCount < _UILayoutCycleTracer.reportThreshold) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (_UILayoutCycleTracer._totalReportsThisPass >= _UILayoutCycleTracer.maxReportsPerPass) {
|
|
87
|
+
if (_UILayoutCycleTracer._totalReportsThisPass === _UILayoutCycleTracer.maxReportsPerPass) {
|
|
88
|
+
console.warn(
|
|
89
|
+
`%c[UILayoutCycleTracer] Maximum reports per pass (${_UILayoutCycleTracer.maxReportsPerPass}) reached. Further reports suppressed.`,
|
|
90
|
+
"color: #F44336"
|
|
91
|
+
);
|
|
92
|
+
_UILayoutCycleTracer._totalReportsThisPass++;
|
|
93
|
+
}
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
_UILayoutCycleTracer._totalReportsThisPass++;
|
|
97
|
+
const rawStack = (_b = new Error().stack) != null ? _b : "(stack unavailable)";
|
|
98
|
+
const cleanStack = _UILayoutCycleTracer._cleanStack(rawStack);
|
|
99
|
+
const existing = _UILayoutCycleTracer._setNeedsLayoutCallsThisPass.get(view);
|
|
100
|
+
if (existing) {
|
|
101
|
+
existing.count++;
|
|
102
|
+
existing.stacks.push(cleanStack);
|
|
103
|
+
} else {
|
|
104
|
+
_UILayoutCycleTracer._setNeedsLayoutCallsThisPass.set(view, { count: 1, stacks: [cleanStack] });
|
|
105
|
+
}
|
|
106
|
+
_UILayoutCycleTracer._reportCycle(view, layoutCount, cleanStack);
|
|
107
|
+
}
|
|
108
|
+
static didFinishLayoutPass(iterationCount) {
|
|
109
|
+
if (!_UILayoutCycleTracer._isEnabled) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
_UILayoutCycleTracer._isPassActive = false;
|
|
113
|
+
if (iterationCount > 1 && _UILayoutCycleTracer._totalReportsThisPass > 0) {
|
|
114
|
+
console.warn(
|
|
115
|
+
`%c[UILayoutCycleTracer] Layout pass completed in ${iterationCount} iteration(s). ${_UILayoutCycleTracer._totalReportsThisPass} cycle event(s) recorded.`,
|
|
116
|
+
"color: #FF9800"
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
static _cleanStack(rawStack) {
|
|
121
|
+
const lines = rawStack.split("\n");
|
|
122
|
+
let firstAppFrameIndex = 1;
|
|
123
|
+
for (let i = 1; i < lines.length; i++) {
|
|
124
|
+
const trimmed = lines[i].trim();
|
|
125
|
+
const isNoise = _UILayoutCycleTracer._noiseFramePrefixes.some(
|
|
126
|
+
(prefix) => trimmed.includes(prefix)
|
|
127
|
+
);
|
|
128
|
+
if (!isNoise) {
|
|
129
|
+
firstAppFrameIndex = i;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return lines.slice(firstAppFrameIndex).join("\n");
|
|
134
|
+
}
|
|
135
|
+
static _viewIdentifier(view) {
|
|
136
|
+
var _a, _b, _c, _d;
|
|
137
|
+
const className = (_b = (_a = view == null ? void 0 : view.constructor) == null ? void 0 : _a.name) != null ? _b : "UnknownView";
|
|
138
|
+
const elementID = (_d = (_c = view == null ? void 0 : view.elementID) != null ? _c : view == null ? void 0 : view._UIViewIndex) != null ? _d : "?";
|
|
139
|
+
return `${className}#${elementID}`;
|
|
140
|
+
}
|
|
141
|
+
static _superviewChain(view) {
|
|
142
|
+
const parts = [];
|
|
143
|
+
let current = view;
|
|
144
|
+
let depth = 0;
|
|
145
|
+
while (current && depth < 20) {
|
|
146
|
+
parts.push(_UILayoutCycleTracer._viewIdentifier(current));
|
|
147
|
+
current = current.superview;
|
|
148
|
+
depth++;
|
|
149
|
+
}
|
|
150
|
+
return parts.join(" \u2192 ");
|
|
151
|
+
}
|
|
152
|
+
static _reportCycle(view, layoutCountThisPass, cleanStack) {
|
|
153
|
+
const identifier = _UILayoutCycleTracer._viewIdentifier(view);
|
|
154
|
+
const chain = _UILayoutCycleTracer._superviewChain(view);
|
|
155
|
+
console.groupCollapsed(
|
|
156
|
+
`%c[UILayoutCycleTracer] \u26A0\uFE0F Layout cycle: ${identifier} re-queued after being laid out ${layoutCountThisPass}x in iteration ${_UILayoutCycleTracer._currentIteration + 1}`,
|
|
157
|
+
"color: #F44336; font-weight: bold"
|
|
158
|
+
);
|
|
159
|
+
console.log("%cView:", "font-weight: bold", view);
|
|
160
|
+
console.log("%cSuperview chain:", "font-weight: bold", chain);
|
|
161
|
+
console.log("%cLayout count this pass:", "font-weight: bold", layoutCountThisPass);
|
|
162
|
+
console.log("%cIteration:", "font-weight: bold", _UILayoutCycleTracer._currentIteration + 1);
|
|
163
|
+
console.log("%cCall stack (noise frames stripped):", "font-weight: bold");
|
|
164
|
+
cleanStack.split("\n").forEach((frame) => console.log(" " + frame.trim()));
|
|
165
|
+
console.groupEnd();
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
let UILayoutCycleTracer = _UILayoutCycleTracer;
|
|
169
|
+
UILayoutCycleTracer._isEnabled = false;
|
|
170
|
+
UILayoutCycleTracer._isPassActive = false;
|
|
171
|
+
UILayoutCycleTracer._layoutCountsThisPass = /* @__PURE__ */ new Map();
|
|
172
|
+
UILayoutCycleTracer._setNeedsLayoutCallsThisPass = /* @__PURE__ */ new Map();
|
|
173
|
+
UILayoutCycleTracer._currentIteration = 0;
|
|
174
|
+
UILayoutCycleTracer._totalReportsThisPass = 0;
|
|
175
|
+
UILayoutCycleTracer.reportThreshold = 1;
|
|
176
|
+
UILayoutCycleTracer.maxReportsPerPass = 10;
|
|
177
|
+
UILayoutCycleTracer._noiseFramePrefixes = [
|
|
178
|
+
"UILayoutCycleTracer",
|
|
179
|
+
"UIView.setNeedsLayout",
|
|
180
|
+
"setNeedsLayout",
|
|
181
|
+
"UIView.didLayoutSubviews",
|
|
182
|
+
"didLayoutSubviews",
|
|
183
|
+
"UIView.layoutSubviews",
|
|
184
|
+
"UIView.layoutIfNeeded",
|
|
185
|
+
"layoutIfNeeded",
|
|
186
|
+
"UIView.layoutViewsIfNeeded",
|
|
187
|
+
"layoutViewsIfNeeded"
|
|
188
|
+
];
|
|
189
|
+
window.UILayoutCycleTracer = UILayoutCycleTracer;
|
|
190
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
191
|
+
0 && (module.exports = {
|
|
192
|
+
UILayoutCycleTracer
|
|
193
|
+
});
|
|
194
|
+
//# sourceMappingURL=UILayoutCycleTracer.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../scripts/UILayoutCycleTracer.ts"],
|
|
4
|
+
"sourcesContent": ["/// #if DEV\n\n/**\n * UILayoutCycleTracer\n *\n * A development-only utility that detects and reports layout cycles in the\n * UIView layout system.\n *\n * A layout cycle occurs when layouting a view causes another setNeedsLayout()\n * call on the same view (or an ancestor) within the same layout pass, causing\n * the loop in layoutViewsIfNeeded() to iterate multiple times.\n *\n * Usage:\n * UILayoutCycleTracer.enable() \u2014 start tracing\n * UILayoutCycleTracer.disable() \u2014 stop tracing\n * UILayoutCycleTracer.isEnabled \u2014 check current state\n *\n * When a cycle is detected, a detailed report is printed to the console\n * including:\n * - Which view was re-queued\n * - Its full superview chain\n * - The call stack at the point of the re-queue (setNeedsLayout call)\n * - How many times the view has been laid out in this pass\n *\n * Integration:\n * Call UILayoutCycleTracer.willBeginLayoutPass() at the start of\n * layoutViewsIfNeeded(), UILayoutCycleTracer.didLayoutView(view) after each\n * view is laid out, and UILayoutCycleTracer.viewDidCallSetNeedsLayout(view)\n * from setNeedsLayout() while a pass is active.\n */\nexport class UILayoutCycleTracer {\n \n static _isEnabled: boolean = false\n static _isPassActive: boolean = false\n static _layoutCountsThisPass: Map<any, number> = new Map()\n static _setNeedsLayoutCallsThisPass: Map<any, { count: number; stacks: string[] }> = new Map()\n static _currentIteration: number = 0\n static _totalReportsThisPass: number = 0\n \n // How many times a view must be re-queued before reporting.\n // 1 means: report the first time a view is re-queued after being laid out.\n static reportThreshold: number = 1\n \n // Maximum number of cycle reports per layout pass to avoid console flooding.\n static maxReportsPerPass: number = 10\n \n // Prefixes of stack frames that belong to the tracer or framework internals\n // and should be stripped from the top of the captured stack so that the\n // first visible frame is always application code.\n static _noiseFramePrefixes: string[] = [\n \"UILayoutCycleTracer\",\n \"UIView.setNeedsLayout\",\n \"setNeedsLayout\",\n \"UIView.didLayoutSubviews\",\n \"didLayoutSubviews\",\n \"UIView.layoutSubviews\",\n \"UIView.layoutIfNeeded\",\n \"layoutIfNeeded\",\n \"UIView.layoutViewsIfNeeded\",\n \"layoutViewsIfNeeded\",\n ]\n \n static get isEnabled(): boolean {\n return UILayoutCycleTracer._isEnabled\n }\n \n \n static enable(reportThreshold: number = 1) {\n // Maximise the V8 stack trace depth so long chains are fully visible.\n // The default is 10 which truncates most interesting call stacks.\n ;(Error as any).stackTraceLimit = 100\n UILayoutCycleTracer.reportThreshold = reportThreshold\n UILayoutCycleTracer._isEnabled = true\n console.log(\n `%c[UILayoutCycleTracer] Layout cycle tracing ENABLED (threshold=${reportThreshold}, Error.stackTraceLimit=100)`,\n \"color: #4CAF50; font-weight: bold\"\n )\n }\n \n static disable() {\n ;(Error as any).stackTraceLimit = 10\n UILayoutCycleTracer._isEnabled = false\n console.log(\n \"%c[UILayoutCycleTracer] Layout cycle tracing DISABLED\",\n \"color: #9E9E9E; font-weight: bold\"\n )\n }\n \n /**\n * Called at the very start of each layoutViewsIfNeeded() invocation.\n */\n static willBeginLayoutPass() {\n if (!UILayoutCycleTracer._isEnabled) { return }\n UILayoutCycleTracer._isPassActive = true\n UILayoutCycleTracer._layoutCountsThisPass = new Map()\n UILayoutCycleTracer._setNeedsLayoutCallsThisPass = new Map()\n UILayoutCycleTracer._currentIteration = 0\n UILayoutCycleTracer._totalReportsThisPass = 0\n }\n \n /**\n * Called after each iteration increment in the layoutViewsIfNeeded() while loop.\n */\n static willBeginIteration(iteration: number) {\n if (!UILayoutCycleTracer._isEnabled) { return }\n UILayoutCycleTracer._currentIteration = iteration\n if (iteration > 0 && UILayoutCycleTracer._totalReportsThisPass > 0) {\n console.warn(\n `%c[UILayoutCycleTracer] Layout pass iteration ${iteration + 1} \u2014 views were re-queued during the previous iteration`,\n \"color: #FF9800; font-weight: bold\"\n )\n }\n }\n \n /**\n * Called after a view's layoutIfNeeded() completes.\n */\n static didLayoutView(view: any) {\n if (!UILayoutCycleTracer._isEnabled || !UILayoutCycleTracer._isPassActive) { return }\n const previous = UILayoutCycleTracer._layoutCountsThisPass.get(view) ?? 0\n UILayoutCycleTracer._layoutCountsThisPass.set(view, previous + 1)\n }\n \n /**\n * Called from setNeedsLayout() when a view enters the queue.\n * If a layout pass is currently active, this is a potential cycle.\n */\n static viewDidCallSetNeedsLayout(view: any) {\n if (!UILayoutCycleTracer._isEnabled || !UILayoutCycleTracer._isPassActive) { return }\n \n // Only report if this view has already been laid out at least once this pass.\n const layoutCount = UILayoutCycleTracer._layoutCountsThisPass.get(view) ?? 0\n if (layoutCount < UILayoutCycleTracer.reportThreshold) { return }\n \n if (UILayoutCycleTracer._totalReportsThisPass >= UILayoutCycleTracer.maxReportsPerPass) {\n if (UILayoutCycleTracer._totalReportsThisPass === UILayoutCycleTracer.maxReportsPerPass) {\n console.warn(\n `%c[UILayoutCycleTracer] Maximum reports per pass (${UILayoutCycleTracer.maxReportsPerPass}) reached. Further reports suppressed.`,\n \"color: #F44336\"\n )\n UILayoutCycleTracer._totalReportsThisPass++\n }\n return\n }\n \n UILayoutCycleTracer._totalReportsThisPass++\n \n const rawStack = new Error().stack ?? \"(stack unavailable)\"\n const cleanStack = UILayoutCycleTracer._cleanStack(rawStack)\n \n const existing = UILayoutCycleTracer._setNeedsLayoutCallsThisPass.get(view)\n if (existing) {\n existing.count++\n existing.stacks.push(cleanStack)\n }\n else {\n UILayoutCycleTracer._setNeedsLayoutCallsThisPass.set(view, { count: 1, stacks: [cleanStack] })\n }\n \n UILayoutCycleTracer._reportCycle(view, layoutCount, cleanStack)\n }\n \n /**\n * Called at the end of a layout pass.\n */\n static didFinishLayoutPass(iterationCount: number) {\n if (!UILayoutCycleTracer._isEnabled) { return }\n UILayoutCycleTracer._isPassActive = false\n \n if (iterationCount > 1 && UILayoutCycleTracer._totalReportsThisPass > 0) {\n console.warn(\n `%c[UILayoutCycleTracer] Layout pass completed in ${iterationCount} iteration(s). ` +\n `${UILayoutCycleTracer._totalReportsThisPass} cycle event(s) recorded.`,\n \"color: #FF9800\"\n )\n }\n }\n \n /**\n * Strips the \"Error\" header line and any leading framework/tracer noise\n * frames from a raw Error.stack string, so the first frame shown is always\n * the application code that triggered the re-queue.\n */\n static _cleanStack(rawStack: string): string {\n const lines = rawStack.split(\"\\n\")\n \n // Find the first line that is NOT the \"Error\" header and NOT a noise frame.\n let firstAppFrameIndex = 1 // skip \"Error\" on line 0\n for (let i = 1; i < lines.length; i++) {\n const trimmed = lines[i].trim()\n const isNoise = UILayoutCycleTracer._noiseFramePrefixes.some(prefix =>\n trimmed.includes(prefix)\n )\n if (!isNoise) {\n firstAppFrameIndex = i\n break\n }\n }\n \n return lines.slice(firstAppFrameIndex).join(\"\\n\")\n }\n \n static _viewIdentifier(view: any): string {\n const className = view?.constructor?.name ?? \"UnknownView\"\n const elementID = view?.elementID ?? view?._UIViewIndex ?? \"?\"\n return `${className}#${elementID}`\n }\n \n static _superviewChain(view: any): string {\n const parts: string[] = []\n let current = view\n let depth = 0\n while (current && depth < 20) {\n parts.push(UILayoutCycleTracer._viewIdentifier(current))\n current = current.superview\n depth++\n }\n return parts.join(\" \u2192 \")\n }\n \n static _reportCycle(view: any, layoutCountThisPass: number, cleanStack: string) {\n const identifier = UILayoutCycleTracer._viewIdentifier(view)\n const chain = UILayoutCycleTracer._superviewChain(view)\n \n console.groupCollapsed(\n `%c[UILayoutCycleTracer] \u26A0\uFE0F Layout cycle: ${identifier} re-queued after being laid out ${layoutCountThisPass}x in iteration ${UILayoutCycleTracer._currentIteration + 1}`,\n \"color: #F44336; font-weight: bold\"\n )\n console.log(\"%cView:\", \"font-weight: bold\", view)\n console.log(\"%cSuperview chain:\", \"font-weight: bold\", chain)\n console.log(\"%cLayout count this pass:\", \"font-weight: bold\", layoutCountThisPass)\n console.log(\"%cIteration:\", \"font-weight: bold\", UILayoutCycleTracer._currentIteration + 1)\n console.log(\"%cCall stack (noise frames stripped):\", \"font-weight: bold\")\n cleanStack.split(\"\\n\").forEach(frame => console.log(\" \" + frame.trim()))\n console.groupEnd()\n }\n \n}\n\nwindow.UILayoutCycleTracer = UILayoutCycleTracer\n\ndeclare global {\n interface Window {\n UILayoutCycleTracer?: typeof UILayoutCycleTracer\n }\n}\n\n/// #endif\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA8BO,MAAM,uBAAN,MAA0B;AAAA,EAgC7B,WAAW,YAAqB;AAC5B,WAAO,qBAAoB;AAAA,EAC/B;AAAA,EAGA,OAAO,OAAO,kBAA0B,GAAG;AAGvC;AAAC,IAAC,MAAc,kBAAkB;AAClC,yBAAoB,kBAAkB;AACtC,yBAAoB,aAAa;AACjC,YAAQ;AAAA,MACJ,mEAAmE;AAAA,MACnE;AAAA,IACJ;AAAA,EACJ;AAAA,EAEA,OAAO,UAAU;AACb;AAAC,IAAC,MAAc,kBAAkB;AAClC,yBAAoB,aAAa;AACjC,YAAQ;AAAA,MACJ;AAAA,MACA;AAAA,IACJ;AAAA,EACJ;AAAA,EAKA,OAAO,sBAAs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AAI;AAC1B,YAAM,KAAK,qBAAoB,gBAAgB,OAAO,CAAC;AACvD,gBAAU,QAAQ;AAClB;AAAA,IACJ;AACA,WAAO,MAAM,KAAK,UAAK;AAAA,EAC3B;AAAA,EAEA,OAAO,aAAa,MAAW,qBAA6B,YAAoB;AAC5E,UAAM,aAAa,qBAAoB,gBAAgB,IAAI;AAC3D,UAAM,QAAQ,qBAAoB,gBAAgB,IAAI;AAEtD,YAAQ;AAAA,MACJ,sDAA4C,6CAA6C,qCAAqC,qBAAoB,oBAAoB;AAAA,MACtK;AAAA,IACJ;AACA,YAAQ,IAAI,WAAW,qBAAqB,IAAI;AAChD,YAAQ,IAAI,sBAAsB,qBAAqB,KAAK;AAC5D,YAAQ,IAAI,6BAA6B,qBAAqB,mBAAmB;AACjF,YAAQ,IAAI,gBAAgB,qBAAqB,qBAAoB,oBAAoB,CAAC;AAC1F,YAAQ,IAAI,yCAAyC,mBAAmB;AACxE,eAAW,MAAM,IAAI,EAAE,QAAQ,WAAS,QAAQ,IAAI,OAAO,MAAM,KAAK,CAAC,CAAC;AACxE,YAAQ,SAAS;AAAA,EACrB;AAEJ;AA/MO,IAAM,sBAAN;AAAM,oBAEF,aAAsB;AAFpB,oBAGF,gBAAyB;AAHvB,oBAIF,wBAA0C,oBAAI,IAAI;AAJhD,oBAKF,+BAA8E,oBAAI,IAAI;AALpF,oBAMF,oBAA4B;AAN1B,oBAOF,wBAAgC;AAP9B,oBAWF,kBAA0B;AAXxB,oBAcF,oBAA4B;AAd1B,oBAmBF,sBAAgC;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;AAmLJ,OAAO,sBAAsB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -269,22 +269,20 @@ const _UITextView = class extends import_UIView.UIView {
|
|
|
269
269
|
notificationText = '<span style="color: ' + _UITextView.notificationTextColor.stringValue + ';">' + (" (" + this.notificationAmount + ")").bold() + "</span>";
|
|
270
270
|
}
|
|
271
271
|
const displayText = this.thousandsSeparator !== null ? _UITextView.applyThousandsSeparatorToNumericalString(text, this.thousandsSeparator) : text;
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
this.
|
|
280
|
-
this.
|
|
272
|
+
const newInnerHTML = this.textPrefix + (0, import_UIObject.FIRST)(displayText, "") + this.textSuffix + notificationText;
|
|
273
|
+
if (this.textElementView.viewHTMLElement.innerHTML !== newInnerHTML) {
|
|
274
|
+
this.textElementView.viewHTMLElement.innerHTML = newInnerHTML;
|
|
275
|
+
if (this.changesOften) {
|
|
276
|
+
this._intrinsicHeightCache = new import_UIObject.UIObject();
|
|
277
|
+
this._intrinsicWidthCache = new import_UIObject.UIObject();
|
|
278
|
+
}
|
|
279
|
+
this._useFastMeasurement = void 0;
|
|
280
|
+
this._intrinsicSizesCache = {};
|
|
281
|
+
this.invalidateMeasurementStrategy();
|
|
282
|
+
this._invalidateMeasurementStyles();
|
|
283
|
+
this.clearIntrinsicSizeCache();
|
|
284
|
+
this.setNeedsLayout();
|
|
281
285
|
}
|
|
282
|
-
this._useFastMeasurement = void 0;
|
|
283
|
-
this._intrinsicSizesCache = {};
|
|
284
|
-
this.invalidateMeasurementStrategy();
|
|
285
|
-
this._invalidateMeasurementStyles();
|
|
286
|
-
this.clearIntrinsicSizeCache();
|
|
287
|
-
this.setNeedsLayout();
|
|
288
286
|
}
|
|
289
287
|
static applyThousandsSeparatorToNumericalString(value, separator) {
|
|
290
288
|
const trimmed = (value || "").trim();
|