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.
Files changed (39) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +120 -0
  3. package/package.json +59 -0
  4. package/src/source/RotorFramework.bs +654 -0
  5. package/src/source/RotorFrameworkTask.bs +278 -0
  6. package/src/source/base/BaseModel.bs +52 -0
  7. package/src/source/base/BasePlugin.bs +48 -0
  8. package/src/source/base/BaseReducer.bs +184 -0
  9. package/src/source/base/BaseStack.bs +92 -0
  10. package/src/source/base/BaseViewModel.bs +124 -0
  11. package/src/source/base/BaseWidget.bs +104 -0
  12. package/src/source/base/DispatcherCreator.bs +193 -0
  13. package/src/source/base/DispatcherExternal.bs +260 -0
  14. package/src/source/base/ListenerForDispatchers.bs +246 -0
  15. package/src/source/engine/Constants.bs +74 -0
  16. package/src/source/engine/animator/Animator.bs +334 -0
  17. package/src/source/engine/builder/Builder.bs +213 -0
  18. package/src/source/engine/builder/NodePool.bs +236 -0
  19. package/src/source/engine/builder/PluginAdapter.bs +139 -0
  20. package/src/source/engine/builder/PostProcessor.bs +331 -0
  21. package/src/source/engine/builder/Processor.bs +156 -0
  22. package/src/source/engine/builder/Tree.bs +278 -0
  23. package/src/source/engine/builder/TreeBase.bs +313 -0
  24. package/src/source/engine/builder/WidgetCreate.bs +322 -0
  25. package/src/source/engine/builder/WidgetRemove.bs +72 -0
  26. package/src/source/engine/builder/WidgetUpdate.bs +113 -0
  27. package/src/source/engine/providers/Dispatcher.bs +72 -0
  28. package/src/source/engine/providers/DispatcherProvider.bs +95 -0
  29. package/src/source/engine/services/I18n.bs +169 -0
  30. package/src/source/libs/animate/Animate.bs +753 -0
  31. package/src/source/libs/animate/LICENSE.txt +21 -0
  32. package/src/source/plugins/DispatcherProviderPlugin.bs +127 -0
  33. package/src/source/plugins/FieldsPlugin.bs +180 -0
  34. package/src/source/plugins/FocusPlugin.bs +1522 -0
  35. package/src/source/plugins/FontStylePlugin.bs +159 -0
  36. package/src/source/plugins/ObserverPlugin.bs +548 -0
  37. package/src/source/utils/ArrayUtils.bs +495 -0
  38. package/src/source/utils/GeneralUtils.bs +181 -0
  39. package/src/source/utils/NodeUtils.bs +180 -0
