diff --git a/.publish/ai/package.json b/.publish/ai/package.json index 29c133f0..3e786bc2 100644 --- a/.publish/ai/package.json +++ b/.publish/ai/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/ai", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "Zero-dependency Claude (Anthropic) client for WrNexus apps.", "license": "MIT", diff --git a/.publish/authz/package.json b/.publish/authz/package.json index 44da127d..568ba0d1 100644 --- a/.publish/authz/package.json +++ b/.publish/authz/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/authz", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "@wrnexus/authz — part of the WrNexus framework.", "license": "MIT", diff --git a/.publish/cli/package.json b/.publish/cli/package.json index c1146d0c..0e6145ce 100644 --- a/.publish/cli/package.json +++ b/.publish/cli/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/cli", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "@wrnexus/cli — part of the WrNexus framework.", "license": "MIT", @@ -28,16 +28,16 @@ "wrnexus": "./dist/index.js" }, "dependencies": { - "@wrnexus/core": "^0.2.42", - "@wrnexus/router": "^0.2.42", - "@wrnexus/csr": "^0.2.42", - "@wrnexus/compiler": "^0.2.42", - "@wrnexus/styles": "^0.2.42", - "@wrnexus/dev-server": "^0.2.42", - "@wrnexus/ui": "^0.2.42", - "@wrnexus/validation": "^0.2.42", - "@wrnexus/i18n": "^0.2.42", - "@wrnexus/db": "^0.2.42" + "@wrnexus/core": "^0.2.43", + "@wrnexus/router": "^0.2.43", + "@wrnexus/csr": "^0.2.43", + "@wrnexus/compiler": "^0.2.43", + "@wrnexus/styles": "^0.2.43", + "@wrnexus/dev-server": "^0.2.43", + "@wrnexus/ui": "^0.2.43", + "@wrnexus/validation": "^0.2.43", + "@wrnexus/i18n": "^0.2.43", + "@wrnexus/db": "^0.2.43" }, "files": [ "dist" diff --git a/.publish/compiler/package.json b/.publish/compiler/package.json index 06731b55..e063223e 100644 --- a/.publish/compiler/package.json +++ b/.publish/compiler/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/compiler", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "@wrnexus/compiler — part of the WrNexus framework.", "license": "MIT", diff --git a/.publish/core/package.json b/.publish/core/package.json index 2137e233..fc85cf05 100644 --- a/.publish/core/package.json +++ b/.publish/core/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/core", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "@wrnexus/core — part of the WrNexus framework.", "license": "MIT", diff --git a/.publish/csr/package.json b/.publish/csr/package.json index af943840..20a2d9ce 100644 --- a/.publish/csr/package.json +++ b/.publish/csr/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/csr", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "@wrnexus/csr — part of the WrNexus framework.", "license": "MIT", @@ -21,7 +21,7 @@ } }, "dependencies": { - "@wrnexus/core": "^0.2.42" + "@wrnexus/core": "^0.2.43" }, "files": [ "dist" diff --git a/.publish/db/package.json b/.publish/db/package.json index f95c75d9..a1632670 100644 --- a/.publish/db/package.json +++ b/.publish/db/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/db", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "@wrnexus/db — part of the WrNexus framework.", "license": "MIT", diff --git a/.publish/dev-server/package.json b/.publish/dev-server/package.json index 4ee704ea..a1db2f95 100644 --- a/.publish/dev-server/package.json +++ b/.publish/dev-server/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/dev-server", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "@wrnexus/dev-server — part of the WrNexus framework.", "license": "MIT", @@ -25,18 +25,18 @@ } }, "dependencies": { - "@wrnexus/core": "^0.2.42", - "@wrnexus/router": "^0.2.42", - "@wrnexus/ssr": "^0.2.42", - "@wrnexus/csr": "^0.2.42", - "@wrnexus/compiler": "^0.2.42", - "@wrnexus/styles": "^0.2.42", - "@wrnexus/ui": "^0.2.42", - "@wrnexus/validation": "^0.2.42", - "@wrnexus/i18n": "^0.2.42", - "@wrnexus/db": "^0.2.42", - "@wrnexus/pubsub": "^0.2.42", - "@wrnexus/uploader": "^0.2.42" + "@wrnexus/core": "^0.2.43", + "@wrnexus/router": "^0.2.43", + "@wrnexus/ssr": "^0.2.43", + "@wrnexus/csr": "^0.2.43", + "@wrnexus/compiler": "^0.2.43", + "@wrnexus/styles": "^0.2.43", + "@wrnexus/ui": "^0.2.43", + "@wrnexus/validation": "^0.2.43", + "@wrnexus/i18n": "^0.2.43", + "@wrnexus/db": "^0.2.43", + "@wrnexus/pubsub": "^0.2.43", + "@wrnexus/uploader": "^0.2.43" }, "files": [ "dist" diff --git a/.publish/encryption/package.json b/.publish/encryption/package.json index daa6a8ba..e22f2ce6 100644 --- a/.publish/encryption/package.json +++ b/.publish/encryption/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/encryption", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "@wrnexus/encryption — part of the WrNexus framework.", "license": "MIT", diff --git a/.publish/helpers/package.json b/.publish/helpers/package.json index 2c1eb1b9..5a4bba82 100644 --- a/.publish/helpers/package.json +++ b/.publish/helpers/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/helpers", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "Safe convenience helpers for WrNexus request contexts and common application flows.", "license": "MIT", @@ -21,7 +21,7 @@ } }, "dependencies": { - "@wrnexus/core": "^0.2.42" + "@wrnexus/core": "^0.2.43" }, "files": [ "dist" diff --git a/.publish/i18n/package.json b/.publish/i18n/package.json index f9c13b41..4e2a0b0a 100644 --- a/.publish/i18n/package.json +++ b/.publish/i18n/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/i18n", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "@wrnexus/i18n — part of the WrNexus framework.", "license": "MIT", @@ -21,7 +21,7 @@ } }, "dependencies": { - "@wrnexus/core": "^0.2.42" + "@wrnexus/core": "^0.2.43" }, "files": [ "dist" diff --git a/.publish/jwt/package.json b/.publish/jwt/package.json index fd3d696e..630ec575 100644 --- a/.publish/jwt/package.json +++ b/.publish/jwt/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/jwt", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "@wrnexus/jwt — part of the WrNexus framework.", "license": "MIT", diff --git a/.publish/mobile/package.json b/.publish/mobile/package.json index 1d02b0bf..ef191d5f 100644 --- a/.publish/mobile/package.json +++ b/.publish/mobile/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/mobile", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "@wrnexus/mobile — part of the WrNexus framework.", "license": "MIT", @@ -21,7 +21,7 @@ } }, "dependencies": { - "@wrnexus/native": "^0.2.42" + "@wrnexus/native": "^0.2.43" }, "files": [ "dist" diff --git a/.publish/native/package.json b/.publish/native/package.json index f1f75f2f..f7df07ec 100644 --- a/.publish/native/package.json +++ b/.publish/native/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/native", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "@wrnexus/native — part of the WrNexus framework.", "license": "MIT", diff --git a/.publish/oauth/package.json b/.publish/oauth/package.json index 62718f74..b984dcb8 100644 --- a/.publish/oauth/package.json +++ b/.publish/oauth/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/oauth", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "@wrnexus/oauth — part of the WrNexus framework.", "license": "MIT", diff --git a/.publish/pubsub/package.json b/.publish/pubsub/package.json index efc68746..6065372d 100644 --- a/.publish/pubsub/package.json +++ b/.publish/pubsub/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/pubsub", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "@wrnexus/pubsub — part of the WrNexus framework.", "license": "MIT", diff --git a/.publish/queue/package.json b/.publish/queue/package.json index c99656f3..551223d1 100644 --- a/.publish/queue/package.json +++ b/.publish/queue/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/queue", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "@wrnexus/queue — part of the WrNexus framework.", "license": "MIT", diff --git a/.publish/reactive/package.json b/.publish/reactive/package.json index 842cc47f..8a7f5d19 100644 --- a/.publish/reactive/package.json +++ b/.publish/reactive/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/reactive", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "@wrnexus/reactive — part of the WrNexus framework.", "license": "MIT", diff --git a/.publish/router/package.json b/.publish/router/package.json index 8caab505..d5e22f9a 100644 --- a/.publish/router/package.json +++ b/.publish/router/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/router", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "@wrnexus/router — part of the WrNexus framework.", "license": "MIT", @@ -21,8 +21,8 @@ } }, "dependencies": { - "@wrnexus/compiler": "^0.2.42", - "@wrnexus/core": "^0.2.42" + "@wrnexus/compiler": "^0.2.43", + "@wrnexus/core": "^0.2.43" }, "files": [ "dist" diff --git a/.publish/ssr/package.json b/.publish/ssr/package.json index 68e90064..8b39e4bc 100644 --- a/.publish/ssr/package.json +++ b/.publish/ssr/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/ssr", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "@wrnexus/ssr — part of the WrNexus framework.", "license": "MIT", @@ -21,7 +21,7 @@ } }, "dependencies": { - "@wrnexus/core": "^0.2.42" + "@wrnexus/core": "^0.2.43" }, "files": [ "dist" diff --git a/.publish/styles/package.json b/.publish/styles/package.json index f3839bb7..b002a606 100644 --- a/.publish/styles/package.json +++ b/.publish/styles/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/styles", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "@wrnexus/styles — part of the WrNexus framework.", "license": "MIT", @@ -21,7 +21,7 @@ } }, "dependencies": { - "@wrnexus/uploader": "^0.2.42" + "@wrnexus/uploader": "^0.2.43" }, "files": [ "dist" diff --git a/.publish/test/package.json b/.publish/test/package.json index eb691b5f..88f66dc0 100644 --- a/.publish/test/package.json +++ b/.publish/test/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/test", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "@wrnexus/test — part of the WrNexus framework.", "license": "MIT", diff --git a/.publish/tracking/package.json b/.publish/tracking/package.json index ef9fd0db..566d8dae 100644 --- a/.publish/tracking/package.json +++ b/.publish/tracking/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/tracking", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "@wrnexus/tracking — part of the WrNexus framework.", "license": "MIT", diff --git a/.publish/ui/package.json b/.publish/ui/package.json index 8381c87d..d4793787 100644 --- a/.publish/ui/package.json +++ b/.publish/ui/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/ui", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "@wrnexus/ui — part of the WrNexus framework.", "license": "MIT", @@ -22,7 +22,7 @@ "./ui.css": "./ui.css" }, "dependencies": { - "@wrnexus/core": "^0.2.42" + "@wrnexus/core": "^0.2.43" }, "files": [ "dist", diff --git a/.publish/uploader/package.json b/.publish/uploader/package.json index 52ce028b..639bf729 100644 --- a/.publish/uploader/package.json +++ b/.publish/uploader/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/uploader", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "@wrnexus/uploader — part of the WrNexus framework.", "license": "MIT", @@ -21,7 +21,7 @@ } }, "dependencies": { - "@wrnexus/core": "^0.2.42" + "@wrnexus/core": "^0.2.43" }, "files": [ "dist" diff --git a/.publish/validation/package.json b/.publish/validation/package.json index 94033f95..45fae5c0 100644 --- a/.publish/validation/package.json +++ b/.publish/validation/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/validation", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "description": "@wrnexus/validation — part of the WrNexus framework.", "license": "MIT", diff --git a/packages/ai/package.json b/packages/ai/package.json index 572111d9..a35b2ab1 100644 --- a/packages/ai/package.json +++ b/packages/ai/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/ai", - "version": "0.2.42", + "version": "0.2.43", "private": true, "type": "module", "description": "Zero-dependency Claude (Anthropic) client for WrNexus apps.", diff --git a/packages/authz/package.json b/packages/authz/package.json index f837ab28..bdfff124 100644 --- a/packages/authz/package.json +++ b/packages/authz/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/authz", - "version": "0.2.42", + "version": "0.2.43", "private": true, "type": "module", "main": "src/index.ts", diff --git a/packages/cli/package.json b/packages/cli/package.json index 2c7e336b..c0d1516d 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/cli", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "main": "src/index.ts", "exports": { diff --git a/packages/cli/src/update.ts b/packages/cli/src/update.ts index 1dfad6ec..7212641c 100644 --- a/packages/cli/src/update.ts +++ b/packages/cli/src/update.ts @@ -456,6 +456,15 @@ const MIGRATIONS: Migration[] = [ // No generated application files require automatic migration. }, }, + { + version: "0.2.43", + id: "conditions-bug", + description: + "Adds server-rendered component each/if blocks and fixes dynamic component rendering.", + apply() { + // No generated application files require automatic migration. + }, + }, ]; /** Release tooling uses this to require an explicit migration entry per version. */ diff --git a/packages/compiler/package.json b/packages/compiler/package.json index 030e2b36..c4bf7376 100644 --- a/packages/compiler/package.json +++ b/packages/compiler/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/compiler", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "main": "src/index.ts", "exports": { diff --git a/packages/core/package.json b/packages/core/package.json index f417048c..cae6e96a 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/core", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "main": "src/index.ts", "exports": { diff --git a/packages/csr/package.json b/packages/csr/package.json index 92d1102e..344def2d 100644 --- a/packages/csr/package.json +++ b/packages/csr/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/csr", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "main": "src/index.ts", "exports": { diff --git a/packages/csr/src/reactive-runtime.ts b/packages/csr/src/reactive-runtime.ts index a75818c9..c4510fc0 100644 --- a/packages/csr/src/reactive-runtime.ts +++ b/packages/csr/src/reactive-runtime.ts @@ -139,9 +139,40 @@ export const REACTIVE_RUNTIME = String.raw` } if (ch === "(" || ch === "[" || ch === "{") depth++; else if (ch === ")" || ch === "]" || ch === "}") depth--; - else if ((ch === ";" || ch === "\n" || ch === "\r") && depth === 0) { - var part = input.slice(start, i).trim(); - if (part) parts.push(part); + else if ( + ( + ch === ";" || + ch === "\n" || + ch === "\r" + ) && + depth === 0 + ) { + var nextIndex = i + 1; + + while ( + nextIndex < input.length && + /\s/.test(input[nextIndex]) + ) { + nextIndex++; + } + + if ( + input.slice( + nextIndex, + nextIndex + 4, + ) === "else" + ) { + continue; + } + + var part = input + .slice(start, i) + .trim(); + + if (part) { + parts.push(part); + } + start = i + 1; } } @@ -387,34 +418,98 @@ export const REACTIVE_RUNTIME = String.raw` }); } - function runStmt(stmt, locals) { - splitStatements(stmt).forEach(function (part) { - runStatement( - part, - function (expression) { return evalExpr(expression, locals); }, + function runStmt( + source, + locals, + ) { + var statements = + splitStatements(source); + + for ( + var statementIndex = 0; + statementIndex < + statements.length; + statementIndex++ + ) { + var result = runStatement( + statements[statementIndex], + function (expression) { + return evalExpr( + expression, + locals, + ); + }, function (name) { - if (locals && Object.prototype.hasOwnProperty.call(locals, name)) return locals[name]; + if ( + locals && + Object.prototype + .hasOwnProperty.call( + locals, + name, + ) + ) { + return locals[name]; + } + return peekScope(name); }, function (name, value) { - if (locals && Object.prototype.hasOwnProperty.call(locals, name)) { + if ( + locals && + Object.prototype + .hasOwnProperty.call( + locals, + name, + ) + ) { locals[name] = value; } else { writeScope(name, value); } }, + function (body) { + return runStmt( + body, + locals, + ); + }, ); - }); + + if (result.returned) { + return result; + } + } + + return { + returned: false, + value: undefined, + }; } function installBehaviorFunctions(source) { extractBehaviorFunctions(source || "").forEach(function (definition) { - behaviorFunctions[definition.name] = function () { + behaviorFunctions[ + definition.name + ] = function () { var locals = {}; - for (var i = 0; i < definition.args.length; i++) { - locals[definition.args[i]] = arguments[i]; + + for ( + var i = 0; + i < definition.args.length; + i++ + ) { + locals[definition.args[i]] = + arguments[i]; } - runStmt(definition.body, locals); + + var result = runStmt( + definition.body, + locals, + ); + + return result.returned + ? result.value + : undefined; }; }); } @@ -780,32 +875,342 @@ export const REACTIVE_RUNTIME = String.raw` return initial; } - function runStatement(stmt, evalExpr, read, write) { + function skipStatementWhitespace( + source, + index, + ) { + while ( + index < source.length && + /\s/.test(source[index]) + ) { + index++; + } + + return index; + } + + function findClosingDelimiter( + source, + start, + opening, + closing, + ) { + if (source[start] !== opening) { + return -1; + } + + var depth = 1; + var quote = ""; + var escaped = false; + + for ( + var index = start + 1; + index < source.length; + index++ + ) { + var character = source[index]; + + if (quote) { + if (escaped) { + escaped = false; + continue; + } + + if (character === "\\") { + escaped = true; + continue; + } + + if (character === quote) { + quote = ""; + } + + continue; + } + + if ( + character === '"' || + character === "'" || + character === "\`" + ) { + quote = character; + continue; + } + + if (character === opening) { + depth++; + continue; + } + + if (character === closing) { + depth--; + + if (depth === 0) { + return index; + } + } + } + + return -1; + } + + function parseIfStatement(source) { + source = String(source || "").trim(); + + if ( + source.slice(0, 2) !== "if" || + /[A-Za-z0-9_$]/.test( + source.charAt(2), + ) + ) { + return null; + } + + var branches = []; + var index = 0; + + while (index < source.length) { + index = skipStatementWhitespace( + source, + index, + ); + + var condition = null; + + if ( + source.slice(index, index + 2) === + "if" + ) { + index += 2; + } else if ( + source.slice(index, index + 7) === + "else if" + ) { + index += 7; + } else if ( + source.slice(index, index + 4) === + "else" + ) { + index += 4; + + condition = null; + } else { + break; + } + + index = skipStatementWhitespace( + source, + index, + ); + + if ( + condition !== null || + source.slice( + index - 4, + index, + ) !== "else" + ) { + if (source[index] !== "(") { + throw new Error( + "Expected '(' after if", + ); + } + + var conditionEnd = + findClosingDelimiter( + source, + index, + "(", + ")", + ); + + if (conditionEnd < 0) { + throw new Error( + "Unclosed if condition", + ); + } + + condition = source + .slice(index + 1, conditionEnd) + .trim(); + + index = skipStatementWhitespace( + source, + conditionEnd + 1, + ); + } + + if (source[index] !== "{") { + throw new Error( + "Expected '{' after if condition", + ); + } + + var bodyEnd = + findClosingDelimiter( + source, + index, + "{", + "}", + ); + + if (bodyEnd < 0) { + throw new Error( + "Unclosed if body", + ); + } + + branches.push({ + condition: condition, + body: source.slice( + index + 1, + bodyEnd, + ), + }); + + index = skipStatementWhitespace( + source, + bodyEnd + 1, + ); + + if ( + source.slice(index, index + 7) === + "else if" || + source.slice(index, index + 4) === + "else" + ) { + continue; + } + + break; + } + + return branches.length > 0 + ? branches + : null; + } + + function runStatement( + stmt, + evalExpr, + read, + write, + runBlock, + ) { stmt = String(stmt || "").trim(); - if (!stmt) return; - var inc = stmt.match(/^([A-Za-z_$][A-Za-z0-9_$]*)\s*(\+\+|--)$/); - if (inc) { - write(inc[1], Number(read(inc[1]) || 0) + (inc[2] === "++" ? 1 : -1)); - return; + if (!stmt) { + return { + returned: false, + value: undefined, + }; } - var assign = stmt.match(/^([A-Za-z_$][A-Za-z0-9_$]*)\s*(\+=|-=|\*=|\/=|%=|=)\s*([\s\S]+)$/); - if (!assign) { - evalExpr(stmt); // bare expression statement (e.g. a method/function call) - return; + var returnMatch = + /^return(?:\s+([\s\S]+))?$/.exec( + stmt, + ); + + if (returnMatch) { + return { + returned: true, + value: returnMatch[1] + ? evalExpr(returnMatch[1]) + : undefined, + }; } - var name = assign[1]; - var op = assign[2]; - var next = evalExpr(assign[3]); - var current = read(name); - if (op === "+=") next = current + next; - else if (op === "-=") next = Number(current || 0) - Number(next || 0); - else if (op === "*=") next = Number(current || 0) * Number(next || 0); - else if (op === "/=") next = Number(current || 0) / Number(next || 0); - else if (op === "%=") next = Number(current || 0) % Number(next || 0); - write(name, next); + var ifBranches = + parseIfStatement(stmt); + + if (ifBranches) { + for ( + var branchIndex = 0; + branchIndex < ifBranches.length; + branchIndex++ + ) { + var branch = + ifBranches[branchIndex]; + + if ( + branch.condition === null || + !!evalExpr(branch.condition) + ) { + return runBlock(branch.body); + } + } + + return { + returned: false, + value: undefined, + }; + } + + var increment = stmt.match( + /^([A-Za-z_$][A-Za-z0-9_$]*)\s*(\+\+|--)$/, + ); + + if (increment) { + write( + increment[1], + Number(read(increment[1]) || 0) + + (increment[2] === "++" + ? 1 + : -1), + ); + + return { + returned: false, + value: undefined, + }; + } + + var assignment = stmt.match( + /^([A-Za-z_$][A-Za-z0-9_$]*)\s*(\+=|-=|\*=|\/=|%=|=)\s*([\s\S]+)$/, + ); + + if (!assignment) { + evalExpr(stmt); + + return { + returned: false, + value: undefined, + }; + } + + var name = assignment[1]; + var operator = assignment[2]; + var nextValue = + evalExpr(assignment[3]); + var currentValue = read(name); + + if (operator === "+=") { + nextValue = + currentValue + nextValue; + } else if (operator === "-=") { + nextValue = + Number(currentValue || 0) - + Number(nextValue || 0); + } else if (operator === "*=") { + nextValue = + Number(currentValue || 0) * + Number(nextValue || 0); + } else if (operator === "/=") { + nextValue = + Number(currentValue || 0) / + Number(nextValue || 0); + } else if (operator === "%=") { + nextValue = + Number(currentValue || 0) % + Number(nextValue || 0); + } + + write(name, nextValue); + + return { + returned: false, + value: nextValue, + }; } function evaluateSpecialExpression( diff --git a/packages/db/package.json b/packages/db/package.json index 325fb4c0..caf8a787 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/db", - "version": "0.2.42", + "version": "0.2.43", "private": true, "type": "module", "main": "src/index.ts", diff --git a/packages/dev-server/package.json b/packages/dev-server/package.json index 13951996..115986b8 100644 --- a/packages/dev-server/package.json +++ b/packages/dev-server/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/dev-server", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "main": "src/index.ts", "exports": { diff --git a/packages/encryption/package.json b/packages/encryption/package.json index 6f12c591..0baf4914 100644 --- a/packages/encryption/package.json +++ b/packages/encryption/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/encryption", - "version": "0.2.42", + "version": "0.2.43", "private": true, "type": "module", "main": "src/index.ts", diff --git a/packages/helpers/package.json b/packages/helpers/package.json index ae4e777d..3c71e0be 100644 --- a/packages/helpers/package.json +++ b/packages/helpers/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/helpers", - "version": "0.2.42", + "version": "0.2.43", "private": true, "type": "module", "description": "Safe convenience helpers for WrNexus request contexts and common application flows.", diff --git a/packages/i18n/package.json b/packages/i18n/package.json index 9ea57583..226ecaee 100644 --- a/packages/i18n/package.json +++ b/packages/i18n/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/i18n", - "version": "0.2.42", + "version": "0.2.43", "private": true, "type": "module", "main": "src/index.ts", diff --git a/packages/jwt/package.json b/packages/jwt/package.json index e506030f..03cde5b3 100644 --- a/packages/jwt/package.json +++ b/packages/jwt/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/jwt", - "version": "0.2.42", + "version": "0.2.43", "private": true, "type": "module", "main": "src/index.ts", diff --git a/packages/mobile/package.json b/packages/mobile/package.json index 6b419f8f..1da30151 100644 --- a/packages/mobile/package.json +++ b/packages/mobile/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/mobile", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "main": "src/index.ts", "exports": { diff --git a/packages/native/package.json b/packages/native/package.json index e879549a..d30f8bbc 100644 --- a/packages/native/package.json +++ b/packages/native/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/native", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "main": "src/index.ts", "exports": { diff --git a/packages/oauth/package.json b/packages/oauth/package.json index 4eb17a8e..b86409f5 100644 --- a/packages/oauth/package.json +++ b/packages/oauth/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/oauth", - "version": "0.2.42", + "version": "0.2.43", "private": true, "type": "module", "main": "src/index.ts", diff --git a/packages/pubsub/package.json b/packages/pubsub/package.json index 86113ea1..e21baba4 100644 --- a/packages/pubsub/package.json +++ b/packages/pubsub/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/pubsub", - "version": "0.2.42", + "version": "0.2.43", "private": true, "type": "module", "main": "src/index.ts", diff --git a/packages/queue/package.json b/packages/queue/package.json index a9f1a77b..134907b8 100644 --- a/packages/queue/package.json +++ b/packages/queue/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/queue", - "version": "0.2.42", + "version": "0.2.43", "private": true, "type": "module", "main": "src/index.ts", diff --git a/packages/reactive/package.json b/packages/reactive/package.json index b07e6d02..e6427d33 100644 --- a/packages/reactive/package.json +++ b/packages/reactive/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/reactive", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "main": "src/index.ts", "exports": { diff --git a/packages/router/package.json b/packages/router/package.json index 58f923db..33af7e07 100644 --- a/packages/router/package.json +++ b/packages/router/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/router", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "main": "src/index.ts", "exports": { diff --git a/packages/ssr/package.json b/packages/ssr/package.json index d5617977..98e3c445 100644 --- a/packages/ssr/package.json +++ b/packages/ssr/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/ssr", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "main": "src/index.ts", "exports": { diff --git a/packages/styles/package.json b/packages/styles/package.json index 4ee3fcfb..13272376 100644 --- a/packages/styles/package.json +++ b/packages/styles/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/styles", - "version": "0.2.42", + "version": "0.2.43", "type": "module", "main": "src/index.ts", "exports": { diff --git a/packages/test/package.json b/packages/test/package.json index b58824aa..8fe97b28 100644 --- a/packages/test/package.json +++ b/packages/test/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/test", - "version": "0.2.42", + "version": "0.2.43", "private": true, "type": "module", "main": "src/index.ts", diff --git a/packages/tracking/package.json b/packages/tracking/package.json index 2736b462..7d031dc3 100644 --- a/packages/tracking/package.json +++ b/packages/tracking/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/tracking", - "version": "0.2.42", + "version": "0.2.43", "private": true, "type": "module", "main": "src/index.ts", diff --git a/packages/ui/package.json b/packages/ui/package.json index b6c0d8f9..f53ca307 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/ui", - "version": "0.2.42", + "version": "0.2.43", "private": true, "type": "module", "main": "src/index.ts", diff --git a/packages/uploader/package.json b/packages/uploader/package.json index 8055b682..4214acab 100644 --- a/packages/uploader/package.json +++ b/packages/uploader/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/uploader", - "version": "0.2.42", + "version": "0.2.43", "private": true, "type": "module", "main": "src/index.ts", diff --git a/packages/validation/package.json b/packages/validation/package.json index 9c35d49b..72bab5e3 100644 --- a/packages/validation/package.json +++ b/packages/validation/package.json @@ -1,6 +1,6 @@ { "name": "@wrnexus/validation", - "version": "0.2.42", + "version": "0.2.43", "private": true, "type": "module", "main": "src/index.ts", diff --git a/update-package-versions.mjs b/update-package-versions.mjs index a3b4dea5..37d22757 100644 --- a/update-package-versions.mjs +++ b/update-package-versions.mjs @@ -1,7 +1,7 @@ import { existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs"; import { join } from "node:path"; -const version = "0.2.42"; +const version = "0.2.43"; const dependencyGroups = [ "dependencies",