chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 13:13:17 +08:00
commit 58ab8315aa
8961 changed files with 5602567 additions and 0 deletions
@@ -0,0 +1,44 @@
using T3.Core.Utils;
namespace Lib.@string.transform;
[Guid("acdd78b1-4e66-4fd0-a36b-5318670fefd4")]
internal sealed class ChangeCase : Instance<ChangeCase>
{
[Output(Guid = "ecf66a1e-45e5-4e0c-ac9e-a784a9339153")]
public readonly Slot<string> Result = new();
public ChangeCase()
{
Result.UpdateAction += Update;
}
private void Update(EvaluationContext context)
{
var str = InputText.GetValue(context);
var mode = Mode.GetEnumValue<Modes>(context);
switch (mode)
{
case Modes.ToUpperCase:
Result.Value = str?.ToUpperInvariant();
break;
case Modes.ToLowerCase:
Result.Value = str?.ToLowerInvariant();
break;
}
}
[Input(Guid = "041C98B6-4450-46D7-9DAE-C9030C88B9E6")]
public readonly InputSlot<string> InputText = new();
[Input(Guid = "8BD38031-DE22-40A8-9B6D-A241B2FCD7F2", MappedType = typeof(Modes))]
public readonly InputSlot<int> Mode = new ();
private enum Modes
{
ToUpperCase,
ToLowerCase,
}
}
@@ -0,0 +1,16 @@
{
"FormatVersion": 3,
"Id": "acdd78b1-4e66-4fd0-a36b-5318670fefd4"/*ChangeCase*/,
"Inputs": [
{
"Id": "041c98b6-4450-46d7-9dae-c9030c88b9e6"/*InputText*/,
"DefaultValue": ""
},
{
"Id": "8bd38031-de22-40a8-9b6d-a241b2fcd7f2"/*Mode*/,
"DefaultValue": 0
}
],
"Children": [],
"Connections": []
}
@@ -0,0 +1,33 @@
{
"FormatVersion": 3,
"Id": "acdd78b1-4e66-4fd0-a36b-5318670fefd4"/*ChangeCase*/,
"Description": "Changes a case of string to upper or lower case.",
"SymbolTags": "1",
"InputUis": [
{
"InputId": "041c98b6-4450-46d7-9dae-c9030c88b9e6"/*InputText*/,
"Position": {
"X": 0.0,
"Y": 45.0
},
"Usage": "Default"
},
{
"InputId": "8bd38031-de22-40a8-9b6d-a241b2fcd7f2"/*Mode*/,
"Position": {
"X": 0.0,
"Y": 90.0
}
}
],
"SymbolChildUis": [],
"OutputUis": [
{
"OutputId": "ecf66a1e-45e5-4e0c-ac9e-a784a9339153"/*Result*/,
"Position": {
"X": 0.0,
"Y": 0.0
}
}
]
}
@@ -0,0 +1,155 @@
using T3.Core.Utils;
namespace Lib.@string.transform;
[Guid("96ccea19-c37f-4ee4-8dd2-5abdb347f5a1")]
internal sealed class WrapString : Instance<WrapString>
{
[Output(Guid = "83571519-ade1-4508-bf4c-c3d734cf5603")]
public readonly Slot<string> Result = new();
public WrapString()
{
Result.UpdateAction += Update;
}
private void Update(EvaluationContext context)
{
var str = InputText.GetValue(context);
var mode = Mode.GetEnumValue<WrapLinesModes>(context);
var wrapColumn = WrapColumn.GetValue(context).Clamp(1,10000);
_stringBuilder.Clear();
_stringBuilder.Append(str);
InsertLineWraps(mode, _stringBuilder, 0, 0, wrapColumn);
Result.Value = _stringBuilder.ToString();
}
private static void InsertLineWraps(WrapLinesModes lineWrap, StringBuilder stringBuilder, int insertPos, int insertLength, int wrapColumn)
{
if (lineWrap == WrapLinesModes.WrapAtCharacters)
{
Log.Warning("WrapAtCharacters has been deprecated. Use WrapToFillBlock instead.");
}
else if (lineWrap == WrapLinesModes.WrapAtWords)
{
int pos = 0;
int currentLineLength = 0;
int lastValidBreakPos = -1;
while (pos < stringBuilder.Length)
{
var c = stringBuilder[pos];
if (c == '\n')
{
currentLineLength = 0;
lastValidBreakPos = -1;
}
else if (c == ' ' || c == '.' || c == ',' || c == '/')
{
lastValidBreakPos = pos;
currentLineLength++;
}
else
{
currentLineLength++;
}
if (currentLineLength > wrapColumn && lastValidBreakPos != -1)
{
stringBuilder[lastValidBreakPos] = '\n';
pos = lastValidBreakPos;
lastValidBreakPos = -1;
currentLineLength = 0;
}
pos++;
}
}
else if (lineWrap == WrapLinesModes.WrapToFillBlock)
{
int pos = 0;
int currentLineLength = 0;
int lastValidBreakPos = -1;
while (pos < stringBuilder.Length)
{
var c = stringBuilder[pos];
if (c == '\n')
{
stringBuilder[pos] = ' ';
//currentLineLength = 0;
lastValidBreakPos = pos;
currentLineLength++;
}
else if (c == ' ' || c == '.' || c == ',' || c == '/')
{
lastValidBreakPos = pos;
currentLineLength++;
}
else
{
currentLineLength++;
}
if (currentLineLength > wrapColumn && lastValidBreakPos != -1)
{
stringBuilder[lastValidBreakPos] = '\n';
pos = lastValidBreakPos;
lastValidBreakPos = -1;
currentLineLength = 0;
}
pos++;
}
}
else if (lineWrap == WrapLinesModes.SolidBlock)
{
int pos = 0;
int currentLineLength = 0;
while (pos < stringBuilder.Length)
{
var c = stringBuilder[pos];
if (c == '\n')
{
stringBuilder.Remove(pos, 1);
continue;
}
currentLineLength++;
pos++;
if (currentLineLength == wrapColumn)
{
stringBuilder.Insert(pos, '\n');
pos++;
currentLineLength = 0;
}
}
}
}
private readonly StringBuilder _stringBuilder = new();
private enum WrapLinesModes
{
DontWrap,
WrapAtWords,
WrapAtCharacters,
WrapToFillBlock,
SolidBlock,
}
[Input(Guid = "85ad6b56-45eb-484e-b7d9-a93d52f8e54d")]
public readonly InputSlot<string> InputText = new();
[Input(Guid = "545629C0-C027-4E7C-888C-8E0589940D9D")]
public readonly InputSlot<int> WrapColumn = new();
[Input(Guid = "9a474693-b2f2-4293-bb52-2f9401a0c928", MappedType = typeof(WrapLinesModes))]
public readonly InputSlot<int> Mode = new ();
}
@@ -0,0 +1,20 @@
{
"FormatVersion": 3,
"Id": "96ccea19-c37f-4ee4-8dd2-5abdb347f5a1"/*WrapString*/,
"Inputs": [
{
"Id": "545629c0-c027-4e7c-888c-8e0589940d9d"/*WrapColumn*/,
"DefaultValue": 100
},
{
"Id": "85ad6b56-45eb-484e-b7d9-a93d52f8e54d"/*InputText*/,
"DefaultValue": ""
},
{
"Id": "9a474693-b2f2-4293-bb52-2f9401a0c928"/*Mode*/,
"DefaultValue": 1
}
],
"Children": [],
"Connections": []
}
@@ -0,0 +1,40 @@
{
"FormatVersion": 3,
"Id": "96ccea19-c37f-4ee4-8dd2-5abdb347f5a1"/*WrapString*/,
"Description": "Wraps a string at a column width",
"SymbolTags": "1",
"InputUis": [
{
"InputId": "545629c0-c027-4e7c-888c-8e0589940d9d"/*WrapColumn*/,
"Position": {
"X": 0.0,
"Y": 90.0
}
},
{
"InputId": "85ad6b56-45eb-484e-b7d9-a93d52f8e54d"/*InputText*/,
"Position": {
"X": 0.0,
"Y": 45.0
},
"Usage": "Default"
},
{
"InputId": "9a474693-b2f2-4293-bb52-2f9401a0c928"/*Mode*/,
"Position": {
"X": 0.0,
"Y": 90.0
}
}
],
"SymbolChildUis": [],
"OutputUis": [
{
"OutputId": "83571519-ade1-4508-bf4c-c3d734cf5603"/*Result*/,
"Position": {
"X": 0.0,
"Y": 0.0
}
}
]
}