kireji 0.13.0 → 0.14.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.
- package/package.json +1 -1
- package/src/parts/abstract/part/attr-click.js +1 -0
- package/src/parts/abstract/part/part.json +4 -0
- package/src/parts/abstract/part/type.d.ts +3 -1
- package/src/parts/core/address-bar/{sync-install.js → async-install.js} +5 -1
- package/src/parts/core/client/async-install.js +1 -4
- package/src/parts/core/client/clicks-block.js +17 -0
- package/src/parts/core/client/part.json +3 -0
- package/src/parts/core/client/type.d.ts +2 -0
- package/src/parts/core/server/sync-install.js +1 -1
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
return `data-onclick="${sanitizeAttr(JSON.stringify([part.host, METHOD_NAME, ...ARGS]))}"`
|
|
@@ -33,8 +33,10 @@ declare interface IPart<TOwner, TSubpart>
|
|
|
33
33
|
readonly "runtimeReference": string
|
|
34
34
|
/** An optional display name for the part. */
|
|
35
35
|
readonly "title"?: string
|
|
36
|
-
/** Generates the attribute string that sets up an onpointerdown listener that calls `part[METHOD_NAME](event,this,...ARGS)`. */
|
|
36
|
+
/** Generates the attribute string that sets up an onpointerdown listener that calls `part[METHOD_NAME](event,this,...ARGS)`. Typically, use `pointer.handle({ ... })` within that method to react to manage complex events drag-and-drop, clicks, double clicks, etc. @remarks This approach will always use the pointer events (not click, touch or mouse events). Use `clickAttr` instead of `pointAttr` to create a traditional click event handler. */
|
|
37
37
|
readonly pointAttr(METHOD_NAME: string = "point", ...ARGS: any[])
|
|
38
|
+
/** Generates the attribute string that sets up an onclick listener that calls `part[METHOD_NAME](event,this,...ARGS)`. Using `pointAttr` with `pointer.handle({ ... })` is the preferred method of reacting to clicks but this event can be used for special cases like requesting a pointerlock, where the browser requires a proper click event. */
|
|
39
|
+
readonly clickAttr(METHOD_NAME: string = "onclick", ...ARGS: any[])
|
|
38
40
|
/** Registers a listener that calls RECEIVER[CALLBACK_NAME](this) after the event of the given type occurs. */
|
|
39
41
|
readonly attach(EVENT_TYPE: string, RECEIVER: IPartAny, CALLBACK_NAME: string): void
|
|
40
42
|
/** Unregisters the listener that calls RECEIVER[CALLBACK_NAME](this) after the event of the given type occurs. */
|
|
@@ -61,10 +61,7 @@ logScope(0, "Finalizing Hydration", log => {
|
|
|
61
61
|
})
|
|
62
62
|
|
|
63
63
|
// Prevent normal click events to ensure the pointerdown event always takes precedence.
|
|
64
|
-
document.addEventListener("click",
|
|
65
|
-
pointerEvent.preventDefault()
|
|
66
|
-
pointerEvent.stopPropagation()
|
|
67
|
-
}, { capture: true })
|
|
64
|
+
document.addEventListener("click", client.blockClicks, { capture: true })
|
|
68
65
|
|
|
69
66
|
log("Setting Initial State")
|
|
70
67
|
// Propagate the initial state (matched to the snapshot exactly).
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const clickHandler = POINTER_EVENT.target.getAttribute("data-onclick")
|
|
2
|
+
|
|
3
|
+
if (clickHandler) {
|
|
4
|
+
|
|
5
|
+
const [partHost, methodName, ...args] = JSON.parse(clickHandler)
|
|
6
|
+
const part = partsByHost[partHost]
|
|
7
|
+
|
|
8
|
+
if (part[methodName] && typeof part[methodName] === "function")
|
|
9
|
+
part[methodName](...args)
|
|
10
|
+
else
|
|
11
|
+
throw new ReferenceError(`ClickAttr Error: could not find a method called "${methodName}" on part ${partHost}.`)
|
|
12
|
+
|
|
13
|
+
return
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
POINTER_EVENT.preventDefault()
|
|
17
|
+
POINTER_EVENT.stopPropagation()
|
|
@@ -4,6 +4,8 @@ declare interface IClient
|
|
|
4
4
|
// Serialized Properties.
|
|
5
5
|
/** Requests an animation frame that distributes the loop function throughout the ecosystem and calls itself again. @remarks Can only be run on the client. */
|
|
6
6
|
readonly requestLoop(REQUEST_TIME: DOMHighResTimeStamp): void
|
|
7
|
+
/** The click event handler that is used globally on the client to prevent the click event from taking precedence over pointer events. */
|
|
8
|
+
readonly blockClicks(POINTER_EVENT: PointerEvent): void
|
|
7
9
|
|
|
8
10
|
// Runtime Properties.
|
|
9
11
|
/** Whether or not the server-rendered page has been fully "taken over" by the client-side framework. @remarks Can only become true in the client environment. */
|
|
@@ -62,7 +62,7 @@ const
|
|
|
62
62
|
|
|
63
63
|
// color.device.light = !prefersDarkMode
|
|
64
64
|
_.setRoute(`https://${host}${pathname}`)
|
|
65
|
-
status = +(host in _.menuApplications ? 200 : _.applications[host].status ??
|
|
65
|
+
status = +(host in _.menuApplications ? 200 : _.applications[host].status ?? 200)
|
|
66
66
|
const customHeaders = _.applications[host].customHeaders ?? {}
|
|
67
67
|
head = { ...indexHeader, ...customHeaders }
|
|
68
68
|
body = _['part.html']
|