@stacksjs/defaults 0.75.558 → 0.75.560
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.
|
@@ -90,7 +90,7 @@ Browser runtime bindings are documented separately in `stacks-auto-imports`.
|
|
|
90
90
|
| `@stacksjs/storage` | [`stacks-storage`](../stacks-storage/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/storage/src/index.ts) | 52 |
|
|
91
91
|
| `@stacksjs/strings` | [`stacks-strings`](../stacks-strings/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/strings/src/index.ts) | 12 |
|
|
92
92
|
| `@stacksjs/testing` | [`stacks-testing`](../stacks-testing/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/testing/src/index.ts) | 24 |
|
|
93
|
-
| `@stacksjs/tinker` | [`stacks-repl`](../stacks-repl/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/tinker/src/index.ts) |
|
|
93
|
+
| `@stacksjs/tinker` | [`stacks-repl`](../stacks-repl/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/tinker/src/index.ts) | 4 |
|
|
94
94
|
| `@stacksjs/tunnel` | [`stacks-tunnel`](../stacks-tunnel/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/tunnel/src/index.ts) | 1 |
|
|
95
95
|
| `@stacksjs/types` | [`stacks-types`](../stacks-types/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/types/src/index.ts) | 2 |
|
|
96
96
|
| `@stacksjs/ui` | [`stacks-ui`](../stacks-ui/SKILL.md) | [entrypoint](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/ui/src/index.ts) | 6 |
|
|
@@ -882,9 +882,9 @@ Guidance: [`stacks-repl`](../stacks-repl/SKILL.md). Source: [storage/framework/c
|
|
|
882
882
|
|
|
883
883
|
Declared runtime exports: `appendHistory`, `clearHistory`, `getHistoryPath`, `isIncompleteSnippet`, `readHistory`, `renderValue`, `startTinker`, `tinkerEval`, `tinkerPrint`.
|
|
884
884
|
|
|
885
|
-
Local source modules: [src/magic.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/tinker/src/magic.ts), [src/protocol.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/tinker/src/protocol.ts), [src/serialize.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/tinker/src/serialize.ts), [src/session.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/tinker/src/session.ts).
|
|
885
|
+
Local source modules: [src/magic.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/tinker/src/magic.ts), [src/protocol.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/tinker/src/protocol.ts), [src/serialize.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/tinker/src/serialize.ts), [src/session.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/tinker/src/session.ts), [src/settle.ts](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/tinker/src/settle.ts).
|
|
886
886
|
|
|
887
|
-
Evidence directory: [
|
|
887
|
+
Evidence directory: [4 retained tests](https://github.com/stacksjs/stacks/blob/main/storage/framework/core/tinker/tests). These files are evidence pointers, not a claim that all tests were run for this catalog.
|
|
888
888
|
|
|
889
889
|
### @stacksjs/tunnel
|
|
890
890
|
|
|
@@ -51,8 +51,8 @@ import type { TinkerConfig } from '@stacksjs/repl'
|
|
|
51
51
|
|
|
52
52
|
```bash
|
|
53
53
|
buddy tinker # interactive prompt, app booted
|
|
54
|
-
buddy tinker --print '
|
|
55
|
-
buddy tinker --eval '
|
|
54
|
+
buddy tinker --print 'User.count()' # evaluate, print the value, exit
|
|
55
|
+
buddy tinker --eval 'seed()' # evaluate, exit, print nothing
|
|
56
56
|
buddy tinker --project ../other-app # run in another project directory
|
|
57
57
|
buddy tinker --bare # plain Bun session, app not booted
|
|
58
58
|
buddy tinker --serve # frame protocol on stdio, for tools
|
|
@@ -77,7 +77,8 @@ evaluates it at global scope:
|
|
|
77
77
|
- several statements work, and the last expression is the result;
|
|
78
78
|
- `const`, `let`, functions, classes and imports persist to the next call, and
|
|
79
79
|
a name can be declared again;
|
|
80
|
-
-
|
|
80
|
+
- a query needs no `await` at the top level (see "No await at the top level");
|
|
81
|
+
top-level `await` still works;
|
|
81
82
|
- a relative `import('./x')` resolves against the session's directory;
|
|
82
83
|
- nothing is written to the project.
|
|
83
84
|
|
|
@@ -91,6 +92,51 @@ Map, Set, class names, cycles and errors, and records every cut.
|
|
|
91
92
|
`dump(value)` emits a frame. `dd(value)` dumps and stops the current run; it
|
|
92
93
|
does not exit the process.
|
|
93
94
|
|
|
95
|
+
## No await at the top level
|
|
96
|
+
|
|
97
|
+
Outside a function, a snippet reads as if it ran in order. Both of these bind
|
|
98
|
+
the row, and the line after can use it:
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
const user = await User.where('email', 'like', '%@example.com').orderByDesc('created_at').first()
|
|
102
|
+
const user = User.where('email', 'like', '%@example.com').orderByDesc('created_at').first()
|
|
103
|
+
|
|
104
|
+
user.email // the email, not undefined
|
|
105
|
+
User.first().email // mid-expression too
|
|
106
|
+
if (User.where('active', true).exists()) dump(User.count())
|
|
107
|
+
for (const post of Post.latest().limit(5).get()) dump(post.title)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
The rule: outside a function, a call that returns a promise is waited for
|
|
111
|
+
where it stands, and so is a promise a statement names (the value of a line,
|
|
112
|
+
of a declaration, of an assignment). A rejection is thrown there, so
|
|
113
|
+
`User.findOrFail(0)` fails the run it was written in.
|
|
114
|
+
|
|
115
|
+
- **Inside a function nothing changes.** `await` there is yours to write:
|
|
116
|
+
`users.map(async user => await user.posts())`.
|
|
117
|
+
- **Promise-handling code keeps its promise:** the receiver of `.then()`,
|
|
118
|
+
`.catch()` or `.finally()`, the arguments of `Promise.all()` and its
|
|
119
|
+
siblings (so they still run together), the operand of `void` (fire and
|
|
120
|
+
forget), and anything already under `await`.
|
|
121
|
+
- **Only a real `Promise` is waited for.** A query builder is not, so
|
|
122
|
+
`const query = User.where('active', true)` keeps the builder and
|
|
123
|
+
`query.count()` and `query.first()` both work.
|
|
124
|
+
- **A snippet with no promise in it is untouched at runtime:** same order,
|
|
125
|
+
same turn. Only a promise causes a wait.
|
|
126
|
+
|
|
127
|
+
`createTinkerSession({ settle: false })` turns it off for a session,
|
|
128
|
+
`session.evaluate(code, { settle: false })` and the request field
|
|
129
|
+
`"settle": false` for one run. A promise is then a promise, as in plain
|
|
130
|
+
JavaScript.
|
|
131
|
+
|
|
132
|
+
The transform is `settleTopLevel(code)`. It reads the snippet with a real
|
|
133
|
+
TypeScript parser and only inserts text, so no line moves; code it cannot
|
|
134
|
+
parse comes back untouched for the runtime to report. An editor that wants
|
|
135
|
+
the same answer from the type checker (`user` typed as the row, not as a
|
|
136
|
+
promise) checks `settleTopLevel(code, { wrap: SETTLE_TYPE_WRAP })` with
|
|
137
|
+
`SETTLE_TYPE_AMBIENT` in scope and maps positions with `settledOffset` and
|
|
138
|
+
`originalOffset`.
|
|
139
|
+
|
|
94
140
|
## The frame protocol (`--serve`)
|
|
95
141
|
|
|
96
142
|
One JSON request per line on stdin: `{ "op": "eval", "id": "a", "code": "..." }`,
|
|
@@ -107,9 +153,9 @@ A comment that starts with a question mark shows a value where it is computed.
|
|
|
107
153
|
The run's result is unchanged, and no line moves.
|
|
108
154
|
|
|
109
155
|
```ts
|
|
110
|
-
const users =
|
|
156
|
+
const users = User.all() //? the value of users
|
|
111
157
|
users.filter(u => u.active)/*?.length*/.map(u => u.name) //?
|
|
112
|
-
|
|
158
|
+
rebuildIndex() //?. ms since the run began
|
|
113
159
|
```
|
|
114
160
|
|
|
115
161
|
- `//?` at the end of a line: the statement that ends there. A declaration
|
|
@@ -141,6 +187,9 @@ what a relation graph and a completion list are built from.
|
|
|
141
187
|
## Gotchas
|
|
142
188
|
|
|
143
189
|
- **The database is real.** Mutations are not isolated or rolled back.
|
|
190
|
+
- **A promise held on purpose needs a function or `void`.** At the top level
|
|
191
|
+
`const job = startJob()` waits for the job. `void startJob()` does not, and
|
|
192
|
+
neither does anything inside a function.
|
|
144
193
|
- **A model is described as a model.** A result that is a model instance is a
|
|
145
194
|
`model` node: its name, table, key, the attributes its `toJSON()` exposes, the
|
|
146
195
|
relations it declares and the ones already loaded. Hidden attributes (a
|
|
@@ -158,5 +207,5 @@ what a relation graph and a completion list are built from.
|
|
|
158
207
|
- `tinkerEval` and `tinkerPrint` resolve with an exit code, not the value. Use
|
|
159
208
|
a session when the value is wanted.
|
|
160
209
|
|
|
161
|
-
Source: `storage/framework/core/tinker/src/{index,session,serialize,protocol}.ts`
|
|
162
|
-
and `core/repl/src/index.ts`. Tests: `core/tinker/tests/session.test.ts`.
|
|
210
|
+
Source: `storage/framework/core/tinker/src/{index,session,settle,magic,serialize,protocol}.ts`
|
|
211
|
+
and `core/repl/src/index.ts`. Tests: `core/tinker/tests/{session,settle,magic}.test.ts`.
|
package/ide/vscode/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"publisher": "Stacks",
|
|
3
3
|
"name": "vscode-stacks",
|
|
4
4
|
"displayName": "Stacks",
|
|
5
|
-
"version": "0.75.
|
|
5
|
+
"version": "0.75.560",
|
|
6
6
|
"description": "Stacks, built into VS Code: stx templates, pickier linting and formatting, encrypted env files, the dev server preview and every buddy command. No other extensions required.",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"funding": "https://github.com/sponsors/chrisbbreuer",
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/defaults",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.75.
|
|
5
|
+
"version": "0.75.560",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/stacksjs/stacks.git",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@iconify-json/f7": "^1.2.2",
|
|
47
47
|
"@iconify-json/hugeicons": "^1.2.35",
|
|
48
|
-
"@stacksjs/mobile": "0.75.
|
|
48
|
+
"@stacksjs/mobile": "0.75.560",
|
|
49
49
|
"@stacksjs/sanitizer": "^0.2.864",
|
|
50
50
|
"@stacksjs/stx": "^0.2.864",
|
|
51
|
-
"@stacksjs/strings": "0.75.
|
|
51
|
+
"@stacksjs/strings": "0.75.560",
|
|
52
52
|
"@xterm/addon-fit": "^0.11.0",
|
|
53
53
|
"@xterm/xterm": "^6.0.0",
|
|
54
54
|
"ts-qr-codes": "^0.1.8"
|