wfc 2.1.0 → 2.2.0

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 (6) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -2
  3. data/README.md +270 -73
  4. data/lib/web_forms.rb +173 -52
  5. data/lib/wfc/version.rb +2 -2
  6. metadata +9 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9c9494460645247374def67bc05bd7c50f77ef72d7b0def2223a1b242880783
4
- data.tar.gz: 619c0999e742305914bcc70d1223c5878e5a293cb4381dad9819a9c756a03eec
3
+ metadata.gz: f23f54514453d35efb89bf9d57f589e07580e71386e5258f482dd71d6f403dbb
4
+ data.tar.gz: bffde63c76c1be31f6569e38a0d7902191c21e857a22e928e415a4861754f3f8
5
5
  SHA512:
6
- metadata.gz: 74b895aea1e783332fca9709ea72564253ea40f95891129478c21e2c4bd089b834bf4188d7f51c86f4cd1231cb573a59241dd128b4eb011cd55a29a3b0eb3dec
7
- data.tar.gz: a149febdc30e90b6d6a6c9dc29a2d481414fc63a82a0d21f04e3d4911d9e4d31c328a68dec1f3f123a3b368851a1f1fab60470b4793759f524b0ecb67444b5f4
6
+ metadata.gz: d046af34057a308a955bcd014c30540044ab31b14c21d0846efc777105841d613ace4ef5a668a0979714de8f058103d1298cf271e9c7bdf21b760dfcfa27dc31
7
+ data.tar.gz: 58f6212bcb8f1985bed449d02e3408fde2626c2d73d1ab44a0b1e552530478e6d83b048198cd15945dd687e6f85f610e82e479245a534842b99968dc1c212311
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [2.1.0] - 2026-09-10
3
+ ## [2.2.0] - 2026-10-05
4
4
 
5
- - Initial release of WebForms Core (WFC) for Ruby.
5
+ - Addition of the powerful `render` method.
6
+ - Addition of `snapshot` and `rollback` methods.
7
+ - Addition of `GetTagHash` for detecting DOM changes.
8
+ - Addition of Regex-based value formatting (`SetFormatCacheValue`, `SetFormatSaveValue`).
9
+ - Addition of arithmetic and text operations for stored values.
10
+ - Addition of Regex-based element selection in Criteria.
11
+ - Addition of `Try`/`Catch` error handling.
12
+ - Addition of `LockQueue` for explicit queue locking.
13
+ - Addition of `SetCustomValidity` for native HTML validation.
14
+ - Stable WebAssembly support across 7 languages.
data/README.md CHANGED
@@ -1,20 +1,41 @@
1
- # WebForms Core (WFC)
1
+ # WebForms Core
2
2
 
3
- WebForms Core (WFC) is a server-driven web interface technology for Ruby.
3
+ ## WFC for Ruby
4
4
 
5
- It provides a `WebForms` class for generating server-side commands that manipulate HTML elements and interact with the WebFormsJS runtime in the browser.
5
+ **WFC** is the Ruby implementation of the **WebForms Core Commander**. It provides the `WebForms` class for generating WebForms Core commands from Ruby server-side applications.
6
6
 
