Skip to content

Commit 47a88fc

Browse files
author
Johan Brichau
authored
Merge pull request #1444 from marschall/web-components-improvements
Improvements for Web Components
2 parents 0f7d6f7 + f6be4f2 commit 47a88fc

File tree

33 files changed

+174
-5
lines changed

33 files changed

+174
-5
lines changed

repository/Seaside-Session.package/WASessionContinuation.class/instance/handle..st

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ handling
22
handle: aRequestContext
33
"Resume processing of a request. To ensure valid application state restore all registered states."
44

5-
self states restore.
5+
self restoreState.
66
self withUnregisteredHandlerDo: [ super handle: aRequestContext ]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
processing
2+
restoreState
3+
4+
self states restore

repository/Seaside-Tests-WebComponents.package/WASingleElementCacheTest.class/README.md

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
private
2+
createCache
3+
^ WASingleElementCache new
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
testing
2+
testClear
3+
cache at: 1 put: 'one'.
4+
cache clear.
5+
self assert: (cache at: 1 ifAbsent: [ 'two' ]) equals: 'two'.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
testing
2+
testKeyAtValue
3+
cache at: 1 put: 'one'.
4+
self assert: (cache keyAtValue: 'one' ifAbsent: [ 2 ]) equals: 1.
5+
self assert: (cache keyAtValue: 'two' ifAbsent: [ 2 ]) equals: 2.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
testing
2+
testKeysAndValuesDo
3+
| reference readBack |
4+
reference := Dictionary new.
5+
6+
cache at: 1 put: 'one'.
7+
reference at: 1 put: 'one'.
8+
9+
readBack := Dictionary new.
10+
cache keysAndValuesDo: [ :key :value |
11+
readBack at: key put: value ].
12+
13+
self assert: readBack equals: reference
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
testing
2+
testSize
3+
self assert: cache size equals: 0.
4+
cache at: 1 put: 'one'.
5+
self assert: cache size equals: 1.
6+
cache at: 2 put: 'two'.
7+
self assert: cache size equals: 1.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
testing
2+
testStore
3+
| generator |
4+
generator := WAPrecomputedKeyGenerator keys: #(1 2 3).
5+
WAKeyGenerator
6+
use: generator
7+
during: [
8+
self assert: (cache store: 'key1') equals: 1.
9+
self assert: (cache store: 'key2') equals: 2.
10+
self assert: (cache store: 'key3') equals: 3 ]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"commentStamp" : "",
3+
"super" : "WACacheTest",
4+
"category" : "Seaside-Tests-WebComponents",
5+
"classinstvars" : [ ],
6+
"pools" : [ ],
7+
"classvars" : [ ],
8+
"instvars" : [ ],
9+
"name" : "WASingleElementCacheTest",
10+
"type" : "normal"
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
I am a session that stores only a single continuation. I am usesful for cases where state snapshots are not used.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
initialization
2+
createContinuationCache
3+
^ WASingleElementCache new
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"commentStamp" : "xxx 7/11/2024 13:25",
3+
"super" : "WASession",
4+
"category" : "Seaside-WebComponents-Core",
5+
"classinstvars" : [ ],
6+
"pools" : [ ],
7+
"classvars" : [ ],
8+
"instvars" : [ ],
9+
"name" : "WASingleContinuationSession",
10+
"type" : "normal"
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
I am a cache that contains at most one element.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
accessing
2+
at: aKey ifAbsent: aBlock
3+
^ key = aKey
4+
ifTrue: [ value ]
5+
ifFalse: [ aBlock value ]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
putting
2+
at: aKey put: anObject
3+
key := aKey.
4+
value := anObject.
5+
^ anObject
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
public
2+
clear
3+
key := nil.
4+
value := nil
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
accessing
2+
keyAtValue: anObject ifAbsent: aBlock
3+
^ value = anObject
4+
ifTrue: [ key ]
5+
ifFalse: [ aBlock value ]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
enumerating
2+
keysAndValuesDo: aTwoArgumentBlock
3+
key isNil ifFalse: [
4+
aTwoArgumentBlock value: key value: value ]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
removing
2+
remove: anObject
3+
value = anObject ifTrue: [
4+
key := nil.
5+
value := nil ]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
accessing
2+
size
3+
^ key isNil
4+
ifTrue: [ 0 ]
5+
ifFalse: [ 1 ]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
putting
2+
store: anObject
3+
key := WAKeyGenerator current keyOfLength: self keySize.
4+
value := anObject.
5+
^ key
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"commentStamp" : "xxx 7/11/2024 10:46",
3+
"super" : "WACache",
4+
"category" : "Seaside-WebComponents-Core",
5+
"classinstvars" : [ ],
6+
"pools" : [ ],
7+
"classvars" : [ ],
8+
"instvars" : [
9+
"key",
10+
"value"
11+
],
12+
"name" : "WASingleElementCache",
13+
"type" : "normal"
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
I am a special action continuation with optimizations for web components.
2+
3+
Since web components have no back button and a full page reload results in an entire new page I perform the following optimizations.
4+
5+
- I do not redirect.
6+
- I do not capture the state.
7+
- I do not restore the state.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
processing
2+
basicPerformAction
3+
super basicPerformAction.
4+
self renderContext callbacks handle: self requestContext
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
processing
2+
continue
3+
"do not capture state"
4+
self createRenderContinuation handle: self requestContext
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public
2+
jumpToAnchor: aString
3+
"Intentionally empty for compatibility with WACallbackProcessingActionContinuation"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
processing
2+
restoreState
3+
"don't restore states"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
private
2+
shouldRedirect
3+
^ false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"commentStamp" : "xxx 7/11/2024 13:24",
3+
"super" : "WAActionPhaseContinuation",
4+
"category" : "Seaside-WebComponents-Core",
5+
"classinstvars" : [ ],
6+
"pools" : [ ],
7+
"classvars" : [ ],
8+
"instvars" : [ ],
9+
"name" : "WAWebComponentActionContinuation",
10+
"type" : "normal"
11+
}

