toilscript 0.1.32 → 0.1.34
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/dist/cli.generated.d.ts +59 -9
- package/dist/cli.js +44 -1
- package/dist/cli.js.map +2 -2
- package/dist/importmap.json +2 -2
- package/dist/toilscript.generated.d.ts +51 -1
- package/dist/toilscript.js +74 -74
- package/dist/toilscript.js.map +4 -4
- package/dist/web.js +3 -3
- package/package.json +3 -2
- package/std/assembly/bindings/toildb.ts +16 -0
- package/std/assembly/toildb.ts +27 -0
- package/std/assembly/toilscript.d.ts +7 -1
package/dist/web.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var ASSEMBLYSCRIPT_VERSION = "0.1.
|
|
1
|
+
var ASSEMBLYSCRIPT_VERSION = "0.1.34";
|
|
2
2
|
var ASSEMBLYSCRIPT_IMPORTMAP = {
|
|
3
3
|
"imports": {
|
|
4
|
-
"toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.
|
|
5
|
-
"toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.
|
|
4
|
+
"toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.34/dist/toilscript.js",
|
|
5
|
+
"toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.34/dist/cli.js",
|
|
6
6
|
"binaryen": "https://cdn.jsdelivr.net/npm/binaryen@130.0.0-nightly.20260609/index.js",
|
|
7
7
|
"long": "https://cdn.jsdelivr.net/npm/long@5.3.2/index.js"
|
|
8
8
|
}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"toilscript",
|
|
9
9
|
"wasm"
|
|
10
10
|
],
|
|
11
|
-
"version": "0.1.
|
|
11
|
+
"version": "0.1.34",
|
|
12
12
|
"author": "Daniel Wirtz <dcode+assemblyscript@dcode.io>",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"homepage": "https://github.com/dacely-cloud/toilscript",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"prepublishOnly": "node scripts/build",
|
|
81
81
|
"watch": "node scripts/build --watch",
|
|
82
82
|
"coverage": "npx c8 -- npm test",
|
|
83
|
-
"test": "npm run test:parser && npm run test:compiler -- --parallel && npm run test:browser && npm run test:toilconfig && npm run test:transform && npm run test:cli && npm run test:json && npm run test:data",
|
|
83
|
+
"test": "npm run test:parser && npm run test:compiler -- --parallel && npm run test:browser && npm run test:toilconfig && npm run test:transform && npm run test:cli && npm run test:json && npm run test:data && npm run test:dbstatic",
|
|
84
84
|
"test:parser": "node --enable-source-maps tests/parser",
|
|
85
85
|
"test:compiler": "node --enable-source-maps --no-warnings tests/compiler",
|
|
86
86
|
"test:browser": "node --enable-source-maps tests/browser",
|
|
@@ -91,6 +91,7 @@
|
|
|
91
91
|
"test:cli": "node tests/cli/options.js",
|
|
92
92
|
"test:json": "node tests/json/run.mjs",
|
|
93
93
|
"test:data": "node tests/data/run.mjs",
|
|
94
|
+
"test:dbstatic": "node tests/dbstatic/run.mjs",
|
|
94
95
|
"asbuild": "npm run asbuild:debug && npm run asbuild:release",
|
|
95
96
|
"asbuild:debug": "node bin/toilscript --config src/toilconfig.json --target debug",
|
|
96
97
|
"asbuild:release": "node bin/toilscript --config src/toilconfig.json --target release",
|
|
@@ -227,4 +227,20 @@ export namespace toildbHost {
|
|
|
227
227
|
// @ts-ignore: decorator
|
|
228
228
|
@external("env", "data.take_result")
|
|
229
229
|
export declare function takeResult(outPtr: usize, outLen: i32): i32;
|
|
230
|
+
|
|
231
|
+
// The schema version the LAST value-returning read's row was written under, so
|
|
232
|
+
// the generated decoder can default fields added since / reject an unknown
|
|
233
|
+
// layout. A u32 version rides in the non-negative range; -1 means the last op
|
|
234
|
+
// returned no value (or the host does not track a version). Does not drain the
|
|
235
|
+
// result stash, so it may be read before or after `takeResult`.
|
|
236
|
+
// @ts-ignore: decorator
|
|
237
|
+
@external("env", "data.result_schema_version")
|
|
238
|
+
export declare function resultSchemaVersion(): i64;
|
|
239
|
+
|
|
240
|
+
// 1 if the current call's kind may issue a record write, else 0. The generated
|
|
241
|
+
// reader uses it to skip the rewrite-on-read convergence write in a read-only
|
|
242
|
+
// `@query` (where it would be rejected) rather than attempt a doomed write.
|
|
243
|
+
// @ts-ignore: decorator
|
|
244
|
+
@external("env", "data.write_allowed")
|
|
245
|
+
export declare function writeAllowed(): i32;
|
|
230
246
|
}
|
package/std/assembly/toildb.ts
CHANGED
|
@@ -25,6 +25,24 @@ export function __toildbResolve(name: string): u32 {
|
|
|
25
25
|
return load<u32>(out.dataStart);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/// The schema version of the last value-returning read's row (or -1). The
|
|
29
|
+
/// generated `decodeInto` of a `@migrate`-d value type calls this to dispatch an
|
|
30
|
+
/// old-layout row through its transform. Global so generated user-code reaches it
|
|
31
|
+
/// (like `__toildbResolve`).
|
|
32
|
+
export function __toildbReadVersion(): i64 {
|
|
33
|
+
return toildbHost.resultSchemaVersion();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/// Set true by a woven `decodeInto` when it migrates an old-layout row, so the
|
|
37
|
+
/// reading handle can converge the row (rewrite-on-read). The handle resets it
|
|
38
|
+
/// before each decode and reads it after; the dispatch marks it AFTER the
|
|
39
|
+
/// transform runs, so a transform that itself reads (resetting the flag) does not
|
|
40
|
+
/// clear the outer migration.
|
|
41
|
+
let __toildbMigratedFlag: bool = false;
|
|
42
|
+
export function __toildbResetMigrated(): void { __toildbMigratedFlag = false; }
|
|
43
|
+
export function __toildbMarkMigrated(): void { __toildbMigratedFlag = true; }
|
|
44
|
+
export function __toildbWasMigrated(): bool { return __toildbMigratedFlag; }
|
|
45
|
+
|
|
28
46
|
/// Pull the last stashed variable-length result of `len` bytes into a buffer.
|
|
29
47
|
function __toildbTake(len: i32): Uint8Array {
|
|
30
48
|
const buf = new Uint8Array(len);
|
|
@@ -61,8 +79,17 @@ export class Documents<K, V> {
|
|
|
61
79
|
const kb = key.encode();
|
|
62
80
|
const status = toildbHost.get(this.__handle, kb.dataStart, kb.byteLength);
|
|
63
81
|
if (status < 0) return null;
|
|
82
|
+
__toildbResetMigrated();
|
|
64
83
|
const v = instantiate<V>();
|
|
65
84
|
v.decodeInto(__toildbTake(status));
|
|
85
|
+
// Rewrite-on-read convergence: if this row was lazily migrated from an older
|
|
86
|
+
// layout AND the current call may write, persist the migrated value so it
|
|
87
|
+
// stops being re-migrated. Best-effort: a read-only kind skips it, and a
|
|
88
|
+
// failed patch is ignored (the in-memory value is already correct).
|
|
89
|
+
if (__toildbWasMigrated() && toildbHost.writeAllowed() == 1) {
|
|
90
|
+
const nb = v.encode();
|
|
91
|
+
toildbHost.patch(this.__handle, kb.dataStart, kb.byteLength, nb.dataStart, nb.byteLength, 0);
|
|
92
|
+
}
|
|
66
93
|
return v;
|
|
67
94
|
}
|
|
68
95
|
|
|
@@ -93,7 +93,13 @@ declare function user(target: Function): void;
|
|
|
93
93
|
declare function database(target: Function): void;
|
|
94
94
|
|
|
95
95
|
/** Declares a `@database` field as a collection - a `Documents`/`View`/`Unique`/
|
|
96
|
-
* `Counter`/`Events`/`Membership`/`Capacity` handle.
|
|
96
|
+
* `Counter`/`Events`/`Membership`/`Capacity` handle. Prefer the `static` form,
|
|
97
|
+
* `@collection static users: Documents<UserId, User>` (no `!` - a definite
|
|
98
|
+
* assignment assertion on a static field is a TS1255 error, and the compiler
|
|
99
|
+
* demotes the field so none is needed), so `App.users` type-checks in any editor
|
|
100
|
+
* with no language-service plugin. The instance form (`@collection users!: ...`)
|
|
101
|
+
* still works but needs the toilscript TS plugin to type the static `App.users`
|
|
102
|
+
* access. */
|
|
97
103
|
declare function collection(target: Object, propertyKey: string | symbol): void;
|
|
98
104
|
|
|
99
105
|
/** ToilDB function kinds (spec 6) - the data ops a function may issue. `@query`
|