Fix async lifecycle ordering, add _spa_init boot phase, update to jqhtml _load_only/_load_render_only flags

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2026-03-06 22:33:38 +00:00
parent 11c95a2886
commit d1ac456279
2718 changed files with 70593 additions and 6320 deletions

View File

@@ -17,14 +17,25 @@ import {
const OFFSET_MASK = 0x00FFFFFF;
const TYPE_SHIFT = 24;
const BLOCK_OPEN_TOKEN = 1;
const BLOCK_CLOSE_TOKEN = 2;
const balancePair = new Uint8Array(32); // 32b of memory ought to be enough for anyone (any number of tokens)
balancePair[FunctionToken] = RightParenthesis;
balancePair[LeftParenthesis] = RightParenthesis;
balancePair[LeftSquareBracket] = RightSquareBracket;
balancePair[LeftCurlyBracket] = RightCurlyBracket;
function isBlockOpenerToken(tokenType) {
return balancePair[tokenType] !== 0;
const blockTokens = new Uint8Array(32);
blockTokens[FunctionToken] = BLOCK_OPEN_TOKEN;
blockTokens[LeftParenthesis] = BLOCK_OPEN_TOKEN;
blockTokens[LeftSquareBracket] = BLOCK_OPEN_TOKEN;
blockTokens[LeftCurlyBracket] = BLOCK_OPEN_TOKEN;
blockTokens[RightParenthesis] = BLOCK_CLOSE_TOKEN;
blockTokens[RightSquareBracket] = BLOCK_CLOSE_TOKEN;
blockTokens[RightCurlyBracket] = BLOCK_CLOSE_TOKEN;
function boundIndex(index, min, max) {
return index < min ? min : index > max ? max : index;
}
export class TokenStream {
@@ -76,7 +87,7 @@ export class TokenStream {
// pop state
balanceStart = prevBalanceStart;
balanceCloseType = balancePair[offsetAndType[prevBalanceStart] >> TYPE_SHIFT];
} else if (isBlockOpenerToken(type)) { // check for FunctionToken, <(-token>, <[-token> and <{-token>
} else if (this.isBlockOpenerTokenType(type)) { // check for FunctionToken, <(-token>, <[-token> and <{-token>
// push state
balanceStart = index;
balanceCloseType = balancePair[type];
@@ -194,14 +205,53 @@ export class TokenStream {
return this.firstCharOffset;
}
getTokenEnd(tokenIndex) {
if (tokenIndex === this.tokenIndex) {
return this.tokenEnd;
}
return this.offsetAndType[boundIndex(tokenIndex, 0, this.tokenCount)] & OFFSET_MASK;
}
getTokenType(tokenIndex) {
if (tokenIndex === this.tokenIndex) {
return this.tokenType;
}
return this.offsetAndType[boundIndex(tokenIndex, 0, this.tokenCount)] >> TYPE_SHIFT;
}
substrToCursor(start) {
return this.source.substring(start, this.tokenStart);
}
isBalanceEdge(pos) {
return this.balance[this.tokenIndex] < pos;
// return this.balance[this.balance[pos]] !== this.tokenIndex;
isBlockOpenerTokenType(tokenType) {
return blockTokens[tokenType] === BLOCK_OPEN_TOKEN;
}
isBlockCloserTokenType(tokenType) {
return blockTokens[tokenType] === BLOCK_CLOSE_TOKEN;
}
getBlockTokenPairIndex(tokenIndex) {
const type = this.getTokenType(tokenIndex);
if (blockTokens[type] === 1) {
// block open token
const pairIndex = this.balance[tokenIndex];
const closeType = this.getTokenType(pairIndex);
return balancePair[type] === closeType ? pairIndex : -1;
} else if (blockTokens[type] === 2) {
// block close token
const pairIndex = this.balance[tokenIndex];
const openType = this.getTokenType(pairIndex);
return balancePair[openType] === type ? pairIndex : -1;
}
return -1;
}
isBalanceEdge(tokenIndex) {
return this.balance[this.tokenIndex] < tokenIndex;
}
isDelim(code, offset) {
if (offset) {
return (
@@ -278,7 +328,7 @@ export class TokenStream {
default:
// fast forward to the end of balanced block for an open block tokens
if (isBlockOpenerToken(this.offsetAndType[cursor] >> TYPE_SHIFT)) {
if (this.isBlockOpenerTokenType(this.offsetAndType[cursor] >> TYPE_SHIFT)) {
cursor = balanceEnd;
}
}