@@ -0,0 +1,180 @@
1
+ namespace Rotor.Utils
2
+
3
+ '==========================================================================
4
+ ' NODE CREATION UTILITIES
5
+ '==========================================================================
6
+
7
+ ' ---------------------------------------------------------------------
8
+ ' createNode - Creates a SceneGraph node with custom fields
9
+ '
10
+ ' @param {string} nodeType - Type of SceneGraph node to create
11
+ ' @param {object} fields - Fields to set on the node (default: {})
12
+ ' @returns {object} Created SceneGraph node
13
+ '
14
+ function createNode(nodeType as string, fields = {} as object) as object
15
+ node = CreateObject("roSGNode", nodeType)
16
+ setCustomFields(node, fields, true, true)
17
+ return node
18
+ end function
19
+
20
+ ' ---------------------------------------------------------------------
21
+ ' createContentNode - Creates a ContentNode with fields
22
+ '
23
+ ' @param {object} fields - Fields to add to the content node (default: {})
24
+ ' @param {string} nodeType - Type of content node (default: "ContentNode")
25
+ ' @returns {object} Created ContentNode
26
+ '
27
+ function createContentNode(fields = {} as object, nodeType = "ContentNode" as string) as object
28
+ contentNode = CreateObject("roSGNode", nodeType)
29
+ if nodeType = "ContentNode"
30
+ contentNode.addFields(fields)
31
+ else
32
+ contentNode.setFields(fields)
33
+ end if
34
+ return contentNode
35
+ end function
36
+
37
+ '==========================================================================
38
+ ' FIELD MANIPULATION UTILITIES
39
+ '==========================================================================
40
+
41
+ ' ---------------------------------------------------------------------
42
+ ' setCustomFields - Sets custom fields on a SceneGraph node
43
+ '
44
+ ' Dynamically adds fields if they don't exist, then sets their values.
45
+ ' Uses addField to enable alwaysNotify feature for runtime field creation.
46
+ '
47
+ ' @param {object} node - SceneGraph node to modify
48
+ ' @param {object} fields - Fields to set (key-value pairs)
49
+ ' @param {boolean} overwrite - If true, overwrites existing field values (default: true)
50
+ ' @param {boolean} alwaysNotify - If true, field changes always trigger observers (default: true)
51
+ '
52
+ sub setCustomFields(node as object, fields as object, overwrite = true as boolean, alwaysNotify = true as boolean)
53
+ for each attr in fields.Items()
54
+ key = attr.key
55
+ value = attr.value
56
+
57
+
58
+ if node.hasField(key) = false
59
+
60
+ ' Only addFiled can set `alwaysNotify` feature to true in runtime, so we need it;
61
+ ' Type conversion and formatting are mandatory to make it possible.
62
+ typeStr = convertIntrinsicType(type(value))
63
+ node.addField(key, typeStr, alwaysNotify)
64
+
65
+ end if
66
+
67
+ if overwrite = true
68
+ node.setField(key, value)
69
+ end if
70
+
71
+ end for
72
+ end sub
73
+
74
+ '==========================================================================
75
+ ' CALLBACK UTILITIES
76
+ '==========================================================================
77
+
78
+ ' ---------------------------------------------------------------------
79
+ ' callbackScoped - Invokes a callback function in a specific scope
80
+ '
81
+ ' Supports both function references and method name strings.
82
+ ' Automatically handles 0-2 payload parameters.
83
+ '
84
+ ' @param {dynamic} callback - Function reference or method name string
85
+ ' @param {object} scope - Scope (m) in which to execute the callback
86
+ ' @param {dynamic} payload1 - Optional first parameter (default: invalid)
87
+ ' @param {dynamic} payload2 - Optional second parameter (default: invalid)
88
+ ' @returns {dynamic} Result of callback invocation or invalid
89
+ '
90
+ function callbackScoped(callback as dynamic, scope as object, payload1 = invalid as dynamic, payload2 = invalid as dynamic) as dynamic
91
+
92
+ if callback = invalid or scope = invalid then return invalid
93
+
94
+ ' check if callback valid, otherwise return
95
+ if not (Rotor.Utils.isFunction(callback) or (Rotor.Utils.isString(callback) and callback <> "")) then return invalid
96
+
97
+ ' check possible arguments
98
+ isValidPayload1 = Rotor.Utils.isValid(payload1)
99
+ isValidPayload2 = Rotor.Utils.isValid(payload2)
100
+
101
+ if Rotor.Utils.isString(callback)
102
+ if true = isValidPayload2
103
+ return scope[callback](payload1, payload2)
104
+ else if true = isValidPayload1
105
+ return scope[callback](payload1)
106
+ else
107
+ return scope[callback]()
108
+ end if
109
+ else if Rotor.Utils.isFunction(callback)
110
+ scope.rotor_tmp_callback_scoped = callback
111
+ if true = isValidPayload2
112
+ return scope.rotor_tmp_callback_scoped(payload1, payload2)
113
+ else if true = isValidPayload1
114
+ return scope.rotor_tmp_callback_scoped(payload1)
115
+ else
116
+ return scope.rotor_tmp_callback_scoped()
117
+ end if
118
+ end if
119
+ scope.rotor_tmp_callback_scoped = invalid
120
+ return invalid
121
+ end function
122
+
123
+ '==========================================================================
124
+ ' FONT UTILITIES
125
+ '==========================================================================
126
+
127
+ ' ---------------------------------------------------------------------
128
+ ' setFontAttribute - Sets font attributes on a node
129
+ '
130
+ ' @param {object} node - SceneGraph node to modify
131
+ ' @param {object} params - Font parameters (uri, size)
132
+ '
133
+ sub setFontAttribute(node as object, params as object)
134
+ font = createNode("Font", {
135
+ uri: params.uri,
136
+ size: params.size
137
+ })
138
+ node.font = font
139
+ end sub
140
+
141
+ ' ---------------------------------------------------------------------
142
+ ' removeFontAttribute - Removes font from a node
143
+ '
144
+ ' @param {object} node - SceneGraph node to modify
145
+ '
146
+ sub removeFontAttribute(node as object)
147
+ node.font = invalid
148
+ end sub
149
+
150
+ '==========================================================================
151
+ ' TYPE CONVERSION UTILITIES
152
+ '==========================================================================
153
+
154
+ ' ---------------------------------------------------------------------
155
+ ' convertIntrinsicType - Converts BrightScript intrinsic type to field type string
156
+ '
157
+ ' Converts type strings like "roInt" to "integer", "roAssocArray" to "assocarray", etc.
158
+ ' Used for dynamic field creation via addField.
159
+ '
160
+ ' @param {string} typeKey - Intrinsic type string (e.g., "roInt", "roAssocArray")
161
+ ' @returns {string} Converted field type string
162
+ '
163
+ function convertIntrinsicType(typeKey as string) as string
164
+ typeKey = LCase(typeKey)
165
+ types = {
166
+ roint: "integer",
167
+ roassocarray: "assocarray",
168
+ rosgnode: "node"
169
+ }
170
+ converted = types.lookUp(typeKey)
171
+ if converted <> invalid
172
+ return converted
173
+ else if Left(typeKey, 2) = "ro"
174
+ return Right(typeKey, Len(typeKey) - 2)
175
+ end if
176
+ return typeKey
177
+
178
+ end function
179
+
180
+ end namespace