Commit Graph
108 Commits
Author SHA1 Message Date
Zef Hemel 178cf2d01f Fix in error propagation during boot 2025-12-10 16:43:16 +01:00
Zef Hemel 992d83f015 Fixes #1720
Stop intercepting exceptions during single file sync so they become
visible in the UI
2025-12-10 10:05:07 +01:00
Zef Hemel 2efeb93b47 Implements #1707
This splits indexing into two phases:

* preindex (where only pages, space lua, space styles are indexed)
* index (where everything else is indexed)

The goal is to get to more-or-less operational state quicker this way,
because probably most functionality can already be enabled after the
pre-index phase.
2025-12-10 09:48:09 +01:00
Thomas JostandGitHub bd132dacb2 Include sourcemaps in production builds (#1717)
This makes it easier to debug issues, but also to understand SilverBullet
internals while developing new features in Space Lua.

Fixes #1699.
2025-12-10 09:30:32 +01:00
Zef Hemel 8c07783460 Only show offline error for offline errors 2025-12-06 17:17:32 +01:00
Zef Hemel b4f8a0ce8b Fixes #1091 In case an auth proxy (such as CF Zero Trust) attempts a
redirect, SB now kills the service worker and reloads in the hope that
the redirect will actually kick in.
2025-12-05 15:27:50 +01:00
Matouš Jan FialkaandGitHub 5b03ed872c Space Lua: Add <const> attribute (#1715)
* Space Lua: Implement <const> attribute

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

* Space Lua: Implement <const> attribute

- Add Lua attributes with parse time validation
- Add `<const>` attribute semantic tests

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

---------

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2025-12-03 15:44:15 +01:00
Tomasz GorochowikandGitHub ca76e880d7 Improve links in frontmatter (#1711) 2025-11-28 14:43:24 +01:00
MrMugameandGitHub eb6b232444 Fix document editors on safari (#1710)
* Revert document editors to old model

Safari had issues with the previous "hacky" way

* Cleaup panel code
2025-11-28 14:40:05 +01:00
Zef Hemel b6e08e8fc7 Fixes #1705
Performing (implicitly) async actions in a `where` filter wasn't
supported. Fixed now.
2025-11-25 13:51:53 +01:00
Zef Hemel 0f57a03542 Remove full-text search from SB core
Now available as separate library:
https://github.com/silverbulletmd/basic-search/blob/main/PLUG.md
2025-11-24 16:33:17 +01:00
Zef Hemel 9e8e717ea3 Fixes #1352 2025-11-24 09:57:02 +01:00
Lelouch HeandGitHub 7afda4aa37 Follow the system theme automatically when dark mode toggle was not set before (#1696)
* follow browser theme unless darkmode was set before

* trigger workflow
2025-11-21 15:46:25 +01:00
Matouš Jan FialkaandGitHub c50bb49205 Space Lua: Add support for \t in strings (#1698)
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2025-11-21 09:36:45 +01:00
Zef Hemel 8395d2ab63 Propagate errors (e.g. when disabled) for proxy fetch 2025-11-19 14:57:32 +01:00
Zef Hemel b0f6b9a33d Add permission check before write/delete operations This avoids
accidentally writing to a read-only file and only finding out about it
after a sync.

Also removes redundant space primitive implementations that weren't used
2025-11-19 14:57:10 +01:00
Matouš Jan FialkaandGitHub 7912f05949 Space Lua: Add goto and labels support (#1686)
* Space Lua: Add AST block type label/goto and duplicated label bools
* Space Lua: Add label/goto resolution and evaluation

Add per block map of labels metadata, per function block metadata cache
and `processBlock` to track AST blocks (`If`, `While`, `Repeat`, `For`
and `ForIn`, and `Do`) while recording labels and their positions.

Align with Lua scoping rules (_e.g._, a `goto` can not jump into the
scope of a local). Also allow the super-special "safe" end of block
cases (except inside `Repeat`). Duplicated labels are detected (error
`label 'foo' is already defined` etc.). The AST context for error
reporting is preserved. The `WeakMap` caches map any block to its
function's metadata.

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

* Space Lua: The `goto` parse flags and eval path

At parser mark each block with `hasLabel`/`hasGoto` and record the first
duplicated label. Flags then propagate through blocks and control flow.

If no `goto`, run the block in a simple loop and raise duplicate label
error if any is present. If `goto` exists, jump via a label map.

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

* Space Lua: Add labels and `goto` statement test suite

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

* Space Lua: Minor `goto`/labels improvement and test hotfix

- The `getBlockGotoMeta` now called only when a block has either
  `hasGoto` or `hasLabel`.

- Add `BlocksFlags` type to get rid of some `(... as any)`s by view.

- Add `blockMetaOrThrow` helper.

- Fix test to reflect standard Lua semantics.

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

* Space Lua: Goto: Add missing Lua semantics checks

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

* Space Lua: Goto: Add Lua semantics checks also covered in Lua tests

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

* Space Lua: Goto: Fix semantic divergence revealed by fixing unfinished test

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

* Fix typo

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

* Space Lua: Optimize block env creation and cache goto metadata

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

* Avoid using the venomous snake case

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

* Add comment for WeakMap use

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

* Space Lua: Block Label Fast-path Optimization

Add block flag `hasLabelHere` during parsing and use it in eval to skip
expensive metadata generation for blocks and entire functions without
label or goto.

Refactor eval logic:
- early fast path when a function is known to have no label/goto,
- later fast path for blocks in functions with goto.

Fetch metadata only when needed.

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

* Space Lua: Remove `BlockFlags` indirection from eval

- Add `hasLabelHere` flag to `LuaBlock`.
- Remove `BlockFlags` indirection from eval.
- Set `hasLabelHere` directly.
- Add some "guards".
- Improve consistency of child filtering.

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

* Remove redundant return statement

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

---------

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2025-11-18 16:35:08 +01:00
Zef Hemel 6d81aeb4c2 Fixes #1687 2025-11-17 15:50:12 +01:00
Zef Hemel e01c8b3d83 Lua: fix edge case where querying wasn't supported for empty tags 2025-11-14 11:49:18 +01:00
Zef Hemel f0e6bb243a Don't show a border when using button widgets 2025-11-12 16:54:07 +01:00
Zef Hemel 1a03ccc561 Stop logging redundant logs 2025-11-12 16:53:41 +01:00
Zef Hemel a6d4eb187b Lua: Fix regression in pairs 2025-11-10 15:33:26 +01:00
Zef Hemel 9569f51142 Fixes #1658
SilverBullet now has hard dependencies on APIs that are only available
via localhost and HTTPS URLs. A lot of people run into this, this
documents how to setup TLS and gives a more in-your-face message about
what's going on.
2025-11-10 14:33:38 +01:00
Matouš Jan FialkaandGitHub 3b0c38d72d Space Lua: Perf improvements (#1666)
* Add result-or-promise (RP) exec model to interpreter (async-first).
* Add centralized table property access with fast misses.
* Update table string keys to be object map.
* Update error contexts to be more consistent and precise.
* Update evaluator to return either values or _Promises_.
* Update func calls, unary and bin operations, and expression lists.
* Update _stdlib_ to the changes and improve errors.
* Add tests to validate async control flow and error contexts.
* Add dedicated benches that isolate the _runtime_ from parsing.
2025-11-10 13:23:32 +01:00
Ohad LutzkyandGitHub 72a7c6e071 More robust "offline" handling when using proxies (#1675)
Identify more HTTP statuses as indicating "offline", specifically ones
delivered by proxies such as cloudflare.
2025-11-09 12:10:30 +01:00
Zef Hemel 26ba11b362 lint fixes 2025-11-07 16:29:19 +01:00
Zef Hemel 125c11721a New Share, Library, Repositories support 2025-11-07 16:28:20 +01:00
Zef Hemel 7cec9b6121 Lua: introduce net.* APIs and deprecate http.request in favor of new
net.proxyFetch API

Introduces foundation support for URIs (net.readURI, net.writeURI).
2025-11-07 10:51:17 +01:00
Zef Hemel f65abb4704 Lua: start of crypto.* API 2025-11-07 10:49:13 +01:00
Zef Hemel 4a34b6c6a3 Properly map JS call return value in Lua 2025-11-07 10:47:56 +01:00
Zef Hemel 44a9ae6c0e Support deletion of keys in YAML patch library 2025-11-07 10:47:11 +01:00
Zef Hemel f0d13b2d60 Lua: index.tag sanity check 2025-11-07 10:46:40 +01:00
Zef Hemel 63bb23f8fb Service bus (services API) implementation 2025-11-07 10:46:14 +01:00
Zef Hemel cc317d8451 Sanity check on KV key building (checking for string type) 2025-11-07 10:43:57 +01:00
Zef Hemel 732c6a5589 Loading of plugs is no longer restricted to _plug
Builtin plugs are generated under Library/Std/Plugs path now.
2025-11-07 10:43:25 +01:00
Matouš Jan FialkaandGitHub 3422a9fa20 Add Space Lua benchmarks based on Deno.bench aligned to Deno.test (#1649)
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2025-11-05 15:06:33 +01:00
Zef Hemel 1b28f04bdf A few refinements for Lua APIs 2025-10-31 17:07:40 +01:00
Zef Hemel 5654a6bc6d config.insert syscall 2025-10-31 09:13:24 +01:00
Zef Hemel f28815d642 Fixes #1622 2025-10-30 15:48:19 +01:00
Zef Hemel c3aea2cf8c When a Lua error occurs, report it and jump to source of occurance (best
effort)
2025-10-30 15:35:34 +01:00
Zef Hemel 000b76a6f7 Support adding additional content to <head> using the SB_HEAD_HTML env
variable
2025-10-30 11:42:08 +01:00
Zef Hemel 4c8dc704b7 Support embedded widgets and markdown with dom.* API 2025-10-29 09:30:48 +01:00
Zef Hemel dbe80bed8c Nicer error in case of empty Lua expression n directive 2025-10-29 08:56:08 +01:00
Zef Hemel 1838cc4eb1 Encryption auth redirect 2025-10-23 09:18:51 +02:00
Zef Hemel 18bea2e113 Client: Clean command 2025-10-23 09:03:57 +02:00
Zef HemelandGitHub 272f293ddb Optional client encryption (#1640)
Implements #1268
2025-10-22 15:35:37 +02:00
Matouš Jan FialkaandGitHub cd6f4e9c58 Space Lua: Align .. (concatenation) operator (#1648)
* Make fallback accept only strings and numbers (as per standard Lua).

* Remove `luaToString` from the fallback. It fits well presentation
  purposes but is too complicated for strict semantic checking in the
  evaluator and also wrongly coersed non-string and non-number value.
  It may also return a promise but we require synchronous error path.

* Concatenating `nil` now throws "attempt to concatenate nil value" as
  per standard Lua.

* Other types throw "attempt to concatenate a non-string or non-number"
  which is simplified message diverting from standard Lua which throws
  typed error but we do not strictly need that for Space Lua (and can be
  easily added anytime in the future).

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2025-10-22 10:41:26 +02:00
Matouš Jan FialkaandGitHub 4b9829c59c Space Lua: Add rawget and rawequal functions (#1647)
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2025-10-21 13:41:36 +02:00
Matouš Jan FialkaandGitHub 9292ae4b74 Space Lua: Align length features with standard Lua (#1637)
* Align `#` operator and `__len` metamethod with Lua and add `rawlen` function

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2025-10-21 09:55:38 +02:00
Zef Hemel 82800ad9bc No longer supress errors coming from event handlers 2025-10-20 19:50:55 +02:00