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,16 @@
namespace Lib.@string.random;
[Guid("dd7fa7ee-266a-43c8-b29f-3357488b26be")]
internal sealed class AnimRandomString : Instance<AnimRandomString>
{
[Output(Guid = "3a769380-1586-4d7f-a881-e509d5c14c1b")]
public readonly Slot<string> Fragments = new();
[Input(Guid = "4e36b984-43ff-447b-8e1d-a099fefd4d74")]
public readonly InputSlot<float> Rate = new();
[Input(Guid = "9b705b88-a644-498a-b831-5d0243e01c41", MappedType = typeof(MockStrings.Categories))]
public readonly InputSlot<int> Category = new();
}
@@ -0,0 +1,84 @@
{
"FormatVersion": 3,
"Id": "dd7fa7ee-266a-43c8-b29f-3357488b26be"/*AnimRandomString*/,
"Inputs": [
{
"Id": "4e36b984-43ff-447b-8e1d-a099fefd4d74"/*Rate*/,
"DefaultValue": 1.0
},
{
"Id": "9b705b88-a644-498a-b831-5d0243e01c41"/*Category*/,
"DefaultValue": 0
}
],
"Children": [
{
"Id": "3af5dc6c-89f4-44b0-8c89-13b006d318cb"/*MockStrings*/,
"SymbolId": "3af25959-fd3f-4608-b521-5860d82554df",
"InputValues": [],
"Outputs": []
},
{
"Id": "9a2ba5ae-1660-48d2-bc58-a9a97f575741"/*PickStringPart*/,
"SymbolId": "7baaa83d-5c09-42a0-b7bc-35dbcfa5156d",
"InputValues": [],
"Outputs": []
},
{
"Id": "d49a1aed-efe6-48b7-a6e7-8c2d3f4db751"/*FloatToInt*/,
"SymbolId": "06b4728e-852c-491a-a89d-647f7e0b5415",
"InputValues": [],
"Outputs": []
},
{
"Id": "fa40238c-0cd8-4ffc-b8ea-18d11fa12790"/*AnimValue*/,
"SymbolId": "ea7b8491-2f8e-4add-b0b1-fd068ccfed0d",
"InputValues": [
{
"Id": "4cf5d20b-7335-4584-b246-c260ac5cdf4f"/*Shape*/,
"Type": "System.Int32",
"Value": 12
}
],
"Outputs": []
}
],
"Connections": [
{
"SourceParentOrChildId": "9a2ba5ae-1660-48d2-bc58-a9a97f575741",
"SourceSlotId": "62368c06-7815-47bc-9b0d-3024a2907e01",
"TargetParentOrChildId": "00000000-0000-0000-0000-000000000000",
"TargetSlotId": "3a769380-1586-4d7f-a881-e509d5c14c1b"
},
{
"SourceParentOrChildId": "00000000-0000-0000-0000-000000000000",
"SourceSlotId": "9b705b88-a644-498a-b831-5d0243e01c41",
"TargetParentOrChildId": "3af5dc6c-89f4-44b0-8c89-13b006d318cb",
"TargetSlotId": "054ade21-c08e-4633-9725-6168fd7806f9"
},
{
"SourceParentOrChildId": "3af5dc6c-89f4-44b0-8c89-13b006d318cb",
"SourceSlotId": "461d8e3a-b4db-4a12-94c5-c791e347e51f",
"TargetParentOrChildId": "9a2ba5ae-1660-48d2-bc58-a9a97f575741",
"TargetSlotId": "05d7962b-a02e-4ab5-9927-865375348ccd"
},
{
"SourceParentOrChildId": "d49a1aed-efe6-48b7-a6e7-8c2d3f4db751",
"SourceSlotId": "1eb7c5c4-0982-43f4-b14d-524571e3cdda",
"TargetParentOrChildId": "9a2ba5ae-1660-48d2-bc58-a9a97f575741",
"TargetSlotId": "9cb908ad-0800-4b88-b256-c6cc2b84ab6c"
},
{
"SourceParentOrChildId": "fa40238c-0cd8-4ffc-b8ea-18d11fa12790",
"SourceSlotId": "ae4addf0-08cf-4b25-9515-4fef9359d183",
"TargetParentOrChildId": "d49a1aed-efe6-48b7-a6e7-8c2d3f4db751",
"TargetSlotId": "af866a6c-1ab0-43c0-9e8a-5d25c300e128"
},
{
"SourceParentOrChildId": "00000000-0000-0000-0000-000000000000",
"SourceSlotId": "4e36b984-43ff-447b-8e1d-a099fefd4d74",
"TargetParentOrChildId": "fa40238c-0cd8-4ffc-b8ea-18d11fa12790",
"TargetSlotId": "48005727-0158-4795-ad70-8410c27fd01d"
}
]
}
@@ -0,0 +1,61 @@
{
"FormatVersion": 3,
"Id": "dd7fa7ee-266a-43c8-b29f-3357488b26be"/*AnimRandomString*/,
"Description": "Returns a random word per beat.",
"SymbolTags": "8",
"InputUis": [
{
"InputId": "4e36b984-43ff-447b-8e1d-a099fefd4d74"/*Rate*/,
"Position": {
"X": -200.0,
"Y": 0.0
}
},
{
"InputId": "9b705b88-a644-498a-b831-5d0243e01c41"/*Category*/,
"Position": {
"X": -200.0,
"Y": 45.0
}
}
],
"SymbolChildUis": [
{
"ChildId": "3af5dc6c-89f4-44b0-8c89-13b006d318cb"/*MockStrings*/,
"Position": {
"X": 150.0,
"Y": 0.0
}
},
{
"ChildId": "9a2ba5ae-1660-48d2-bc58-a9a97f575741"/*PickStringPart*/,
"Position": {
"X": 300.0,
"Y": 0.0
}
},
{
"ChildId": "d49a1aed-efe6-48b7-a6e7-8c2d3f4db751"/*FloatToInt*/,
"Position": {
"X": 150.0,
"Y": 56.0
}
},
{
"ChildId": "fa40238c-0cd8-4ffc-b8ea-18d11fa12790"/*AnimValue*/,
"Position": {
"X": 1.0560608,
"Y": 214.44357
}
}
],
"OutputUis": [
{
"OutputId": "3a769380-1586-4d7f-a881-e509d5c14c1b"/*Fragments*/,
"Position": {
"X": 600.0,
"Y": 21.5
}
}
]
}
@@ -0,0 +1,369 @@
using T3.Core.Utils;
namespace Lib.@string.random;
[Guid("7b21f10b-3548-4a23-95df-360addaeb03d")]
internal sealed class BuildRandomString : Instance<BuildRandomString>
{
[Output(Guid = "ABA9EB42-5AF0-4165-A2BD-FDFCD4340484", DirtyFlagTrigger = DirtyFlagTrigger.Animated)]
public readonly Slot<string> Result = new();
[Output(Guid = "8116d50e-0220-4bb7-b09d-881f722804cd")]
public readonly Slot<StringBuilder> Builder = new();
public BuildRandomString()
{
Result.UpdateAction += Update;
Builder.UpdateAction += Update;
}
private double _lastUpdateTime = 0;
private void Update(EvaluationContext context)
{
var maxLength = MaxLength.GetValue(context);
var stringBuilder = OverrideBuilder.GetValue(context);
if (Result.Value != null && Math.Abs(context.LocalFxTime - _lastUpdateTime) < 0.001)
return;
_lastUpdateTime = context.LocalFxTime;
var scrambleSeed = ScrambleSeed.GetValue(context);
//var lastIndex = _index;
if (maxLength <= 0)
{
Result.Value= String.Empty;
Result.Value= string.Empty;
return;
}
if (!OverrideBuilder.HasInputConnections || stringBuilder == null)
{
stringBuilder = _fallbackBuffer;
}
if (Clear.GetValue(context))
{
stringBuilder.Clear();
_index = 0;
}
//var mode = (Modes)WriteMode.GetValue(context);
try
{
var scrambleRatio = ScrambleRatio.GetValue(context);
var scrambleEnabled = Scramble.GetValue(context);
if (scrambleRatio > 0 && scrambleEnabled)
{
for (int index = 0; index < stringBuilder.Length; index++)
{
var hash = (float)((double)MathUtils.XxHash((uint)index + (uint)scrambleSeed * 123127) / uint.MaxValue);
if (hash < scrambleRatio)
{
var scrambleChunkEnd = index + hash * stringBuilder.Length + 1;
while (index < stringBuilder.Length && index < scrambleChunkEnd)
{
var c = stringBuilder[index];
if (c != '\n')
{
if (c == 32)
c = (char)90;
c= (char)(c-1);
stringBuilder[index] = c;
}
index++;
}
}
}
}
if (Insert.GetValue(context))
{
if (JumpToRandomPos.GetValue(context))
_index = (int)_random.NextLong(0, stringBuilder.Length);
var separator = Separator.GetValue(context); ;
if (!string.IsNullOrEmpty(separator))
separator = separator.Replace("\\n", "\n");
var str = InsertString.GetValue(context);
var insertString = str + separator;
var insertLength = insertString.Length;
var currentLength = stringBuilder.Length;
var lineWrap = (WrapLinesModes)WrapLines.GetValue(context);
var mode = (Modes)WriteMode.GetValue(context);
if (_index > maxLength)
_index = 0;
var pos = _index;
if (pos + insertLength > maxLength)
{
insertLength = maxLength - pos;
}
if (mode != Modes.Insert && pos < currentLength - insertLength)
{
stringBuilder.Remove(pos, insertLength);
}
if (pos > currentLength)
{
stringBuilder.Append(new string(' ', pos - currentLength));
}
stringBuilder.Insert(pos, insertString);
InsertLineWraps(lineWrap, stringBuilder, pos, insertLength, WrapLineColumn.GetValue(context).Clamp(1,1000));
switch (mode)
{
case Modes.Insert:
{
_index += insertLength;
_index %= maxLength;
break;
}
case Modes.Overwrite:
{
_index += insertLength;
_index %= maxLength;
break;
}
case Modes.OverwriteAtFixedOffset:
_index += OverwriteOffset.GetValue(context);
if (_index > maxLength)
{
_index = _index % maxLength;
}
else if (_index < 0)
{
_index += maxLength - insertLength;
}
break;
default:
throw new ArgumentOutOfRangeException();
}
//InsertLineWraps(lineWrap, stringBuilder);
if (stringBuilder.Length > maxLength)
stringBuilder.Length = maxLength;
}
}
catch (Exception e)
{
Log.Warning($"Failed to manipulate string at index {_index} " + e.Message);
}
//
Builder.Value = stringBuilder;
Result.Value = stringBuilder.ToString();
}
private void InsertLineWraps(WrapLinesModes lineWrap, StringBuilder stringBuilder, int insertPos, int insertLength, int wrapColumn)
{
if (lineWrap == WrapLinesModes.WrapAtCharacters)
{
var lookBackIndex = insertPos;
while (lookBackIndex > 0 && stringBuilder[lookBackIndex] != '\n')
{
lookBackIndex--;
}
var lineLength = insertPos - lookBackIndex + insertLength;
if (lineLength > wrapColumn && insertPos > 0 && insertPos < stringBuilder.Length)
{
stringBuilder[insertPos - 1] = '\n';
return;
}
var lookForwardIndex = insertPos;
while (lookForwardIndex < stringBuilder.Length && stringBuilder[lookForwardIndex] != '\n')
{
lookForwardIndex++;
}
if (lookForwardIndex - lookBackIndex > wrapColumn)
{
stringBuilder[insertPos + insertLength - 1] = '\n';
}
}
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 enum Modes
{
Insert,
Overwrite,
OverwriteAtFixedOffset,
}
private enum WrapLinesModes
{
DontWrap,
WrapAtWords,
WrapAtCharacters,
WrapToFillBlock,
SolidBlock,
}
private StringBuilder _fallbackBuffer = new();
private int _index = 0;
private Random _random = new();
[Input(Guid = "CE436E27-05A5-431D-9AA2-920DBFF639A7", MappedType = typeof(Modes))]
public readonly InputSlot<int> WriteMode = new();
[Input(Guid = "77A5604A-034A-4352-BD46-BE3CB57F90B7")]
public readonly InputSlot<bool> Clear = new();
[Input(Guid = "095202BF-118F-4C4C-802E-7916BC290A60")]
public readonly InputSlot<bool> Insert = new();
[Input(Guid = "F977FAAF-1840-4A75-9BC5-43176F2E88E9")]
public readonly InputSlot<bool> JumpToRandomPos = new();
[Input(Guid = "960179BD-286F-4629-BBCB-CD31AA9C9AE2")]
public readonly InputSlot<string> InsertString = new();
[Input(Guid = "8EEE8067-1A4E-4372-93D0-2DBC368AA45A")]
public readonly InputSlot<string> Separator = new();
[Input(Guid = "1559C0E9-BA56-447F-8241-03D8D59AC205")]
public readonly InputSlot<int> OverwriteOffset = new();
[Input(Guid = "38CE7F47-C117-47A2-AEEA-609716C60555")]
public readonly InputSlot<int> MaxLength = new();
[Input(Guid = "875CBFA9-FFA8-4204-810C-C04F5F421441", MappedType = typeof(WrapLinesModes))]
public readonly InputSlot<int> WrapLines = new();
[Input(Guid = "BD941C4B-18A8-4687-85A8-3FE53B4F6213")]
public readonly InputSlot<int> WrapLineColumn = new();
[Input(Guid = "7DABD7C8-5C2B-4BE2-B1B6-BF8B8FCBFD8D")]
public readonly InputSlot<float> ScrambleRatio = new();
[Input(Guid = "9253B148-325B-427A-819E-1AE1B1019ADE")]
public readonly InputSlot<bool> Scramble = new();
[Input(Guid = "3EA4F12E-7184-45BC-A523-EF6A2E1C5C3D")]
public readonly InputSlot<int> ScrambleSeed = new();
[Input(Guid = "CCFAC8A9-0954-4869-A47C-B66C714F6545")]
public readonly InputSlot<StringBuilder> OverrideBuilder = new();
}
@@ -0,0 +1,64 @@
{
"FormatVersion": 3,
"Id": "7b21f10b-3548-4a23-95df-360addaeb03d"/*BuildRandomString*/,
"Inputs": [
{
"Id": "095202bf-118f-4c4c-802e-7916bc290a60"/*Insert*/,
"DefaultValue": true
},
{
"Id": "1559c0e9-ba56-447f-8241-03d8d59ac205"/*OverwriteOffset*/,
"DefaultValue": 10
},
{
"Id": "38ce7f47-c117-47a2-aeea-609716c60555"/*MaxLength*/,
"DefaultValue": 1000
},
{
"Id": "3ea4f12e-7184-45bc-a523-ef6a2e1c5c3d"/*ScrambleSeed*/,
"DefaultValue": 0
},
{
"Id": "77a5604a-034a-4352-bd46-be3cb57f90b7"/*Clear*/,
"DefaultValue": false
},
{
"Id": "7dabd7c8-5c2b-4be2-b1b6-bf8b8fcbfd8d"/*ScrambleRatio*/,
"DefaultValue": 0.0
},
{
"Id": "875cbfa9-ffa8-4204-810c-c04f5f421441"/*WrapLines*/,
"DefaultValue": 1
},
{
"Id": "8eee8067-1a4e-4372-93d0-2dbc368aa45a"/*Separator*/,
"DefaultValue": " "
},
{
"Id": "9253b148-325b-427a-819e-1ae1b1019ade"/*Scramble*/,
"DefaultValue": false
},
{
"Id": "960179bd-286f-4629-bbcb-cd31aa9c9ae2"/*InsertString*/,
"DefaultValue": "Tooll likes Cats."
},
{
"Id": "bd941c4b-18a8-4687-85a8-3fe53b4f6213"/*WrapLineColumn*/,
"DefaultValue": 60
},
{
"Id": "ccfac8a9-0954-4869-a47c-b66c714f6545"/*OverrideBuilder*/,
"DefaultValue": null
},
{
"Id": "ce436e27-05a5-431d-9aa2-920dbff639a7"/*WriteMode*/,
"DefaultValue": 0
},
{
"Id": "f977faaf-1840-4a75-9bc5-43176f2e88e9"/*JumpToRandomPos*/,
"DefaultValue": false
}
],
"Children": [],
"Connections": []
}
@@ -0,0 +1,130 @@
{
"FormatVersion": 3,
"Id": "7b21f10b-3548-4a23-95df-360addaeb03d"/*BuildRandomString*/,
"Description": "Produces a wide selection of text writer effects that \ncan be linked to AudioReactions. Interesting setups are\n\n[MockStrings]->[GetStringPart]->[ScrambleString]",
"SymbolTags": "72",
"InputUis": [
{
"InputId": "095202bf-118f-4c4c-802e-7916bc290a60"/*Insert*/,
"Position": {
"X": -200.0,
"Y": 135.0
}
},
{
"InputId": "1559c0e9-ba56-447f-8241-03d8d59ac205"/*OverwriteOffset*/,
"Position": {
"X": -200.0,
"Y": 270.0
}
},
{
"InputId": "38ce7f47-c117-47a2-aeea-609716c60555"/*MaxLength*/,
"Position": {
"X": -200.0,
"Y": 90.0
}
},
{
"InputId": "3ea4f12e-7184-45bc-a523-ef6a2e1c5c3d"/*ScrambleSeed*/,
"Position": {
"X": -200.0,
"Y": 225.0
}
},
{
"InputId": "77a5604a-034a-4352-bd46-be3cb57f90b7"/*Clear*/,
"Position": {
"X": -200.0,
"Y": 405.0
},
"AddPadding": "True"
},
{
"InputId": "7dabd7c8-5c2b-4be2-b1b6-bf8b8fcbfd8d"/*ScrambleRatio*/,
"Position": {
"X": -200.0,
"Y": 135.0
},
"AddPadding": "True"
},
{
"InputId": "875cbfa9-ffa8-4204-810c-c04f5f421441"/*WrapLines*/,
"Position": {
"X": -200.0,
"Y": 360.0
},
"AddPadding": "True"
},
{
"InputId": "8eee8067-1a4e-4372-93d0-2dbc368aa45a"/*Separator*/,
"Position": {
"X": -200.0,
"Y": 180.0
},
"Usage": "Default"
},
{
"InputId": "9253b148-325b-427a-819e-1ae1b1019ade"/*Scramble*/,
"Position": {
"X": -200.0,
"Y": 180.0
}
},
{
"InputId": "960179bd-286f-4629-bbcb-cd31aa9c9ae2"/*InsertString*/,
"Position": {
"X": -200.0,
"Y": 180.0
},
"GroupTitle": "Settings",
"Usage": "Default"
},
{
"InputId": "bd941c4b-18a8-4687-85a8-3fe53b4f6213"/*WrapLineColumn*/,
"Position": {
"X": -200.0,
"Y": 45.0
}
},
{
"InputId": "ccfac8a9-0954-4869-a47c-b66c714f6545"/*OverrideBuilder*/,
"Position": {
"X": -200.0,
"Y": 90.0
},
"AddPadding": "True"
},
{
"InputId": "ce436e27-05a5-431d-9aa2-920dbff639a7"/*WriteMode*/,
"Position": {
"X": -200.0,
"Y": 0.0
}
},
{
"InputId": "f977faaf-1840-4a75-9bc5-43176f2e88e9"/*JumpToRandomPos*/,
"Position": {
"X": -200.0,
"Y": 315.0
}
}
],
"SymbolChildUis": [],
"OutputUis": [
{
"OutputId": "8116d50e-0220-4bb7-b09d-881f722804cd"/*Builder*/,
"Position": {
"X": 0.0,
"Y": 0.0
}
},
{
"OutputId": "aba9eb42-5af0-4165-a2bd-fdfcd4340484"/*Result*/,
"Position": {
"X": 0.0,
"Y": 0.0
}
}
]
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,12 @@
{
"FormatVersion": 3,
"Id": "3af25959-fd3f-4608-b521-5860d82554df"/*MockStrings*/,
"Inputs": [
{
"Id": "054ade21-c08e-4633-9725-6168fd7806f9"/*Category*/,
"DefaultValue": 0
}
],
"Children": [],
"Connections": []
}
@@ -0,0 +1,25 @@
{
"FormatVersion": 3,
"Id": "3af25959-fd3f-4608-b521-5860d82554df"/*MockStrings*/,
"Description": "A small selection of strings of different categories.",
"SymbolTags": "8",
"InputUis": [
{
"InputId": "054ade21-c08e-4633-9725-6168fd7806f9"/*Category*/,
"Position": {
"X": -200.0,
"Y": 0.0
}
}
],
"SymbolChildUis": [],
"OutputUis": [
{
"OutputId": "461d8e3a-b4db-4a12-94c5-c791e347e51f"/*Result*/,
"Position": {
"X": 0.0,
"Y": 0.0
}
}
]
}