7
- WebForms Core is developed by [Elanat](https://elanat.net).
7
+ ## WebForms Core Architecture
8
+
9
+ WebForms Core consists of two main parts:
10
+
11
+ - **Commander** — WebForms classes implemented for different programming languages. Commanders generate WebForms Core commands that describe changes to the HTML document.
12
+ - **Executor** — **WebFormsJS**, the client-side JavaScript library that receives and executes those commands in the browser.
13
+
14
+ The Ruby `WFC` implementation provides the **Commander** for Ruby, while WebFormsJS provides the common browser-side Executor.
15
+
16
+ The WebFormsJS Executor is loaded into the HTML document:
17
+
18
+ ```html
19
+ <script type="module" src="/script/web-forms.js"></script>
20
+ ```
21
+
22
+ WebForms Core is a technology developed by [Elanat](https://elanat.net).
8
23
 
9
24
  ## Installation
10
25
 
11
- Install the gem:
26
+ ### Installation via RubyGems
27
+
28
+ The package is available on RubyGems:
29
+
30
+ https://rubygems.org/gems/wfc
31
+
32
+ Install using RubyGems:
12
33
 
13
34
  ```bash
14
35
  gem install wfc
15
36
  ```
16
37
 
17
- Or add it to your application's Gemfile:
38
+ Or add it to your application's `Gemfile`:
18
39
 
19
40
  ```ruby
20
41
  gem "wfc"
@@ -26,25 +47,32 @@ Then run:
26
47
  bundle install
27
48
  ```
28
49
 
29
- ## Usage
50
+ ### Source Code
51
+
52
+ The Ruby implementation is available in the WebForms Core classes repository:
53
+
54
+ https://github.com/webforms-core/WebFormsClasses/tree/elanat_framework/ruby
30
55
 
31
- Require the gem:
56
+ ## How to Work with WebForms Core in Ruby
57
+
58
+ The following example demonstrates how to use WFC in a Ruby server-side application.
32
59
 
33
60
  ```ruby
34
61
  require "wfc"
35
62
 
36
63
  include WebFormsCore
37
- ```
38
64
 
39
- You can then create a `WebForms` instance and generate server-side commands:
40
-
41
- ```ruby
42
65
  form = WebForms.new
43
66
 
44
- form.set_text("message", "Hello from WebForms Core!")
67
+ form.set_text(
68
+ InputPlace.tag("body"),
69
+ "Hello from WebForms Core!"
70
+ )
71
+
72
+ puts form.response
45
73
  ```
46
74
 
47
- The generated commands are intended to be executed by the WebFormsJS runtime in the browser.
75
+ The `WebForms` class generates WebForms Core commands on the server. These commands are returned to the browser and executed by WebFormsJS.
48
76
 
49
77
  ## How to Work with WebForms Core in Ruby (Sinatra Framework)
50
78
 
@@ -53,123 +81,292 @@ WebForms Core can be used with the [Sinatra](https://sinatrarb.com/) framework.
53
81
  After installing the `wfc` gem, require it in your Sinatra application:
54
82
 
55
83
  ```ruby
56
- require 'sinatra'
57
- require 'wfc'
84
+ require "sinatra"
85
+ require "wfc"
58
86
 
59
87
  include WebFormsCore
60
88
  ```
61
89
 
62
- The following example demonstrates a form that sends data to the server. The server then uses the `WebForms` class to generate commands that modify the page.
90
+ The following example demonstrates a form that sends data to the server. The server then uses the `WebForms` class to generate commands that modify the existing HTML document.
63
91
 
64
92
  ```ruby
65
- require 'sinatra'
66
- require 'wfc'
93
+ require "sinatra"
94
+ require "wfc"
67
95
 
68
96
  include WebFormsCore
69
97
 
70
- get '/' do
98
+ get "/" do
71
99
  erb :view
72
100
  end
73
101
 
74
- post '/' do
75
- if params['btn_SetBodyValue']
76
- name = params['txt_Name']
77
- background_color = params['txt_BackgroundColor']
78
- font_size = params['txt_FontSize'].to_i
102
+ post "/" do
103
+ if params["btn_SetBodyValue"]
104
+ name = params["txt_Name"]
105
+ background_color = params["txt_BackgroundColor"]
106
+ font_size = params["txt_FontSize"].to_i
79
107
 
80
108
  form = WebForms.new
81
109
 
82
- form.set_font_size(InputPlace.tag('form'), font_size)
83
- form.set_background_color(InputPlace.tag('form'), background_color)
84
- form.set_disabled(InputPlace.name('btn_SetBodyValue'), true)
110
+ form.set_font_size(
111
+ InputPlace.tag("form"),
112
+ font_size
113
+ )
85
114
 
86
- form.add_tag(InputPlace.tag('form'), 'h3')
87
- form.set_text(InputPlace.tag('h3'), "Welcome #{name}!")
115
+ form.set_background_color(
116
+ InputPlace.tag("form"),
117
+ background_color
118
+ )
119
+
120
+ form.set_disabled(
121
+ InputPlace.name("btn_SetBodyValue"),
122
+ true
123
+ )
124
+
125
+ form.add_tag(
126
+ InputPlace.tag("form"),
127
+ "h3"
128
+ )
129
+
130
+ form.set_text(
131
+ InputPlace.tag("h3"),
132
+ "Welcome #{name}!"
133
+ )
88
134
 
89
135
  return form.response
90
136
  end
91
137
  end
138
+ ```
92
139
 
93
- __END__
140
+ The corresponding view can contain:
94
141
 
95
- @@view
142
+ ```html
96
143
  <!DOCTYPE html>
97
144
  <html>
98
145
  <head>
99
146
  <title>Using WebForms Core</title>
100
- <script type="text/javascript" src="/script/web-forms.js"></script>
147
+ <script type="module" src="/script/web-forms.js"></script>
101
148
  </head>
102
149
  <body>
103
- <form method="post" action="/" >
104
-
105
- <label for="txt_Name">Your Name</label>
106
- <input name="txt_Name" id="txt_Name" type="text" />
107
- <br>
108
- <label for="txt_FontSize">Set Font Size</label>
109
- <input name="txt_FontSize" id="txt_FontSize" type="number" value="16" min="10" max="36" />
110
- <br>
111
- <label for="txt_BackgroundColor">Set Background Color</label>
112
- <input name="txt_BackgroundColor" id="txt_BackgroundColor" type="text" />
113
- <br>
114
- <input name="btn_SetBodyValue" type="submit" value="Click to send data" />
115
-
116
- </form>
150
+ <form method="post" action="/">
151
+ <label for="txt_Name">Your Name</label>
152
+ <input name="txt_Name" id="txt_Name" type="text">
153
+ <br>
154
+
155
+ <label for="txt_FontSize">Set Font Size</label>
156
+ <input
157
+ name="txt_FontSize"
158
+ id="txt_FontSize"
159
+ type="number"
160
+ value="16"
161
+ min="10"
162
+ max="36"
163
+ >
164
+ <br>
165
+
166
+ <label for="txt_BackgroundColor">
167
+ Set Background Color
168
+ </label>
169
+
170
+ <input
171
+ name="txt_BackgroundColor"
172
+ id="txt_BackgroundColor"
173
+ type="text"
174
+ >
175
+ <br>
176
+
177
+ <input
178
+ name="btn_SetBodyValue"
179
+ type="submit"
180
+ value="Click to send data"
181
+ >
182
+ </form>
117
183
  </body>
118
184
  </html>
119
185
  ```
120
186
 
121
- ### How the Example Works
187
+ ## How the Ruby Example Works
122
188
 
123
- When the page is requested for the first time, the `GET /` route renders the complete view.
189
+ When the page is requested for the first time, the `GET /` route renders the complete HTML view.
124
190
 
125
- When the submit button is clicked, the browser sends the form data to the `POST /` route. The server checks whether `btn_SetBodyValue` was submitted.
191
+ The page includes the WebFormsJS Executor:
126
192
 
127
- If the button was submitted, a `WebForms` instance is created and WebForms Core methods are used to generate commands:
193
+ ```html
194
+ <script type="module" src="/script/web-forms.js"></script>
195
+ ```
196
+
197
+ When the form is submitted, Sinatra receives the submitted form data through `params`.
198
+
199
+ If the submit button is included in the request, a `WebForms` instance is created:
128
200
 
129
201
  ```ruby
130
202
  form = WebForms.new
203
+ ```
131
204
 
132
- form.set_font_size(InputPlace.tag('form'), font_size)
133
- form.set_background_color(InputPlace.tag('form'), background_color)
134
- form.set_disabled(InputPlace.name('btn_SetBodyValue'), true)
205
+ The application then generates WebForms Core commands:
135
206
 
136
- form.add_tag(InputPlace.tag('form'), 'h3')
137
- form.set_text(InputPlace.tag('h3'), "Welcome #{name}!")
207
+ ```ruby
208
+ form.set_font_size(
209
+ InputPlace.tag("form"),
210
+ font_size
211
+ )
212
+
213
+ form.set_background_color(
214
+ InputPlace.tag("form"),
215
+ background_color
216
+ )
217
+
218
+ form.set_disabled(
219
+ InputPlace.name("btn_SetBodyValue"),
220
+ true
221
+ )
138
222
  ```
139
223
 
140
- The generated response is then returned:
224
+ Additional commands modify the HTML document:
225
+
226
+ ```ruby
227
+ form.add_tag(
228
+ InputPlace.tag("form"),
229
+ "h3"
230
+ )
231
+
232
+ form.set_text(
233
+ InputPlace.tag("h3"),
234
+ "Welcome #{name}!"
235
+ )
236
+ ```
237
+
238
+ Finally, the generated WebForms Core response is returned:
141
239
 
142
240
  ```ruby
143
241
  return form.response
144
242
  ```
145
243
 
146
- In this case, the complete view is not rendered again. The response contains WebForms Core commands that are processed by WebFormsJS in the browser.
244
+ WebFormsJS receives the response and executes the generated commands on the HTML DOM.
245
+
246
+ In this case, the complete HTML view is not rendered again. The POST response contains WebForms Core commands that update the existing HTML document in the browser.
247
+
248
+ This allows a Ruby server-side application to control the client-side HTML document through WebForms Core commands without requiring JavaScript code for each individual UI operation.
249
+
250
+ ## Sending Commands with the Initial HTML
251
+
252
+ When WebForms Core commands need to be sent together with the initial HTML document, you can use `export_to_html_comment` instead of `response`.
253
+
254
+ `export_to_html_comment` embeds the generated WebForms Core commands in an HTML comment. WebFormsJS detects these commands when the HTML document is loaded and executes them in the browser.
255
+
256
+ For example:
147
257
 
148
- The initial `GET` request and subsequent `POST` request therefore have different purposes. The initial request renders the page, while the POST request can return WebForms Core commands to update the existing HTML.
258
+ ```ruby
259
+ require "wfc"
260
+
261
+ include WebFormsCore
149
262
 
150
- ### WebFormsJS
263
+ form = WebForms.new
151
264
 
152
- WebFormsJS is the client-side runtime that executes WebForms Core commands in the browser.
265
+ form.set_background_color(
266
+ InputPlace.tag("body"),
267
+ "lightblue"
268
+ )
269
+ ```
153
270
 
154
- Add the WebFormsJS script to the `<head>` section of your view:
271
+ The generated commands can then be included in the HTML response using:
272
+
273
+ ```ruby
274
+ form.export_to_html_comment
275
+ ```
276
+
277
+ For example:
155
278
 
156
279
  ```html
157
- <script type="text/javascript" src="/script/web-forms.js"></script>
280
+ <!DOCTYPE html>
281
+ <html>
282
+ <head>
283
+ <title>WebForms Core</title>
284
+ <script type="module" src="/script/web-forms.js"></script>
285
+ </head>
286
+ <body>
287
+ <h1>Hello World!</h1>
288
+ </body>
289
+ </html>
290
+ <%= form.export_to_html_comment %>
158
291
  ```
159
292
 
160
- The latest WebFormsJS source is available in the [WebForms repository](https://github.com/elanatframework/Web_forms/blob/elanat_framework/web-forms.js).
293
+ The generated WebForms Core commands are embedded in the HTML response itself. When WebFormsJS loads, it detects the commands in the HTML comment and executes them on the DOM.
161
294
 
162
- ## WebForms Core Architecture
295
+ Use `response` when returning WebForms Core commands as a response to a request. Use `export_to_html_comment` when the commands need to be included directly in the HTML document, such as during the initial page load.
296
+
297
+ ## Commander and Executor
298
+
299
+ The `WebForms` class is the **Commander**. It generates WebForms Core commands that describe operations to be performed on the HTML document.
300
+
301
+ For example:
163
302
 
164
- WebForms Core separates server-side command generation from client-side command execution.
303
+ ```ruby
304
+ form = WebForms.new
305
+
306
+ form.add_tag(
307
+ InputPlace.tag("body"),
308
+ "h3"
309
+ )
310
+
311
+ form.set_text(
312
+ InputPlace.tag("h3"),
313
+ "Hello World!"
314
+ )
315
+
316
+ form.set_background_color(
317
+ InputPlace.tag("body"),
318
+ "lightblue"
319
+ )
320
+
321
+ puts form.response
322
+ ```
323
+
324
+ The Commander does not directly manipulate the browser DOM. It generates the WebForms Core response that is sent to the client.
325
+
326
+ **WebFormsJS** is the **Executor**. It receives WebForms Core commands from the server and executes them in the browser.
327
+
328
+ ```text
329
+ WebForms Core
330
+ │
331
+ ┌──────────┴──────────┐
332
+ │ │
333
+ Commander Executor
334
+ │ │
335
+ Ruby WFC WebFormsJS
336
+ │ web-forms.js
337
+ │ │
338
+ Generates commands ──► Executes commands
339
+ │
340
+ ▼
341
+ Browser DOM
342
+ ```
343
+
344
+ The **Commander describes what should happen**.
345
+
346
+ The **Executor performs those commands in the browser**.
165
347
 
166
- * **WebForms** runs on the server and generates commands.
167
- * **WebFormsJS** runs in the browser and executes those commands.
168
- * HTML remains the primary interface.
169
- * No virtual DOM is required.
170
- * No client-side component framework is required.
348
+ WebForms Core uses a **command-driven flow** and a **stateless server architecture**. The same WebForms Core programming model can be used across different programming languages and server-side environments.
171
349
 
172
- The Ruby implementation provides the server-side WebForms Core API.
350
+ WebForms Core is available for web development in all major web programming languages.
351
+
352
+ ## WebFormsJS
353
+
354
+ WebFormsJS is the client-side JavaScript **Executor** of WebForms Core.
355
+
356
+ The latest WebFormsJS Executor is available here:
357
+
358
+ - WebFormsJS on Elanat: https://elanat.net/webforms-js
359
+ - WebFormsJS on GitHub: https://github.com/webforms-core/WebFormsJS
360
+
361
+ The npm package is also available:
362
+
363
+ https://www.npmjs.com/package/webformsjs
364
+
365
+ Install using npm:
366
+
367
+ ```bash
368
+ npm install webformsjs
369
+ ```
173
370
 
174
371
  ## Development
175
372
 
@@ -199,7 +396,7 @@ gem install ./wfc-*.gem
199
396
 
200
397
  ## Source Code
201
398
 
202
- The WebForms Core source code is available in the [WebForms Core classes repository](https://github.com/webforms-core/Web_forms_classes).
399
+ The WebForms Core source code is available in the [WebForms Core classes repository](https://github.com/webforms-core/WebFormsClasses).
203
400
 
204
401
  ## License
205
402
 
data/lib/web_forms.rb CHANGED
@@ -1,5 +1,5 @@
1
- # web_forms.rb 2.1 - The Back-End Part of WebForms Core Technology, Owned by Elanat (https://elanat.net)
2
- # Compatible with WebFormsJS version 2.1
1
+ # web_forms.rb 2.2 - The Back-End Part of WebForms Core Technology, Owned by Elanat (https://elanat.net)
2
+ # Compatible with WebFormsJS version 2.2
3
3
 
4
4
  module WebFormsCore
5
5
  class WebForms
@@ -269,6 +269,10 @@ module WebFormsCore
269
269
  add("ki" + input_place, index.to_s + GS + (checked ? "1" : "0"))
270
270
  end
271
271
 
272
+ def set_custom_validity(input_place, text)
273
+ add("cv" + input_place, text.gsub("\n", "$[ln];"))
274
+ end
275
+
272
276
  # Insert
273
277
  # Creates the Data only if it does not exist; otherwise, does nothing.
274
278
  def insert_id(input_place, id)
@@ -380,16 +384,16 @@ module WebFormsCore
380
384
  add("dp" + input_place)
381
385
  end
382
386
 
383
- # Tag
387
+ # Tag Transformation
384
388
  def swap_tag(input_place, output_place)
385
389
  add("sp" + input_place, output_place)
386
390
  end
387
391
 
388
- def set_reflection(input_place, tag)
392
+ def set_reflect(input_place, tag)
389
393
  add("sR" + input_place, tag)
390
394
  end
391
395
 
392
- def set_reflection_by_output_place(input_place, output_place)
396
+ def set_reflect_by_output_place(input_place, output_place)
393
397
  add("iR" + input_place, output_place)
394
398
  end
395
399
 
@@ -401,6 +405,14 @@ module WebFormsCore
401
405
  add("iM" + input_place, output_place)
402
406
  end
403
407
 
408
+ def snapshot(input_place, key = "", permanent = false)
409
+ add("rS" + input_place, ((key.nil? || key.empty?) ? input_place : key) + (permanent ? GS + "1" : ""))
410
+ end
411
+
412
+ def rollback(input_place, key = "", permanent = false)
413
+ add("rB" + input_place, ((key.nil? || key.empty?) ? input_place : key) + (permanent ? GS + "1" : ""))
414
+ end
415
+
404
416
  # Browser
405
417
  def change_url(url)
406
418
  add("cu", url)
@@ -933,6 +945,18 @@ module WebFormsCore
933
945
  add("Dc", pause ? "1" : "0")
934
946
  end
935
947
 
948
+ def try_
949
+ add("tr")
950
+ end
951
+
952
+ def catch_
953
+ add("ca")
954
+ end
955
+
956
+ def comment(text)
957
+ add("//", text)
958
+ end
959
+
936
960
  # Service Worker
937
961
  # To Use Service Worker, You Need To Add The Elanat Dedicated Module (service-worker.js) On The Client Side
938
962
  def service_worker_register(path = nil, scope_path = nil)
@@ -1023,6 +1047,10 @@ module WebFormsCore
1023
1047
  add("DS", "*")
1024
1048
  end
1025
1049
 
1050
+ def lock_queue(millisecond)
1051
+ add("lq", millisecond.to_s)
1052
+ end
1053
+
1026
1054
  # Cookie
1027
1055
  def set_cookie(key, value, seconds, path = nil)
1028
1056
  add("sC", key + GS + value + GS + seconds.to_s + (!path.nil? && !path.empty? ? GS + path : ""))
@@ -1142,6 +1170,21 @@ module WebFormsCore
1142
1170
  add("SR", cache_key + GS + value.gsub("\n", "$[ln];") + GS + search_value.gsub("\n", "$[ln];"))
1143
1171
  end
1144
1172
 
1173
+ # Is Regex Replace
1174
+ def set_format_save_value(cache_key, regex, replacement)
1175
+ add("SF", cache_key + GS + regex + GS + replacement.gsub("\n", "$[ln];"))
1176
+ end
1177
+
1178
+ # Operator: +, -, *, /, %, //, **
1179
+ def set_arithmetic_save_value(cache_key, operator, value)
1180
+ add("SM", cache_key + GS + operator + GS + value.to_s)
1181
+ end
1182
+
1183
+ # Operation: textafter, textafterlast, textbefore, textbeforelast, substring, remove
1184
+ def set_text_operation_save_value(cache_key, operation, value1, value2)
1185
+ add("ST", cache_key + GS + operation + GS + value1.to_s + GS + value2.to_s)
1186
+ end
1187
+
1145
1188
  # Cache
1146
1189
  def cache_id(input_place, key = ".")
1147
1190
  add("@ci" + input_place, key)
@@ -1259,7 +1302,22 @@ module WebFormsCore
1259
1302
  def replace_cache_value(cache_key, search_value, value)
1260
1303
  add("CR", cache_key + GS + value.gsub("\n", "$[ln];") + GS + search_value.gsub("\n", "$[ln];"))
1261
1304
  end
1262
-
1305
+
1306
+ # Is Regex Replace
1307
+ def set_format_cache_value(cache_key, regex, replacement)
1308
+ add("CF", cache_key + GS + regex + GS + replacement.gsub("\n", "$[ln];"))
1309
+ end
1310
+
1311
+ # Operator: +, -, *, /, %, //, **
1312
+ def set_arithmetic_cache_value(cache_key, operator, value)
1313
+ add("CM", cache_key + GS + operator + GS + value.to_s)
1314
+ end
1315
+
1316
+ # Operation: textafter, textafterlast, textbefore, textbeforelast, substring, remove
1317
+ def set_text_operation_cache_value(cache_key, operation, value1, value2)
1318
+ add("CT", cache_key + GS + operation + GS + value1.to_s + GS + value2.to_s)
1319
+ end
1320
+
1263
1321
  # Call
1264
1322
  def load_url(input_place, url)
1265
1323
  add("lu" + input_place, url)
@@ -1369,18 +1427,18 @@ module WebFormsCore
1369
1427
  end
1370
1428
 
1371
1429
  # Pre Runner
1372
- def assign_delay(mili_second, index = -1)
1430
+ def assign_delay(milli_second, index = -1)
1373
1431
  current_line = get_line_by_index(index)
1374
1432
  return if current_line.nil? || current_line.empty?
1375
1433
 
1376
1434
  parts = current_line.split('=', 2)
1377
- new_name = ":" + mili_second.to_s + ")" + parts[0]
1435
+ new_name = ":" + milli_second.to_s + ")" + parts[0]
1378
1436
  new_value = parts.length > 1 ? parts[1] : ""
1379
1437
 
1380
1438
  update_line_by_index(index, new_name, new_value)
1381
1439
  end
1382
1440
 
1383
- def assign_delay_change(mili_second, index = -1)
1441
+ def assign_delay_change(milli_second, index = -1)
1384
1442
  current_line = get_line_by_index(index)
1385
1443
  return if current_line.nil? || current_line.empty?
1386
1444
 
@@ -1392,24 +1450,24 @@ module WebFormsCore
1392
1450
  current_name = current_name[(closing_bracket + 1)..-1]
1393
1451
  end
1394
1452
 
1395
- new_name = ":" + mili_second.to_s + ")" + current_name
1453
+ new_name = ":" + milli_second.to_s + ")" + current_name
1396
1454
  new_value = parts.length > 1 ? parts[1] : ""
1397
1455
 
1398
1456
  update_line_by_index(index, new_name, new_value)
1399
1457
  end
1400
1458
 
1401
- def assign_interval(mili_second, id = nil, index = -1)
1459
+ def assign_interval(milli_second, id = nil, index = -1)
1402
1460
  current_line = get_line_by_index(index)
1403
1461
  return if current_line.nil? || current_line.empty?
1404
1462
 
1405
1463
  parts = current_line.split('=', 2)
1406
- new_name = "(" + mili_second.to_s + (!id.nil? && !id.empty? ? "|" + id : "") + ")" + parts[0]
1464
+ new_name = "(" + milli_second.to_s + (!id.nil? && !id.empty? ? "|" + id : "") + ")" + parts[0]
1407
1465
  new_value = parts.length > 1 ? parts[1] : ""
1408
1466
 
1409
1467
  update_line_by_index(index, new_name, new_value)
1410
1468
  end
1411
1469
 
1412
- def assign_interval_change(mili_second, id = nil, index = -1)
1470
+ def assign_interval_change(milli_second, id = nil, index = -1)
1413
1471
  current_line = get_line_by_index(index)
1414
1472
  return if current_line.nil? || current_line.empty?
1415
1473
 
@@ -1421,7 +1479,7 @@ module WebFormsCore
1421
1479
  current_name = current_name[(closing_bracket + 1)..-1]
1422
1480
  end
1423
1481
 
1424
- new_name = "(" + mili_second.to_s + (!id.nil? && !id.empty? ? "|" + id : "") + ")" + current_name
1482
+ new_name = "(" + milli_second.to_s + (!id.nil? && !id.empty? ? "|" + id : "") + ")" + current_name
1425
1483
  new_value = parts.length > 1 ? parts[1] : ""
1426
1484
 
1427
1485
  update_line_by_index(index, new_name, new_value)
@@ -1646,13 +1704,11 @@ module WebFormsCore
1646
1704
  self
1647
1705
  end
1648
1706
 
1649
- # 'break' is a reserved keyword in Ruby, so 'wf_break' is used to preserve API intent without syntax errors.
1650
- def wf_break
1707
+ def break_
1651
1708
  add(";")
1652
1709
  end
1653
1710
 
1654
- # 'else' is a reserved keyword in Ruby, so 'wf_else' is used to preserve API intent without syntax errors.
1655
- def wf_else
1711
+ def else_
1656
1712
  add("}e")
1657
1713
  self
1658
1714
  end
@@ -1665,8 +1721,9 @@ module WebFormsCore
1665
1721
  add("}")
1666
1722
  end
1667
1723
 
1724
+ # High-Level Methods
1668
1725
  # Used Then In Condition And Loop Methods
1669
- def then_form(new_form = nil, &block)
1726
+ def then_(new_form = nil, &block)
1670
1727
  if block_given?
1671
1728
  new_form = WebForms.new
1672
1729
  yield new_form
@@ -1687,45 +1744,108 @@ module WebFormsCore
1687
1744
  self
1688
1745
  end
1689
1746
 
1690
- def repeat_form(new_form = nil, repeat = 1, index = nil, &block)
1691
- if block_given?
1692
- temp_form = WebForms.new
1693
- yield temp_form
1694
- return repeat_form(temp_form, repeat, index)
1695
- end
1747
+ def repeat(new_form = nil, repeat_count = 1, index = nil, &block)
1748
+ if block_given?
1749
+ temp_form = WebForms.new
1750
+ yield temp_form
1751
+ return repeat(temp_form, repeat_count, index)
1752
+ end
1696
1753
 
1697
- return self if new_form.nil?
1754
+ return self if new_form.nil?
1698
1755
 
1699
- if !index.nil?
1700
- go_to(index)
1701
- start_index(index)
1702
- end
1756
+ if index.nil?
1757
+ body_data = new_form.get_web_forms_data
1758
+ return self if body_data.nil? || body_data.empty?
1703
1759
 
1704
- body_data = new_form.get_web_forms_data
1760
+ start_line = body_data.split("\n", -1).length * -1
1761
+ append_form(new_form)
1762
+ go_to(start_line, repeat_count - 1)
1763
+ else
1764
+ go_to(index)
1765
+ start_index(index)
1705
1766
 
1706
- return self if body_data.nil? || body_data.empty?
1767
+ body_data = new_form.get_web_forms_data
1768
+ return self if body_data.nil? || body_data.empty?
1707
1769
 
1708
- if index.nil?
1709
- start_line = body_data.split("\n", -1).length * -1
1710
- append_form(new_form)
1711
- go_to(start_line, repeat - 1)
1712
- else
1713
- append_form(new_form)
1714
- go_to(index, repeat - 1)
1715
- end
1770
+ append_form(new_form)
1716
1771
 
1717
- self
1718
- end
1772
+ if index.empty?
1773
+ index_number = -1
1774
+ get_web_forms_data.split("\n").each do |x|
1775
+ index_number += 1 if x.start_with?("#")
1776
+ end
1777
+ go_to(index_number.to_s, repeat_count - 1)
1778
+ else
1779
+ go_to(index, repeat_count - 1)
1780
+ end
1781
+ end
1782
+
1783
+ self
1784
+ end
1785
+
1786
+ def isole(new_form = nil, input_place = nil, &block)
1787
+ if block_given?
1788
+ temp_form = WebForms.new
1789
+ yield temp_form
1790
+ return isole(temp_form, input_place)
1791
+ end
1792
+
1793
+ return self if new_form.nil?
1794
+
1795
+ body_data = new_form.get_web_forms_data
1796
+ return self if body_data.nil? || body_data.empty?
1797
+
1798
+ form = WebForms.new
1799
+ form.start_transient_dom(input_place)
1800
+
1801
+ append_form(form)
1802
+ new_form.end_transient_dom
1803
+ append_form(new_form)
1804
+
1805
+ self
1806
+ end
1807
+
1808
+ # The Render Method is Sensitive to DOM Changes; It is Recommended to Assign a Stable ID to the Selected Element.
1809
+ # This Method Utilizes the Transient DOM; Therefore, When Selecting InputPlaces, You Must Consider the Root of the Selected InputPlace Within the Method.
1810
+ def render(new_form = nil, input_place = nil, key = "", permanent = false, &block)
1811
+ if block_given?
1812
+ temp_form = WebForms.new
1813
+ yield temp_form
1814
+ return render(temp_form, input_place, key, permanent)
1815
+ end
1816
+
1817
+ return self if new_form.nil?
1818
+
1819
+ body_data = new_form.get_web_forms_data
1820
+ return self if body_data.nil? || body_data.empty?
1821
+
1822
+ key = input_place if key.nil? || key.empty?
1823
+
1824
+ form = WebForms.new
1825
+
1826
+ form.exist(permanent ? Fetch.cache(key) : Fetch.save(key))
1827
+ form.rollback(input_place, key, permanent)
1828
+ form.else_
1829
+ form.snapshot(input_place, key, permanent)
1830
+
1831
+ form.start_transient_dom(input_place)
1832
+
1833
+ append_form(form)
1834
+ new_form.end_transient_dom
1835
+ append_form(new_form)
1836
+
1837
+ self
1838
+ end
1719
1839
 
1720
1840
  # Async
1721
1841
  # It Supports Brackets and Then
1722
- def async_action
1842
+ def async_
1723
1843
  add("{(a)")
1724
1844
  self
1725
1845
  end
1726
1846
 
1727
- def delay(mili_second)
1728
- add("De", mili_second.to_s)
1847
+ def delay(milli_second)
1848
+ add("De", milli_second.to_s)
1729
1849
  end
1730
1850
 
1731
1851
  # Option
@@ -2104,7 +2224,7 @@ module WebFormsCore
2104
2224
  end
2105
2225
 
2106
2226
  # MethodName: The Method Name May Need to Include the Class Name, Separated by a Period. Example: MyClassName.MyMethodName
2107
- def self.wasm_method(wasm_language, wasm_url, method_name, args = nil, key = ".")
2227
+ def self.wasm_method(wasm_language, wasm_url, method_name, args = nil)
2108
2228
  return_value = "@wA" + wasm_language + RS + wasm_url + RS + method_name
2109
2229
  if !args.nil? && args.is_a?(Array)
2110
2230
  return_value += (args.length > 0) ? RS + args.join(US) : ""
@@ -2166,7 +2286,7 @@ module WebFormsCore
2166
2286
  return_value
2167
2287
  end
2168
2288
 
2169
- # Data
2289
+ # Date
2170
2290
  def self.date_year = "@dy"
2171
2291
  # Month In JavaScript Is Start From Index 0, Month In WebForms Core Is Start From Index 1
2172
2292
  def self.date_month = "@dm"
@@ -2262,7 +2382,11 @@ module WebFormsCore
2262
2382
  "@$V" + input_place
2263
2383
  end
2264
2384
 
2265
- # Save
2385
+ def self.get_tag_hash(input_place)
2386
+ "@$H" + input_place
2387
+ end
2388
+
2389
+ # Save and Cache
2266
2390
  def self.has_hash(hash_val)
2267
2391
  "@HH" + hash_val
2268
2392
  end
@@ -2431,13 +2555,10 @@ module WebFormsCore
2431
2555
  end
2432
2556
 
2433
2557
  class WasmLanguage
2434
- # The Suffix "Mediator" Means You Must Call the JavaScript Interface. In Other Cases, the WASM File Should Be Called Directly.
2435
2558
  def self.c = "c"
2436
2559
  def self.cpp = "c"
2437
2560
  def self.rust = "rust"
2438
2561
  def self.c_sharp = "csharp"
2439
- # .NET WebCIL Container. The "dotnet.js" File Should Be Invoked.
2440
- def self.c_sharp_mediator = "csharp-m"
2441
2562
  def self.go = "go"
2442
2563
  def self.java = "java"
2443
2564
  def self.assembly_script = "as"
@@ -2633,7 +2754,7 @@ module WebFormsCore
2633
2754
  return value
2634
2755
  end
2635
2756
 
2636
- self + "?" + value.gsub("|", "$[vb];").gsub("?", "$[qu];")
2757
+ self + "?" + value.gsub("|", "$[vb];").gsub("?", "$[qu];").gsub("=", "$[eq];")
2637
2758
  end
2638
2759
 
2639
2760
  def append_fetch_replace(search_value, value)
data/lib/wfc/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wfc
4
- VERSION = "2.1.0"
5
- end
4
+ VERSION = "2.2.0"
5
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wfc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elanat
@@ -10,6 +10,8 @@ cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: WebForms Core (WFC) is a server-driven web interface technology for Ruby.
13
+ It provides the WebForms Commander for generating WebForms Core commands from Ruby
14
+ server-side applications.
13
15
  email:
14
16
  - info@elanat.net
15
17
  executables: []
@@ -23,12 +25,14 @@ files:
23
25
  - lib/wfc.rb
24
26
  - lib/wfc/version.rb
25
27
  - sig/wfc.rbs
26
- homepage: https://elanat.net/page_content/web_forms_core
28
+ homepage: https://elanat.net/webforms-core
27
29
  licenses:
28
30
  - MIT
29
31
  metadata:
30
- homepage_uri: https://elanat.net/page_content/web_forms_core
31
- source_code_uri: https://github.com/webforms-core/Web_forms_classes
32
+ homepage_uri: https://elanat.net/webforms-core
33
+ source_code_uri: https://github.com/webforms-core/WebFormsClasses
34
+ documentation_uri: https://elanat.net/page_content/documentation
35
+ bug_tracker_uri: https://github.com/webforms-core/WebFormsClasses/issues
32
36
  rdoc_options: []
33
37
  require_paths:
34
38
  - lib
@@ -45,5 +49,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
45
49
  requirements: []
46
50
  rubygems_version: 4.0.16
47
51
  specification_version: 4
48
- summary: WebForms Core technology for Ruby.
52
+ summary: WebForms Core (WFC) for Ruby.
49
53
  test_files: []