toilscript 0.1.30 → 0.1.31
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 +1 -1
- package/dist/cli.js +9 -9
- package/dist/cli.js.map +2 -2
- package/dist/importmap.json +2 -2
- package/dist/toilscript.generated.d.ts +1 -1
- package/dist/toilscript.js +2 -2
- package/dist/toilscript.js.map +2 -2
- package/dist/web.js +3 -3
- package/package.json +1 -1
- package/std/assembly/toildb.ts +6 -6
- package/std/assembly/toilscript.d.ts +11 -17
- package/std/ts-plugin.cjs +1 -1
package/dist/web.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var ASSEMBLYSCRIPT_VERSION = "0.1.
|
|
1
|
+
var ASSEMBLYSCRIPT_VERSION = "0.1.31";
|
|
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.31/dist/toilscript.js",
|
|
5
|
+
"toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.31/dist/cli.js",
|
|
6
6
|
"binaryen": "https://cdn.jsdelivr.net/npm/binaryen@129.0.0-nightly.20260428/index.js",
|
|
7
7
|
"long": "https://cdn.jsdelivr.net/npm/long@5.3.2/index.js"
|
|
8
8
|
}
|
package/package.json
CHANGED
package/std/assembly/toildb.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// ToilDB: the developer-facing edge-database API.
|
|
2
2
|
//
|
|
3
|
-
// `@database class App { @collection(...) users!:
|
|
3
|
+
// `@database class App { @collection(...) users!: Documents<UserId, User>; ... }`
|
|
4
4
|
// declares logical collections; the compiler (see parser `injectDatabaseBinding`)
|
|
5
5
|
// synthesizes a `@global App` singleton whose fields are these typed handles,
|
|
6
6
|
// resolved to numeric host handles once at module init.
|
|
@@ -49,7 +49,7 @@ function __toildbTakeGrow(): Uint8Array {
|
|
|
49
49
|
/// A mutable keyed-entity collection (spec 7.1). `V` is the `@data` value type,
|
|
50
50
|
/// `K` the `@data` key type.
|
|
51
51
|
@global
|
|
52
|
-
export class
|
|
52
|
+
export class Documents<K, V> {
|
|
53
53
|
private __handle: u32;
|
|
54
54
|
|
|
55
55
|
constructor(handle: u32) {
|
|
@@ -156,7 +156,7 @@ export class Record<V, K> {
|
|
|
156
156
|
/// by a `@derive`/`@job` (the host kind gate enforces it). `V` is the `@data`
|
|
157
157
|
/// value type, `K` the `@data` key type.
|
|
158
158
|
@global
|
|
159
|
-
export class View<
|
|
159
|
+
export class View<K, V> {
|
|
160
160
|
private __handle: u32;
|
|
161
161
|
|
|
162
162
|
constructor(handle: u32) {
|
|
@@ -202,7 +202,7 @@ export class ClaimResult<V> {
|
|
|
202
202
|
/// A globally-unique claim collection (spec 7.6): username, email, slug, ...
|
|
203
203
|
/// `V` is the `@data` OWNER value type, `K` the `@data` claim-key type.
|
|
204
204
|
@global
|
|
205
|
-
export class Unique<
|
|
205
|
+
export class Unique<K, V> {
|
|
206
206
|
private __handle: u32;
|
|
207
207
|
|
|
208
208
|
constructor(handle: u32) {
|
|
@@ -251,7 +251,7 @@ export class Unique<V, K> {
|
|
|
251
251
|
/// An unordered set (spec 7.3): followers, tags, ACLs, room members. `M` is the
|
|
252
252
|
/// `@data` member type, `K` the `@data` set-key type.
|
|
253
253
|
@global
|
|
254
|
-
export class Membership<
|
|
254
|
+
export class Membership<K, M> {
|
|
255
255
|
private __handle: u32;
|
|
256
256
|
|
|
257
257
|
constructor(handle: u32) {
|
|
@@ -394,7 +394,7 @@ export class Counter<K> {
|
|
|
394
394
|
/// fact stream a `@derive` consumes. `V` is the `@data` event type, `K` the
|
|
395
395
|
/// `@data` stream-key type.
|
|
396
396
|
@global
|
|
397
|
-
export class Events<
|
|
397
|
+
export class Events<K, V> {
|
|
398
398
|
private __handle: u32;
|
|
399
399
|
|
|
400
400
|
constructor(handle: u32) {
|
|
@@ -92,7 +92,7 @@ declare function user(target: Function): void;
|
|
|
92
92
|
* lazily-resolved collection handle (`App.users.get(...)`). */
|
|
93
93
|
declare function database(target: Function): void;
|
|
94
94
|
|
|
95
|
-
/** Declares a `@database` field as a collection - a `
|
|
95
|
+
/** Declares a `@database` field as a collection - a `Documents`/`View`/`Unique`/
|
|
96
96
|
* `Counter`/`Events`/`Membership`/`Capacity` handle. */
|
|
97
97
|
declare function collection(target: Object, propertyKey: string | symbol): void;
|
|
98
98
|
|
|
@@ -107,13 +107,14 @@ declare function job(target: Function): void;
|
|
|
107
107
|
declare function derive(target: Function): void;
|
|
108
108
|
declare function admin(target: Function): void;
|
|
109
109
|
|
|
110
|
-
// The ToilDB collection HANDLES are ambient globals (
|
|
111
|
-
// provides them (`std/assembly/toildb`, `@global`);
|
|
112
|
-
// recognize `@collection users!:
|
|
113
|
-
//
|
|
110
|
+
// The ToilDB collection HANDLES are ambient globals (NO import, like the bignum
|
|
111
|
+
// natives below) - the compiler provides them (`std/assembly/toildb`, `@global`);
|
|
112
|
+
// these typings let editors recognize `@collection users!: Documents<UserId,
|
|
113
|
+
// User>` and `App.users.get(...)`. Every handle is KEY-FIRST (`<K, V>`, matching
|
|
114
|
+
// `Map`/`Record`). `K`/`V`/`M` are `@data` types (the codec the host marshals).
|
|
114
115
|
|
|
115
116
|
/** A mutable keyed-entity collection (spec 7.1): user profiles, items, sessions. */
|
|
116
|
-
declare class
|
|
117
|
+
declare class Documents<K, V> {
|
|
117
118
|
get(key: K): V | null;
|
|
118
119
|
require(key: K): V;
|
|
119
120
|
exists(key: K): bool;
|
|
@@ -125,7 +126,7 @@ declare class Record<V, K> {
|
|
|
125
126
|
}
|
|
126
127
|
|
|
127
128
|
/** A precomputed, read-optimized projection (spec 7.2): pages, leaderboards. */
|
|
128
|
-
declare class View<
|
|
129
|
+
declare class View<K, V> {
|
|
129
130
|
get(key: K): V | null;
|
|
130
131
|
require(key: K): V;
|
|
131
132
|
publish(key: K, value: V): void;
|
|
@@ -139,14 +140,14 @@ declare class ClaimResult<V> {
|
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
/** A globally-unique claim collection (spec 7.6): usernames, emails, slugs. */
|
|
142
|
-
declare class Unique<
|
|
143
|
+
declare class Unique<K, V> {
|
|
143
144
|
lookup(key: K): V | null;
|
|
144
145
|
claim(key: K, value: V): ClaimResult<V>;
|
|
145
146
|
release(key: K, value: V): void;
|
|
146
147
|
}
|
|
147
148
|
|
|
148
149
|
/** An unordered set (spec 7.3): followers, tags, ACLs, room members. */
|
|
149
|
-
declare class Membership<
|
|
150
|
+
declare class Membership<K, M> {
|
|
150
151
|
contains(key: K, member: M): bool;
|
|
151
152
|
add(key: K, member: M): void;
|
|
152
153
|
remove(key: K, member: M): void;
|
|
@@ -169,18 +170,11 @@ declare class Counter<K> {
|
|
|
169
170
|
}
|
|
170
171
|
|
|
171
172
|
/** An append-only event log (spec 7.5): activity feeds, audit trails. */
|
|
172
|
-
declare class Events<
|
|
173
|
+
declare class Events<K, V> {
|
|
173
174
|
append(key: K, event: V): void;
|
|
174
175
|
latest(key: K, limit: i32): V[];
|
|
175
176
|
}
|
|
176
177
|
|
|
177
|
-
// The handles are ambient (no import needed), but `import { Counter } from
|
|
178
|
-
// 'toildb'` is also accepted for editors that prefer explicit imports - it just
|
|
179
|
-
// re-exports the same globals.
|
|
180
|
-
declare module 'toildb' {
|
|
181
|
-
export { Record, View, Unique, ClaimResult, Membership, Capacity, Counter, Events };
|
|
182
|
-
}
|
|
183
|
-
|
|
184
178
|
// Big integers, native globals implemented in std/assembly/bignum. The
|
|
185
179
|
// arithmetic/bitwise/comparison operators
|
|
186
180
|
// (+ - * / % & | ^ << >> == != < > <= >=) are operator overloads resolved by
|
package/std/ts-plugin.cjs
CHANGED
|
@@ -212,7 +212,7 @@ function init(modules) {
|
|
|
212
212
|
* instance type-carrier field, so stock TS reports `AuthDb.users` as
|
|
213
213
|
* TS2339. Merge a `namespace` onto the class (the standard way to add typed
|
|
214
214
|
* statics) with one `const` per collection, typed as the field's handle type
|
|
215
|
-
* (`
|
|
215
|
+
* (`Documents<UserId, User>`, `Capacity<DropId>`, ...). Returns "" when the file
|
|
216
216
|
* declares no `@database`.
|
|
217
217
|
*/
|
|
218
218
|
function databaseAugmentation(text) {
|