repository/Seaside-WebComponents-Core.package/WAWebComponentsLibrary.class/instance/seasideWebComponentsJs.st

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ seasideWebComponentsJs
3737
#load(method, url, data) {
3838
const xhr = new XMLHttpRequest();
3939
40-
xhr.responseType = "text"; // we do not stirp anyhing, just use innerHtml
40+
xhr.responseType = "text"; // we do not strip anyhing, just use innerHtml
4141
xhr.addEventListener("load", (event) => {
4242
if (xhr.status === 200) {
4343
this.#shadowRoot.innerHTML = xhr.response;

repository/Seaside-WebComponents-Examples.package/WAHeadlessCounter.class/class/initialize.st

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@ initialize
44
"register such that we do not have the developer tools"
55
application := WAAdmin register: WAApplication at: 'examples/headless-counter' in: WAAdmin defaultDispatcher.
66
application configuration addParent: WARenderLoopConfiguration instance.
7-
application rootClass: self.
8-
application preferenceAt: #renderPhaseContinuationClass put: WAFragmentRenderPhaseContinuation
7+
application
8+
rootClass: self;
9+
sessionClass: WASingleContinuationSession;
10+
preferenceAt: #renderPhaseContinuationClass put: WAFragmentRenderPhaseContinuation;
11+
preferenceAt: #actionPhaseContinuationClass put: WAWebComponentActionContinuation
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
initialization
22
initialize
3-
(WAAdmin register: self asApplicationAt: 'examples/web-components')
3+
| application |
4+
"register such that we do not have the developer tools"
5+
application := WAAdmin register: WAApplication at: 'examples/web-components' in: WAAdmin defaultDispatcher.
6+
application configuration addParent: WARenderLoopConfiguration instance.
7+
application
8+
rootClass: self;
49
scriptGeneratorClass: WANullScriptGenerator

0 commit comments

Comments
 (0)