Commit Graph
3038 Commits
Author SHA1 Message Date
Zef Hemel 9e49794ac8 Remove file:// Deno-ism from plug compiler
- Drop file:// URL prefix from generated plug imports; use plain
  absolute paths instead (esbuild resolves these natively)
- Remove the file-url-resolver esbuild plugin that was only needed
  to strip that prefix
2026-02-27 16:08:31 +01:00
Zef Hemel 42ff234801 Cleanup test 2026-02-27 15:47:25 +01:00
Matouš Jan Fialka 8f193dc402 [LIQ] Fix: preserve queryable collections in query evaluation
Check for already-queryable objects (e.g. `DataStoreQueryCollection`)
before `LuaTable` extraction or `luaValueToJS` conversion, preventing
them from being destroyed by the collection normalization pipeline.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-27 15:44:26 +01:00
Zef Hemel efc0d24e11 Fixes 2026-02-27 15:35:34 +01:00
Matouš Jan Fialka cad71aa586 [LIQ] Fix: group by keys and collection handling
- Fix `group by` key building: populate array indices from
  `keyParts` instead of only from `keyRecord`, which was empty for
  some expressions (e.g. `tags[1]`).

- Fix collection handling: treat record-like `LuaTables` (no array part)
  as items instead of extracting zero items.

- Update test suite.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-27 15:30:40 +01:00
Zef Hemel 6c7b1891a1 Use .nvmrc to determine node versions for build in CI actions 2026-02-27 15:14:08 +01:00
Zef Hemel 803c5c478d Merge remote-tracking branch 'origin/main' into to-node 2026-02-27 15:05:49 +01:00
Laurence TanandGitHub c8e541250b Fix typo in Library Manager documentation 2026-02-27 19:12:03 +11:00
Matouš Jan Fialka bc2ae5e46f [LIQ] Miscellaneous bugfixes
* Fix `LUA_SQL_NULL` leaking into `order by` comparisons

  Note: SQL `NULLS LAST` is now default behaviour!

* Fix `objectVariable` unset for empty groups

* Fix non-grouped `having` used wrong environment builder

  Note: Queries similar to the following one now works correctly:

  ```sql
  ${query[[
    from
      tags.page
    having
      name == 'index'
  ]]}
  ```

* Fix `generateKey` did not handle `LUA_SQL_NULL`

* Refactor/deduplicate duplicated `order by` comparator

* Add `isSqlNull` helper

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-27 08:37:00 +01:00
Matouš Jan FialkaandGitHub 41b4a5d394 Merge branch 'silverbulletmd:main' into space-lua-fix-liq-ordering 2026-02-27 08:20:09 +01:00
Matouš Jan Fialka f7dc242790 [LIQ] Fix group by: order by with select aliases, variable binding in having and nil column ordering
1. Fix `order by` inability to access `select` output aliases and
   aggregate functions after `group by`.

2. Introduce `LUA_SQL_NULL` sentinel to preserve column ordering when
   `select` expressions evaluate to `nil`.

   Note: In Lua, setting a table key to `nil` deletes it so rows with
   `nil` values lose those keys and produced inconsistent insertion
   order across result tables.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-26 15:32:28 +01:00
Zef Hemel 336e87672f Simplifies #1724
Now considers any HTTP status >= 500 < 600 as offline
2026-02-26 11:39:43 +01:00
Zef HemelandGitHub 8e71ff90eb Merge pull request #1856 from mjf/fix-doc-typo
[LIQ/doc] Fix docs typo
2026-02-26 11:05:16 +01:00
Zef Hemel 8ca97579fb Hide vertical scrolling in page name in case of long page names 2026-02-26 10:15:25 +01:00
Zef Hemel f29f043ff3 Fixes #1846: bring back virtual pages
Was misusing Lua pattern matching before
2026-02-26 09:48:15 +01:00
Zef HemelandGitHub 0f3f963de0 Merge pull request #1833 from rktjmp/feat-upload-no-clobber
Dont clobber existing files when uploading
2026-02-26 09:28:27 +01:00
Oliver Marriott 274780e5e1 Match await flashNotification usage to existing code 2026-02-26 14:56:51 +11:00
Oliver Marriott ea590f8e27 Formatter 2026-02-26 14:27:25 +11:00
Oliver Marriott 4c5598dd4f Swap client.space... to editor.space... 2026-02-26 14:27:25 +11:00
Oliver Marriott 9467e8af26 Convert arrow functions to regular function decls 2026-02-26 14:27:14 +11:00
Matouš Jan Fialka b6d4f71aca [LIQ/doc] Fix docs typo
The `select` part operates not over a single record, but over each group
(i.e., the set of records sharing the same group key). The `select`
clause's environment is generally:

