kireji 0.6.6 → 0.6.8
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/app/kireji/editor/tab-group/type.d.ts +6 -18
- package/src/app/kireji/sidebar/type.d.ts +1 -3
- package/src/build.js +13 -0
- package/src/parts/abstract/box/build.js +3 -4
- package/src/parts/abstract/box/routeID-distribute.js +1 -1
- package/src/parts/abstract/box/routeID-model-to.js +2 -4
- package/src/parts/abstract/box/type.d.ts +3 -3
- package/src/parts/abstract/part/model-set.js +1 -0
- package/src/parts/abstract/part/part.json +4 -3
- package/src/parts/abstract/part/type.d.ts +5 -11
- package/src/parts/abstract/permutation/type.d.ts +2 -10
- package/src/parts/core/client/async-install.js +63 -72
- package/src/parts/core/client/build.js +6 -2
- package/src/parts/core/client/loop-request.js +10 -0
- package/src/parts/core/client/part.json +6 -1
- package/src/parts/core/client/type.d.ts +17 -3
- package/src/parts/core/pointer/type.d.ts +4 -12
- package/src/parts/desktop/task-bar/tray/stats/button.html_.js +4 -1
- package/src/parts/desktop/task-bar/tray/stats/loop.js +1 -3
- package/src/parts/desktop/task-bar/tray/stats/type.d.ts +0 -7
- package/src/parts/desktop/task-bar/view-hydrate.js +1 -1
- package/src/parts/desktop/windows/type.d.ts +1 -3
- package/src/type.d.ts +11 -12
- package/src/loop-distribute.js +0 -2
- package/src/parts/desktop/task-bar/tray/stats/build.js +0 -5
package/package.json
CHANGED
|
@@ -28,17 +28,11 @@ declare interface IKirejiAppTabGroup
|
|
|
28
28
|
readonly permutationSizes: bigint[]
|
|
29
29
|
readonly payloadCardinality: bigint
|
|
30
30
|
readonly payloadSizes: bigint[]
|
|
31
|
-
/**
|
|
32
|
-
*
|
|
33
|
-
* The tab group's main HTML element. */
|
|
31
|
+
/** The tab group's main HTML element. @remarks Client-only */
|
|
34
32
|
readonly container: HTMLElement
|
|
35
|
-
/**
|
|
36
|
-
*
|
|
37
|
-
* The most recent tab model, as determined while populating the view (not when propagating the route ID). */
|
|
33
|
+
/** The most recent tab model, as determined while populating the view (not when propagating the route ID). @remarks Client-only */
|
|
38
34
|
readonly viewedActiveTab?: IKirejiAppTabGroupTab
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
41
|
-
* The most recent preview tab model, as determined while populating the view (not when propagating the route ID). */
|
|
35
|
+
/** The most recent preview tab model, as determined while populating the view (not when propagating the route ID). @remarks Client-only */
|
|
42
36
|
readonly viewedPreviewTab?: IKirejiAppTabGroupTab
|
|
43
37
|
/** The most recent permutation route ID, used to quickly determine if the tab arrangement has changed since the last view population. */
|
|
44
38
|
readonly viewedPermutationRouteID?: bigint
|
|
@@ -70,17 +64,11 @@ declare interface IKirejiAppTabGroupTab {
|
|
|
70
64
|
}
|
|
71
65
|
|
|
72
66
|
declare const tabGroup: IKirejiAppTabGroup
|
|
73
|
-
/** The index of the tab to render.
|
|
74
|
-
*
|
|
75
|
-
* *Only available in `close`, `point` and `renderTabHTML` methods.* */
|
|
67
|
+
/** The index of the tab to render. @remarks Only in `close`, `point` and `renderTabHTML` methods. */
|
|
76
68
|
declare const TAB_INDEX: number
|
|
77
|
-
/** The host part of the given tab.
|
|
78
|
-
*
|
|
79
|
-
* *Only available in `renderTabHTML` method.* */
|
|
69
|
+
/** The host part of the given tab. @remarks Only in `renderTabHTML` method. */
|
|
80
70
|
declare const TAB_PART: IPartAny
|
|
81
|
-
/** The filename of the given tab.
|
|
82
|
-
*
|
|
83
|
-
* *Only available in `renderTabHTML` method.* */
|
|
71
|
+
/** The filename of the given tab. @remarks Only in `renderTabHTML` method. */
|
|
84
72
|
declare const TAB_FILENAME: string
|
|
85
73
|
declare const activeTab: IKirejiAppTabGroupTab
|
|
86
74
|
declare const activePart: IPartAny
|
|
@@ -14,9 +14,7 @@ declare interface IKirejiAppSidebar
|
|
|
14
14
|
readonly "view.html": string
|
|
15
15
|
/** The part outliner currently assigned to the sidebar (resolves to a view even when the sidebar is hidden). */
|
|
16
16
|
readonly "view": IPartOutliner<IKirejiAppSidebar>
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
* Opens any closed parent folders of and scrolls (if necessary) to the element corresponding to the currently active tab. Does nothing if the sidebar is closed or there are no tabs open. */
|
|
17
|
+
/** Opens any closed parent folders of and scrolls (if necessary) to the element corresponding to the currently active tab. Does nothing if the sidebar is closed or there are no tabs open. @remarks Client-only */
|
|
20
18
|
readonly frameActiveTab(): void
|
|
21
19
|
|
|
22
20
|
// Runtime Properties.
|
package/src/build.js
CHANGED
|
@@ -78,6 +78,19 @@ function ƒ(_, compressedSubjectOrigins) {
|
|
|
78
78
|
sanitizeAttr = string => string.replaceAll(/&/g, '&').replaceAll(/"/g, '"').replaceAll(/'/g, ''').replaceAll(/</g, '<').replaceAll(/>/g, '>')
|
|
79
79
|
|
|
80
80
|
// Math Utilities
|
|
81
|
+
class Vector {
|
|
82
|
+
static magnitude(vector) {
|
|
83
|
+
return Math.hypot(...Object.values(vector))
|
|
84
|
+
}
|
|
85
|
+
static normalize(vector) {
|
|
86
|
+
const result = { ...vector }
|
|
87
|
+
const magnitude = this.magnitude(vector)
|
|
88
|
+
if (magnitude)
|
|
89
|
+
for (const dimension in vector)
|
|
90
|
+
result[dimension] = vector[dimension] / magnitude
|
|
91
|
+
return result
|
|
92
|
+
}
|
|
93
|
+
}
|
|
81
94
|
class FenwickTree {
|
|
82
95
|
static LSB = []
|
|
83
96
|
constructor(size) {
|
|
@@ -10,11 +10,10 @@ const placeLimits = []
|
|
|
10
10
|
let product = 1n
|
|
11
11
|
|
|
12
12
|
for (const dimension of dimensions) {
|
|
13
|
-
const placeLimit = BigInt(dimension)
|
|
14
13
|
placeValues.push(product)
|
|
15
|
-
placeStates.push(-
|
|
16
|
-
placeLimits.push(
|
|
17
|
-
product *=
|
|
14
|
+
placeStates.push(-1)
|
|
15
|
+
placeLimits.push(dimension)
|
|
16
|
+
product *= BigInt(dimension)
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
box.define({
|
|
@@ -4,12 +4,10 @@ if (!Array.isArray(MODEL))
|
|
|
4
4
|
if (MODEL.length !== box.placeValues.length)
|
|
5
5
|
throw new RangeError(`Model To RouteID Error: Box "${box.host}" does not support computing a route ID from an array with a different length than the number of dimensions the box has.`)
|
|
6
6
|
|
|
7
|
-
if (MODEL.some(member =>
|
|
7
|
+
if (MODEL.some(member => isNaN(member)))
|
|
8
8
|
throw new RangeError(`Model To RouteID Error: Box "${box.host}" does not support computing a route ID from an array with element(s) which are not numeric.`)
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
box.placeValues.forEach((placeValue, i) => resultRouteID += BigInt(MODEL[i]) * box.placeValues[i])
|
|
10
|
+
const resultRouteID = box.placeValues.reduce((resultRouteID, placeValue, i) => resultRouteID + BigInt(placeValue) * BigInt(Math.max(Math.min(Math.round(MODEL[i]), box.placeLimits[i] - 1), 0)), 0n)
|
|
13
11
|
|
|
14
12
|
if (resultRouteID >= part.cardinality)
|
|
15
13
|
throw new RangeError(`Model To RouteID Error: Part "${part.host}" returned a route ID that was too large (${resultRouteID}) (max ${part.cardinality}).`)
|
|
@@ -2,16 +2,16 @@ declare interface IBox<TOwner>
|
|
|
2
2
|
extends IPart<TOwner, null> {
|
|
3
3
|
|
|
4
4
|
// Serialized Properties.
|
|
5
|
-
readonly "dimensions": [
|
|
5
|
+
readonly "dimensions": [number]
|
|
6
6
|
// Runtime Properties.
|
|
7
7
|
/** The array of dimension multipliers, (the value of a unit for each of the defined dimensions) where the box is viewed as a fixed-length mixed-radix string.
|
|
8
8
|
*
|
|
9
9
|
* Used to speed up computation. */
|
|
10
10
|
readonly placeValues: bigint[]
|
|
11
11
|
/** A cache of the individual dimension values as extracted from the box's overall route ID. */
|
|
12
|
-
readonly placeStates:
|
|
12
|
+
readonly placeStates: number[]
|
|
13
13
|
/** A cache of the "dimensions" property, so that the array is not duplicated during arithmetic and so that the values are guaranteed to be bigints. */
|
|
14
|
-
readonly placeLimits:
|
|
14
|
+
readonly placeLimits: number[]
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
declare type IBoxAny =
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
part.setRouteID(part.modelToRouteID(MODEL))
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
"ROUTE_ID",
|
|
9
9
|
"DELTA = false"
|
|
10
10
|
],
|
|
11
|
+
"model-set": [
|
|
12
|
+
"MODEL"
|
|
13
|
+
],
|
|
11
14
|
"routeID-collect": [
|
|
12
15
|
"SUBPARTS",
|
|
13
16
|
"DEPTH"
|
|
@@ -62,9 +65,7 @@
|
|
|
62
65
|
"IMAGE_NAME"
|
|
63
66
|
],
|
|
64
67
|
"loop-distribute": [],
|
|
65
|
-
"loop": [
|
|
66
|
-
"TIME"
|
|
67
|
-
],
|
|
68
|
+
"loop": [],
|
|
68
69
|
"attr-point": [
|
|
69
70
|
"METHOD_NAME = 'point'",
|
|
70
71
|
"...ARGS"
|
|
@@ -43,7 +43,7 @@ declare interface IPart<TOwner, TSubpart>
|
|
|
43
43
|
readonly notify(EVENT_TYPE: string): void
|
|
44
44
|
/** Computes the cardinality of the part from its subparts and defines any other necessary properties. */
|
|
45
45
|
readonly build(): void
|
|
46
|
-
/** Calls loop on the part and then propagates the call leafward to all subparts. */
|
|
46
|
+
/** Calls `loop()` on the part and then propagates the call leafward to all subparts. */
|
|
47
47
|
readonly distributeLoop(): void
|
|
48
48
|
/** Returns the subparts that meet the condition provided by FILTER_FUNCTION. */
|
|
49
49
|
readonly filter(FILTER_FUNCTION: (subpart: TSubpart, index: number, part: IPart<TOwner, TSubpart>) => TSubpart): TSubpart[]
|
|
@@ -53,7 +53,7 @@ declare interface IPart<TOwner, TSubpart>
|
|
|
53
53
|
readonly includes(SUBPART: TSubpart): boolean
|
|
54
54
|
readonly reduce(REDUCE_FUNCTION: (result: TResult, subpart: TSubpart, index: number, part: IPart<TOwner, TSubpart>) => TResult, INITIAL_VALUE: TResult): TResult
|
|
55
55
|
/** If defined, the per-frame update method for the part. Useful for implementing game features. */
|
|
56
|
-
readonly loop?(
|
|
56
|
+
readonly loop?(): void
|
|
57
57
|
/** Performs MAP_FUNCTION on every subpart of the part and returns an array of the results. */
|
|
58
58
|
readonly map(MAP_FUNCTION: (subpart: TSubpart, index: number, part: IPart<TOwner, TSubpart>) => TResult): TResult[]
|
|
59
59
|
/** Converts the given model to a routeID without modifying the state of the part. */
|
|
@@ -158,9 +158,7 @@ declare interface IPart<TOwner, TSubpart>
|
|
|
158
158
|
/** The previous route of the part, changed at the last call to distributeRouteID or collectRouteID. */
|
|
159
159
|
readonly previousRouteID: bigint
|
|
160
160
|
readonly Property: typeof Property
|
|
161
|
-
/** The part's prototype part.
|
|
162
|
-
*
|
|
163
|
-
* *Note: The part `part.abstract.parts` does not have a prototype part.* */
|
|
161
|
+
/** The part's prototype part. @remarks The part `part.abstract.parts` does not have a prototype part. */
|
|
164
162
|
readonly prototype?: IPartAny
|
|
165
163
|
/** The current route of the part expressed as a bigint index in the virtual array of all of its routes. */
|
|
166
164
|
readonly routeID: bigint
|
|
@@ -227,13 +225,9 @@ declare function base(...args): any
|
|
|
227
225
|
declare function recurse(...args): any
|
|
228
226
|
/** Sets the current ecosystem route ID and host application as the undo point (the state the back button will return to). */
|
|
229
227
|
declare function setUndoPoint(): void
|
|
230
|
-
/** The current incoming route ID argument.
|
|
231
|
-
*
|
|
232
|
-
* *Available within distributeRouteID, setRouteID and updateRouteID methods only.* */
|
|
228
|
+
/** The current incoming route ID argument. @remarks Available within distributeRouteID, setRouteID and updateRouteID methods only. */
|
|
233
229
|
declare const ROUTE_ID: bigint
|
|
234
|
-
/** The part on which an event occurred
|
|
235
|
-
*
|
|
236
|
-
* **where available as an argument passed to a part listener callback.* */
|
|
230
|
+
/** The part on which an event occurred. @remarks Where available as an argument passed to a part listener callback. */
|
|
237
231
|
declare const SENDER: IPartAny
|
|
238
232
|
/** If on the client, returns whether or not the server-rendered view has been taken over by the client-side MVC framework. */
|
|
239
233
|
declare const hydrated: boolean | null
|
|
@@ -33,24 +33,16 @@ declare interface IPermutation<TOwner, TInstance, TModel, TSubject>
|
|
|
33
33
|
readonly supersetSize: bigint
|
|
34
34
|
/** The maximum number of instances that can exist at one time. */
|
|
35
35
|
readonly maxInstanceCount: bigint
|
|
36
|
-
|
|
37
36
|
/** A subindex representing which permutation of k instances is assigned. */
|
|
38
37
|
readonly permutationRouteID: bigint
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
41
|
-
* The most recent permutation route ID, used to quickly determine if the instance arrangement has changed since the last view population. */
|
|
38
|
+
/** The most recent permutation route ID, used to quickly determine if the instance arrangement has changed since the last view population. @remarks Client-only */
|
|
42
39
|
readonly viewedPermutationRouteID?: bigint
|
|
43
|
-
|
|
44
40
|
/** A subindex representing the combined per-instance payload data for the k instances. */
|
|
45
41
|
readonly payloadRouteID: bigint
|
|
46
|
-
|
|
47
42
|
/** The distributed instance data. */
|
|
48
43
|
readonly instances: TInstance[]
|
|
49
|
-
/**
|
|
50
|
-
*
|
|
51
|
-
* The set of viewed instance objects corresponding to the current `part.viewedPermutationRouteID`. */
|
|
44
|
+
/** The set of viewed instance objects corresponding to the current `part.viewedPermutationRouteID`. @remarks Client-only */
|
|
52
45
|
readonly viewedInstances: TInstance[]
|
|
53
|
-
|
|
54
46
|
/** A Fenwick tree that allows performant ranking and unranking of permutation indices. */
|
|
55
47
|
readonly tree: FenwickTree
|
|
56
48
|
}
|
|
@@ -3,91 +3,82 @@ await Promise.all([
|
|
|
3
3
|
worker.takeControlAsync()
|
|
4
4
|
])
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
if (+_.haltHydration && !production)
|
|
8
|
-
warn('Intentionally blocked hydration.')
|
|
9
|
-
else {
|
|
10
|
-
|
|
11
|
-
// To preview FOUC
|
|
12
|
-
if (_.hangHydration > 0 && !production)
|
|
13
|
-
logScope(0, `Intentionally hanging the main thread for ${_.hangHydration} milliseconds.`, log => {
|
|
14
|
-
const start = _.now
|
|
15
|
-
let iteration = -1, elapsedMilliseconds, remainingMilliseconds
|
|
16
|
-
do {
|
|
17
|
-
elapsedMilliseconds = Math.trunc(_.now - start)
|
|
18
|
-
const newRemainingMilliseconds = _.hangHydration - elapsedMilliseconds
|
|
19
|
-
Math.sin(iteration++)
|
|
20
|
-
if (Math.trunc(newRemainingMilliseconds / 100) !== Math.trunc(remainingMilliseconds / 100))
|
|
21
|
-
log("t: -" + newRemainingMilliseconds)
|
|
22
|
-
remainingMilliseconds = newRemainingMilliseconds
|
|
23
|
-
} while (remainingMilliseconds > 0)
|
|
24
|
-
log(`Main thread hang finished at iteration ${iteration}.`)
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
log("Defining Client-Only Methods, Globals and Default Listeners")
|
|
28
|
-
if (environment === "client") {
|
|
29
|
-
Object.assign(globalThis, {
|
|
30
|
-
Q(...args) {
|
|
31
|
-
return document.querySelector(...args)
|
|
32
|
-
},
|
|
33
|
-
inRect(pointerEvent, boundingClientRect) {
|
|
34
|
-
return pointerEvent.clientX >= boundingClientRect.left
|
|
35
|
-
&& pointerEvent.clientX <= boundingClientRect.right
|
|
36
|
-
&& pointerEvent.clientY >= boundingClientRect.top
|
|
37
|
-
&& pointerEvent.clientY <= boundingClientRect.bottom
|
|
38
|
-
},
|
|
39
|
-
setUndoPoint() {
|
|
40
|
-
_.parts.core.addressBar.setUndoPoint()
|
|
41
|
-
},
|
|
42
|
-
pointer: _.parts.core.pointer,
|
|
43
|
-
client: _.parts.core.client
|
|
44
|
-
})
|
|
6
|
+
if (!production) {
|
|
45
7
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
log("Activating Body")
|
|
53
|
-
document.body.classList.remove("unhydrated")
|
|
8
|
+
// To debug FOUC.
|
|
9
|
+
if (+_.haltHydration) {
|
|
10
|
+
warn('Intentionally blocked hydration.')
|
|
11
|
+
return
|
|
12
|
+
}
|
|
54
13
|
|
|
55
|
-
|
|
56
|
-
|
|
14
|
+
// To simulate slow loading time.
|
|
15
|
+
if (+_.hangHydration > 0) {
|
|
16
|
+
warn(`Intentionally hanging the main thread for ${_.hangHydration} milliseconds.`)
|
|
17
|
+
const start = _.now
|
|
18
|
+
while (_.hangHydration - (_.now - start) > 0)
|
|
19
|
+
Math.sin(Math.random())
|
|
20
|
+
}
|
|
21
|
+
}
|
|
57
22
|
|
|
58
|
-
|
|
59
|
-
document.addEventListener("click", pointerEvent => {
|
|
60
|
-
pointerEvent.preventDefault()
|
|
61
|
-
pointerEvent.stopPropagation()
|
|
62
|
-
}, { capture: true })
|
|
23
|
+
logScope(0, "Finalizing Hydration", log => {
|
|
63
24
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
25
|
+
log("Defining Client-Only Methods, Globals and Default Listeners")
|
|
26
|
+
Object.assign(globalThis, {
|
|
27
|
+
Q(...args) {
|
|
28
|
+
return document.querySelector(...args)
|
|
29
|
+
},
|
|
30
|
+
inRect(pointerEvent, boundingClientRect) {
|
|
31
|
+
return pointerEvent.clientX >= boundingClientRect.left
|
|
32
|
+
&& pointerEvent.clientX <= boundingClientRect.right
|
|
33
|
+
&& pointerEvent.clientY >= boundingClientRect.top
|
|
34
|
+
&& pointerEvent.clientY <= boundingClientRect.bottom
|
|
35
|
+
},
|
|
36
|
+
setUndoPoint() {
|
|
37
|
+
_.parts.core.addressBar.setUndoPoint()
|
|
38
|
+
},
|
|
39
|
+
pointer: _.parts.core.pointer,
|
|
40
|
+
client: _.parts.core.client
|
|
41
|
+
})
|
|
68
42
|
|
|
69
|
-
|
|
70
|
-
|
|
43
|
+
// Handle navigation. TODO: fix bugs here.
|
|
44
|
+
window.addEventListener("pageshow", pageTransitionEvent => {
|
|
45
|
+
log("Setting Initial State")
|
|
46
|
+
addressBar.useRoute()
|
|
71
47
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
48
|
+
log("Activating Body")
|
|
49
|
+
document.body.classList.remove("unhydrated")
|
|
75
50
|
|
|
51
|
+
debug('remove these preview classes', document.querySelectorAll(`[class^="preview-"]`))
|
|
52
|
+
})
|
|
53
|
+
globalThis.addEventListener("popstate", () => {
|
|
76
54
|
log("Setting Initial State")
|
|
77
55
|
addressBar.useRoute()
|
|
78
56
|
|
|
79
57
|
log("Activating Body")
|
|
80
58
|
document.body.classList.remove("unhydrated")
|
|
81
59
|
|
|
82
|
-
|
|
83
|
-
|
|
60
|
+
debug('remove these preview classes', document.querySelectorAll(`[class^="preview-"]`))
|
|
61
|
+
})
|
|
84
62
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
63
|
+
// Prevent normal click events to ensure the pointerdown event always takes precedence.
|
|
64
|
+
document.addEventListener("click", pointerEvent => {
|
|
65
|
+
pointerEvent.preventDefault()
|
|
66
|
+
pointerEvent.stopPropagation()
|
|
67
|
+
}, { capture: true })
|
|
89
68
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
69
|
+
log("Setting Initial State")
|
|
70
|
+
// Propagate the initial state (matched to the snapshot exactly).
|
|
71
|
+
addressBar.useRoute()
|
|
72
|
+
|
|
73
|
+
log("Activating Interaction")
|
|
74
|
+
// Enable HTML event listeners.
|
|
75
|
+
globalThis._ = _
|
|
76
|
+
// Disable pre-hydration presentation.
|
|
77
|
+
document.body.classList.remove("unhydrated")
|
|
78
|
+
// Switch to post-hydration state propagation.
|
|
79
|
+
client.hydrated = true
|
|
80
|
+
|
|
81
|
+
log("Starting Engine Loop")
|
|
82
|
+
// One-frame lag to capture refresh-rate-specific initial timestamp.
|
|
83
|
+
requestAnimationFrame(now => client.requestLoop(now))
|
|
93
84
|
})
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
hydrated: { value: false, writable: true }
|
|
1
|
+
client.define({
|
|
2
|
+
hydrated: { value: false, writable: true },
|
|
3
|
+
fps: { value: 60, writable: true },
|
|
4
|
+
now: { value: null, writable: true },
|
|
5
|
+
deltaTime: { value: null, writable: true },
|
|
6
|
+
meanFrameTime: { value: 1000 / 60, writable: true },
|
|
3
7
|
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
requestAnimationFrame(now => {
|
|
2
|
+
const deltaTime = now - REQUEST_TIME
|
|
3
|
+
// Use 60fps delta if returning to tab or heavy lag.
|
|
4
|
+
client.deltaTime = deltaTime > 100 ? (1000 / 60) : deltaTime
|
|
5
|
+
client.meanFrameTime += (client.deltaTime - client.meanFrameTime) / 20
|
|
6
|
+
client.fps = Math.round(1000 / client.meanFrameTime)
|
|
7
|
+
client.now = now
|
|
8
|
+
_.distributeLoop()
|
|
9
|
+
recurse(now)
|
|
10
|
+
})
|
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
declare interface IClient
|
|
2
2
|
extends IFacet<ICore> {
|
|
3
3
|
|
|
4
|
+
// Serialized Properties.
|
|
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
|
+
readonly requestLoop(REQUEST_TIME: DOMHighResTimeStamp): void
|
|
7
|
+
|
|
4
8
|
// Runtime Properties.
|
|
5
|
-
/** Whether or not the server-rendered page has been fully "taken over" by the client-side framework. */
|
|
9
|
+
/** 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. */
|
|
6
10
|
readonly hydrated: boolean
|
|
11
|
+
/** The averaged framerate of the application over a certain time window. @remarks Defaults to `60` before the first loop and when not in the client environment. */
|
|
12
|
+
readonly fps?: number
|
|
13
|
+
/** The current session time, aligned to the client refresh rate by `requestAnimationFrame`. @remarks Defaults to 'null' on first loop and when not in the client environment.*/
|
|
14
|
+
readonly now: number
|
|
15
|
+
/** The difference between the session time of the current frame and the session time of the previous frame. @remarks Defaults to `1000 / 60` before the first loop and when not in the client environment. */
|
|
16
|
+
readonly deltaTime: number
|
|
17
|
+
/** The average length of time each frame is on screen in milliseconds. @remarks Defaults to `1000 / 60` before the first loop and when not in the client environment. */
|
|
18
|
+
readonly meanFrameTime?: number
|
|
7
19
|
}
|
|
8
20
|
|
|
9
|
-
/** A facet which helps toggle the page style between a locked loading state (before hydration) and a fully-interactive state (after hydration). */
|
|
10
|
-
declare const client: IClient
|
|
21
|
+
/** A facet which helps toggle the page style between a locked loading state (before hydration) and a fully-interactive state (after hydration). It also starts and continues the engine loop. */
|
|
22
|
+
declare const client: IClient
|
|
23
|
+
/** The animation frame timestamp when the method was called. @remarks Only available in `client.requestLoop()`. */
|
|
24
|
+
declare const REQUEST_TIME: DOMHighResTimeStamp
|
|
@@ -36,13 +36,9 @@ declare interface IPointerConfig {
|
|
|
36
36
|
doubleClick: (pointerEvent: PointerEvent) => void,
|
|
37
37
|
/** The action that should finally execute whenever the user's pointer action is complete (whether successfully or through a native pointer event cancellation). */
|
|
38
38
|
reset: () => void,
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
41
|
-
* The pointerdown event responsible for launching the pointer session. */
|
|
39
|
+
/** The pointerdown event responsible for launching the pointer session. @remarks Required for all pointer handling. */
|
|
42
40
|
readonly POINTER_EVENT: PointerEvent,
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
45
|
-
* The target HTML element whose pointerdown listener responsible for launching the pointer session. */
|
|
41
|
+
/** The target HTML element whose pointerdown listener responsible for launching the pointer session. @remarks Required for all pointer handling. */
|
|
46
42
|
readonly TARGET_ELEMENT: HTMLElement,
|
|
47
43
|
/** Optional helper that can automate calling TARGET_ELEMENT.focus() during the pointer session. */
|
|
48
44
|
readonly focus?: "none" | "down" | "click",
|
|
@@ -51,11 +47,7 @@ declare interface IPointerConfig {
|
|
|
51
47
|
declare const pointer: IPointer
|
|
52
48
|
|
|
53
49
|
declare const POINTER_CONFIG: IPointerConfig
|
|
54
|
-
/** The pointerdown event that the current listener is reacting to.
|
|
55
|
-
*
|
|
56
|
-
* *Available only in pointerdown event listeners.* */
|
|
50
|
+
/** The pointerdown event that the current listener is reacting to. @remarks Only in pointerdown event listeners. */
|
|
57
51
|
declare const POINTER_EVENT: PointerEvent
|
|
58
|
-
/** The element that the current pointerdown event is reacting to.
|
|
59
|
-
*
|
|
60
|
-
* *Available only in pointerdown event listeners.* */
|
|
52
|
+
/** The element that the current pointerdown event is reacting to. @remarks Only in pointerdown event listeners. */
|
|
61
53
|
declare const TARGET_ELEMENT: HTMLElement
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
declare interface IStats
|
|
2
2
|
extends ITrayItem {
|
|
3
3
|
|
|
4
|
-
// Runtime Properties.
|
|
5
|
-
/** If in the client environment, the computed framerate of the application. Null otherwise. */
|
|
6
|
-
readonly fps?: number
|
|
7
|
-
/** If in the client environment, the time (taken from _.now) of the last loop evaluation. Null otherwise. */
|
|
8
|
-
readonly mark?: DOMHighResTimeStamp
|
|
9
|
-
/** If in the client environment, the average length of time each frame is on screen in milliseconds. Null otherwise. */
|
|
10
|
-
readonly meanFrameTime?: number
|
|
11
4
|
}
|
|
12
5
|
|
|
13
6
|
/** The framerate monitor, which sits in the taskbar tray. */
|
|
@@ -23,9 +23,7 @@ declare interface IDesktopWindowModel {
|
|
|
23
23
|
readonly height: number
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
/** The host of the application to render.
|
|
27
|
-
*
|
|
28
|
-
* *Only available in `renderTaskHTML` methods.* */
|
|
26
|
+
/** The host of the application to render. @remarks Only in `renderTaskHTML` methods. */
|
|
29
27
|
declare const APPLICATION_HOST: string
|
|
30
28
|
declare const INSTANCES: IDesktopWindow[]
|
|
31
29
|
declare const INSTANCE: IDesktopWindow
|
package/src/type.d.ts
CHANGED
|
@@ -50,9 +50,7 @@ declare interface IEcosystem
|
|
|
50
50
|
readonly setRoute(REQUEST_URL: string): void
|
|
51
51
|
/** Performs automated build-time unit tests to validate the state of the build. */
|
|
52
52
|
readonly validate(): void
|
|
53
|
-
/**
|
|
54
|
-
*
|
|
55
|
-
* Navigates to the given host by setting the current location. An undo point is automatically set by the browser. */
|
|
53
|
+
/** Navigates to the given host by setting the current location. An undo point is automatically set by the browser. @remarks Client-only */
|
|
56
54
|
readonly gotoApplication(HOST: string): void
|
|
57
55
|
|
|
58
56
|
// Runtime Properties.
|
|
@@ -68,15 +66,11 @@ declare interface IEcosystem
|
|
|
68
66
|
readonly landingModel: string
|
|
69
67
|
/** The routeID of the desired landing page, as computed from data parameters during the initial boot process. */
|
|
70
68
|
readonly landingRouteID: bigint
|
|
71
|
-
/** If in the client environment, an integer ID representing the application frame loop's current pending frame request. Null, otherwise. */
|
|
72
|
-
readonly frameRequest: number | null
|
|
73
69
|
/** A boolean that is set to `true` as soon as the route ID is set for the first time. */
|
|
74
70
|
readonly initialized: undefined | true
|
|
75
71
|
}
|
|
76
72
|
|
|
77
|
-
/**
|
|
78
|
-
*
|
|
79
|
-
* The serialized version should not include any values that are added during or after recursively hydrating the part tree. */
|
|
73
|
+
/** This is the root part of the ecosystem, considered the ecosystem itself. @remarks When JSON stringified, it should inline all information compiled from the git repo in node by the build process. The serialized version should not include any values that are added during or after recursively hydrating the part tree. This means that all runtime values should be non-enumerable and defined using the `define()` method. */
|
|
80
74
|
declare const _: IEcosystem
|
|
81
75
|
/** A shorthand for document.querySelector */
|
|
82
76
|
declare const Q: typeof document.querySelector
|
|
@@ -261,9 +255,7 @@ declare class MethodConstant {
|
|
|
261
255
|
/** Idempotent function that ensures that the constant and all its recursive dependencies (`requirements`) are declared (added to the source file output). Marks the constant as used. */
|
|
262
256
|
ensureDeclarationAndDependencies(): void
|
|
263
257
|
}
|
|
264
|
-
/** The incoming request url string.
|
|
265
|
-
*
|
|
266
|
-
* Available only in _.setRoute(). */
|
|
258
|
+
/** The incoming request url string. @remarks Only in _.setRoute(). */
|
|
267
259
|
declare const REQUEST_URL: string
|
|
268
260
|
/** A host-keyed map of all parts in the ecosystem. */
|
|
269
261
|
declare const partsByHost: Record<string, IPartAny>
|
|
@@ -311,4 +303,11 @@ declare class FenwickTree {
|
|
|
311
303
|
update(i: bigint, val: bigint): void
|
|
312
304
|
query(i: bigint): bigint
|
|
313
305
|
findNthAvailable(n: bigint): bigint
|
|
314
|
-
}
|
|
306
|
+
}
|
|
307
|
+
/** A utility class for handling arbitrary-length vectors. Any object with entirely numeric values can be treated as a vector. */
|
|
308
|
+
declare class Vector {
|
|
309
|
+
static magnitude(vector: IVector): number
|
|
310
|
+
static normalize(vector: IVector): IVector
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
declare type IVector = Record<string, number>
|
package/src/loop-distribute.js
DELETED