rotor-framework 0.3.2
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/LICENSE.md +21 -0
- package/README.md +120 -0
- package/package.json +59 -0
- package/src/source/RotorFramework.bs +654 -0
- package/src/source/RotorFrameworkTask.bs +278 -0
- package/src/source/base/BaseModel.bs +52 -0
- package/src/source/base/BasePlugin.bs +48 -0
- package/src/source/base/BaseReducer.bs +184 -0
- package/src/source/base/BaseStack.bs +92 -0
- package/src/source/base/BaseViewModel.bs +124 -0
- package/src/source/base/BaseWidget.bs +104 -0
- package/src/source/base/DispatcherCreator.bs +193 -0
- package/src/source/base/DispatcherExternal.bs +260 -0
- package/src/source/base/ListenerForDispatchers.bs +246 -0
- package/src/source/engine/Constants.bs +74 -0
- package/src/source/engine/animator/Animator.bs +334 -0
- package/src/source/engine/builder/Builder.bs +213 -0
- package/src/source/engine/builder/NodePool.bs +236 -0
- package/src/source/engine/builder/PluginAdapter.bs +139 -0
- package/src/source/engine/builder/PostProcessor.bs +331 -0
- package/src/source/engine/builder/Processor.bs +156 -0
- package/src/source/engine/builder/Tree.bs +278 -0
- package/src/source/engine/builder/TreeBase.bs +313 -0
- package/src/source/engine/builder/WidgetCreate.bs +322 -0
- package/src/source/engine/builder/WidgetRemove.bs +72 -0
- package/src/source/engine/builder/WidgetUpdate.bs +113 -0
- package/src/source/engine/providers/Dispatcher.bs +72 -0
- package/src/source/engine/providers/DispatcherProvider.bs +95 -0
- package/src/source/engine/services/I18n.bs +169 -0
- package/src/source/libs/animate/Animate.bs +753 -0
- package/src/source/libs/animate/LICENSE.txt +21 -0
- package/src/source/plugins/DispatcherProviderPlugin.bs +127 -0
- package/src/source/plugins/FieldsPlugin.bs +180 -0
- package/src/source/plugins/FocusPlugin.bs +1522 -0
- package/src/source/plugins/FontStylePlugin.bs +159 -0
- package/src/source/plugins/ObserverPlugin.bs +548 -0
- package/src/source/utils/ArrayUtils.bs +495 -0
- package/src/source/utils/GeneralUtils.bs +181 -0
- package/src/source/utils/NodeUtils.bs +180 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import "../base/BasePlugin.bs"
|
|
2
|
+
|
|
3
|
+
namespace Rotor
|
|
4
|
+
|
|
5
|
+
' =====================================================================
|
|
6
|
+
' FontStylePlugin - Rotor Framework plugin for font styling on Labels
|
|
7
|
+
'
|
|
8
|
+
' Handles dynamic font styling on Label nodes with function evaluation
|
|
9
|
+
' and @-prefixed expression interpolation for dynamic font selection.
|
|
10
|
+
' Automatically updates font styles on widget lifecycle changes.
|
|
11
|
+
'
|
|
12
|
+
' Key Features:
|
|
13
|
+
' - Applies font styles specifically to Label nodes
|
|
14
|
+
' - Evaluates function-based font style values
|
|
15
|
+
' - Interpolates @-prefixed expressions for dynamic font selection
|
|
16
|
+
' - Automatically updates font styles on widget lifecycle changes
|
|
17
|
+
'
|
|
18
|
+
' Expression Syntax:
|
|
19
|
+
' @key.path - Resolves from widget.viewModelState
|
|
20
|
+
'
|
|
21
|
+
' Note: Only affects widgets with nodeType = "Label"
|
|
22
|
+
' =====================================================================
|
|
23
|
+
class FontStylePlugin extends Rotor.BasePlugin
|
|
24
|
+
|
|
25
|
+
' =============================================================
|
|
26
|
+
' MEMBER VARIABLES
|
|
27
|
+
' =============================================================
|
|
28
|
+
|
|
29
|
+
' Regex pattern for matching @-prefixed expressions
|
|
30
|
+
' Matches: @ followed by any characters except space, @, or comma
|
|
31
|
+
configRegex = /(\@)([^\s\@\,]*)/i
|
|
32
|
+
|
|
33
|
+
' Regex pattern for extracting plugin key prefix (unused but kept for compatibility)
|
|
34
|
+
pluginKeyRegex = /^[^\.]*/i
|
|
35
|
+
|
|
36
|
+
' =============================================================
|
|
37
|
+
' CONSTRUCTOR
|
|
38
|
+
' =============================================================
|
|
39
|
+
|
|
40
|
+
' ---------------------------------------------------------------------
|
|
41
|
+
' new - Initializes the FontStylePlugin instance
|
|
42
|
+
'
|
|
43
|
+
' @param {string} key - Plugin identifier (default: "fontStyle")
|
|
44
|
+
'
|
|
45
|
+
sub new(key = "fontStyle" as string)
|
|
46
|
+
super(key)
|
|
47
|
+
end sub
|
|
48
|
+
|
|
49
|
+
' =============================================================
|
|
50
|
+
' LIFECYCLE HOOKS
|
|
51
|
+
' =============================================================
|
|
52
|
+
|
|
53
|
+
hooks = {
|
|
54
|
+
' ---------------------------------------------------------------------
|
|
55
|
+
' beforeMount - Sets font style when widget is mounted
|
|
56
|
+
'
|
|
57
|
+
' Evaluates and applies font style after Label widget creation.
|
|
58
|
+
'
|
|
59
|
+
' @param {object} scope - Plugin instance (m)
|
|
60
|
+
' @param {object} widget - Widget being mounted
|
|
61
|
+
'
|
|
62
|
+
beforeMount: sub(scope as object, widget as object)
|
|
63
|
+
scope.setFontAttribute(widget)
|
|
64
|
+
end sub,
|
|
65
|
+
|
|
66
|
+
' ---------------------------------------------------------------------
|
|
67
|
+
' beforeUpdate - Updates font style when widget config changes
|
|
68
|
+
'
|
|
69
|
+
' Re-evaluates and applies font style when fontStyle property changes.
|
|
70
|
+
'
|
|
71
|
+
' @param {object} scope - Plugin instance (m)
|
|
72
|
+
' @param {object} widget - Widget being updated
|
|
73
|
+
' @param {dynamic} newValue - New font style configuration
|
|
74
|
+
' @param {dynamic} oldValue - Previous font style configuration
|
|
75
|
+
'
|
|
76
|
+
beforeUpdate: sub(scope as object, widget as object, newValue, oldValue)
|
|
77
|
+
widget[scope.key] = newValue ?? ""
|
|
78
|
+
scope.setFontAttribute(widget)
|
|
79
|
+
end sub
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
' =============================================================
|
|
83
|
+
' FONT STYLE PROCESSING
|
|
84
|
+
' =============================================================
|
|
85
|
+
|
|
86
|
+
' ---------------------------------------------------------------------
|
|
87
|
+
' setFontAttribute - Evaluates and applies font style to Label node
|
|
88
|
+
'
|
|
89
|
+
' Processing logic:
|
|
90
|
+
' 1. Checks if widget is a Label node (only Labels support font styles)
|
|
91
|
+
' 2. Resolves font style value through function evaluation or interpolation
|
|
92
|
+
' 3. Applies resolved font style to the node
|
|
93
|
+
'
|
|
94
|
+
' Font Style Resolution:
|
|
95
|
+
' - Functions are executed in widget scope
|
|
96
|
+
' - @-prefixed strings are interpolated from viewModelState
|
|
97
|
+
' - Direct strings are used as-is
|
|
98
|
+
'
|
|
99
|
+
' @param {object} widget - Widget instance
|
|
100
|
+
'
|
|
101
|
+
sub setFontAttribute(widget as object)
|
|
102
|
+
' Font styles only apply to Label nodes
|
|
103
|
+
if widget.nodeType = "Label"
|
|
104
|
+
value = widget[m.key]
|
|
105
|
+
node = widget.node
|
|
106
|
+
|
|
107
|
+
' Step 1: Resolve function-based font style
|
|
108
|
+
if Rotor.Utils.isFunction(value)
|
|
109
|
+
fontStyle = Rotor.Utils.callbackScoped(value, widget)
|
|
110
|
+
|
|
111
|
+
' Step 2: Process string interpolation
|
|
112
|
+
else if Rotor.Utils.isString(value)
|
|
113
|
+
results = m.configRegex.MatchAll(value)
|
|
114
|
+
|
|
115
|
+
if results.Count() > 0 and Rotor.Utils.isString(value)
|
|
116
|
+
for each result in results
|
|
117
|
+
matchKey = result[2] ' The key path after @
|
|
118
|
+
sourceTypeOperator = result[1] ' The @ symbol
|
|
119
|
+
|
|
120
|
+
' Determine source based on operator
|
|
121
|
+
if sourceTypeOperator = "@"
|
|
122
|
+
source = widget.viewModelState
|
|
123
|
+
else
|
|
124
|
+
source = widget
|
|
125
|
+
end if
|
|
126
|
+
|
|
127
|
+
if source <> invalid
|
|
128
|
+
' Resolve font style from key path
|
|
129
|
+
assetValue = Rotor.Utils.getValueByKeyPath(source, matchKey)
|
|
130
|
+
|
|
131
|
+
' Handle string vs non-string results
|
|
132
|
+
if Rotor.Utils.isString(assetValue)
|
|
133
|
+
' String interpolation - replace in original string
|
|
134
|
+
replaceRegex = CreateObject("roRegex", sourceTypeOperator + matchKey, "ig")
|
|
135
|
+
value = replaceRegex.ReplaceAll(value, assetValue)
|
|
136
|
+
else
|
|
137
|
+
' Non-string value - replace entire font style
|
|
138
|
+
value = assetValue
|
|
139
|
+
exit for
|
|
140
|
+
end if
|
|
141
|
+
end if
|
|
142
|
+
end for
|
|
143
|
+
end if
|
|
144
|
+
|
|
145
|
+
fontStyle = value
|
|
146
|
+
|
|
147
|
+
' Step 3: Direct value assignment
|
|
148
|
+
else
|
|
149
|
+
fontStyle = value
|
|
150
|
+
end if
|
|
151
|
+
|
|
152
|
+
' Apply font style to the Label node
|
|
153
|
+
Rotor.Utils.setFontAttribute(node, fontStyle)
|
|
154
|
+
end if
|
|
155
|
+
end sub
|
|
156
|
+
|
|
157
|
+
end class
|
|
158
|
+
|
|
159
|
+
end namespace
|