* `name` (the group key)

* `group` (the table of records in the group)

Note: no `p` is bound (`p` is not set; it was the row variable during scan, but we are now at the group level).

In the `select { name = name }` the name refers to the group key (what
we `group by`-ed).

We typically use:

* `name = name` (group key, as in the query), or

* if we want data from the first record (say all grouped `p.name` are
  the same and non-`nil`) then `name = group[1].name`.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-25 10:45:08 +01:00
Zef HemelandGitHub 924f7cacc3 Merge pull request #1852 from mjf/space-lua-add-frexp-and-ldexp
[Space Lua] Add `math.frexp` and `math.ldexp` and tests
2026-02-25 10:38:06 +01:00
Zef HemelandGitHub 89f0e57bfa Merge pull request #1844 from mjf/space-lua-fixtures
[Space Lua] Miscellaneous bug fixes and improvements
2026-02-25 10:37:37 +01:00
Zef HemelandGitHub a347487375 Merge branch 'main' into space-lua-fixtures 2026-02-25 10:36:32 +01:00
13c61ebab7 [LIQ] Extend with group by and having with aggregators (#1843)
* [LIQ] Extend with `group by` and `having` support

Also update documentation with extensive examples and add some parser
tests.

Note: `make generate` JS files included.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Merge `liq-add-support-for-aggregators` branch

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Fix link, remove `_` example

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Wrap example LIQ queries inside `query [[ .. ]]` and replace `sql` code block type to `lua`

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Example self-consistency fix

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Fixed some queries

* Add experimental tags to LIQ aggregation/grouping

---------

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
Co-authored-by: Zef Hemel <zef@zef.me>
2026-02-25 10:35:31 +01:00
rktjmpandGitHub f4bd2c3abc Trim user input from prompts where appropriate (#1854)
* Trim user input from prompts where appropriate

* Run formatter

* Use "page title" language instead of "page name" in notifications.

Existing language in prompt asks for a "page title".

* Use const for prefix inputs as they are never trimmed
2026-02-25 10:16:37 +01:00
Matouš Jan FialkaandGitHub fd4ff8518d [Space Lua] Implement string.pack, string.unpack and string.packsize (#1851)
The three binary-packing functions from Lua are now implemented in
a dedicated `string_pack.ts` module and wired into `stringApi`.

Format parsing follows the exact option set of Lua:

* signed and unsigned integers of configurable width
  (`b`/`B`/`h`/`H`/`l`/`L`/`j`/`J`/`T`/`i`/`I`),
* IEEE 754 single and double precision floats (`f`/`d`/`n`),
* fixed-length strings (`c`),
* length-prefixed strings (`s`),
* zero-terminated strings (`z`),
* padding bytes (`x`),
* alignment padding (`X`), and
* endianness/alignment modifiers (`<`/`>`/`=`/`!`).

`string.packsize` rejects variable-length formats (`s` and `z`) as Lua
requires.

`string.unpack` returns all unpacked values followed by the
next position integer, matching the Lua contract exactly.

Test suite extended in separates `string_pack_test.lua` file. Passes
both Lua and Space Lua execution.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-25 09:29:14 +01:00
Matouš Jan FialkaandGitHub cebc834469 FIX: Skip nil results in query select to prevent null rows corrupting renderer (#1853)
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-25 09:27:24 +01:00
Oliver Marriott db6f16fa6f Fix typing 2026-02-25 00:00:04 +11:00
Oliver Marriott 037e69c889 Add no-clobber behaviour to paste uploads 2026-02-25 00:00:04 +11:00
Oliver Marriott f22c1ce15c Check user input for null, trim otherwise 2026-02-25 00:00:04 +11:00
Oliver Marriott d8f0a7488b Prompt user before replacing files when using Upload file command 2026-02-25 00:00:04 +11:00
Matouš Jan Fialka 1f36103338 Add math.frexp and math.ldexp and tests
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-23 14:55:04 +01:00
Matouš Jan Fialka ed8ce174fc [Space Lua] Add _VERSION environment variable
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-23 13:01:50 +01:00
Matouš Jan Fialka 390fe384c1 [Space Lua] Remove unpack from core language test suite
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-23 08:24:28 +01:00
Matouš Jan Fialka cc931319d7 [Space Lua] Align table.pack and table.unpack with Lua semantics
`table.pack` now routes element writes through `luaSet` so `__newindex`
metamethods are honoured, matching the exact Lua 5.4 semantics.  The `n`
field is still written with `rawSet`, also matching Lua.

`table.unpack` now returns an empty `LuaMultiRes` instead of `null` for
an empty range `(i > j)`. Returning `null` would inject a single `nil`
argument at the call site; an empty `LuaMultiRes` correctly contributes
zero values, matching the exact Lua semantics.

The global `unpack` shim (for Lua 5.1 compatibility) has been removed
from `luaBuildStandardEnv`. Users who need the short alias can set it up
in `space-script` with a single line stating `unpack = table.unpack`.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-23 08:16:09 +01:00
Matouš Jan Fialka 11347fee72 Merge on main
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-23 07:33:51 +01:00
Matouš Jan FialkaandGitHub 3bb80ece3f [Space Lua]: Implement math.random and math.randomseed (#1845) 2026-02-21 17:56:49 +01:00
rktjmpandGitHub 472ff93416 Consider "" to be an invalid path (#1847) 2026-02-21 17:55:23 +01:00
Matouš Jan Fialka ef7b128793 [Space Lua] Fix: math.tointeger coerces strings like Lua; fix test
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-20 15:25:24 +01:00
Matouš Jan Fialka c3b747b0d5 [Space Lua] Fix: t[nil] read returns nil, not an error
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-20 15:06:22 +01:00
Matouš Jan Fialka 91927a7314 [Space Lua] Fix: Table index is nil/NaN raises error
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-20 11:27:55 +01:00
Matouš Jan Fialka 559fc0b94d [Space Lua] Implement math.tointeger
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-20 11:26:59 +01:00
Matouš Jan Fialka 3b29aa8497 [Space Lua] # operator respects __len metamethod via luaLen
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-20 11:03:28 +01:00
Matouš Jan Fialka f93a306a66 [Space Lua] Guarantee that math.modf returns integer and tagged float
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-20 09:36:10 +01:00
Matouš Jan Fialka 77d37090ca [Space Lua] Fix: string.gsub table repl unwraps tagged float before String
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-20 09:15:52 +01:00
Matouš Jan Fialka 4d30baa2f2 [Space Lua] Fix: table.sort comparator returns 0 for ties, not 1
Returning `1` when the comparator yields `false`/`nil` declares `a > b`
for equal elements. `asyncQuickSort` tolerates this today but any future
sort algorithm change could corrupt results. Changed to `0` so ties are
neutral.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-20 09:04:04 +01:00
Matouš Jan Fialka af0086fcfb [Space Lua] Implement table.move
Implement `table.move(a1, f, e, t [,a2])`.

The implementation copies elements `a1[f..e]` to `a2[t..t+(e-f)]`
defaulting `a2` to `a1` and returning `a2` as follows:

* empty ranges (`e < f`) are "no-op",

* for in-table copies where `t > f` loop backwards to prevent unread
  source slots from being clobbered before they are read (note: the only
  case where overlap is destructive,

* cross-table copies always run forwards since there is no aliasing.

Add test suite that covers:

* non-overlapping copies,
* cross-table copies,
* both overlap directions,
* same position identity,
* empty ranges, and
* single element moves.

Each of the above is tested with both scalar and nested-table values.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-20 08:28:24 +01:00
Matouš Jan Fialka 8cecd0985c [Space Lua] tostring() respects __tostring metamethod with live stack frame
`tostring()` was delegating to `luaToString()` which calls `__tostring`
with a dead stack frame, breaking metamethods that call back into
globals. Now `tostringFunction` receives the live stack frame, looks up
`__tostring` via `rawGet`, calls it through `luaCall` with the live
frame, and validates the return is a string.

Also add tests covering the basic case, the nested-call case, and the
error path for a non-string return.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-20 07:59:16 +01:00
Matouš Jan Fialka d2eb8fe6ec [SpaceLua] Use luaFormatNumber for number-to-string coercion in .. and table.concat
Replace raw `String(v)` calls with `luaFormatNumber` in the concatenation
operator and `table.concat`, so that floats are formatted according to Lua
semantics rather than JavaScript's. This fixes cases like `10.8*22..""`
producing `237.60000000000002` instead of `237.6`, and ensures
integer-valued floats carry the `.0` suffix as Lua requires.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-20 07:31:32 +01:00