@stacksjs/defaults 0.74.45 → 0.74.46
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.
|
@@ -8,54 +8,56 @@ allowed-tools: Read Edit Write Bash Grep Glob
|
|
|
8
8
|
|
|
9
9
|
# Stacks Composables
|
|
10
10
|
|
|
11
|
-
154 reactive composables for STX templates. **
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
`
|
|
39
|
-
`useDateFormat`, `useFetch`, `useFloor`, `useForm`, `useGitStore`, `useMax`,
|
|
40
|
-
`useMin`, `useNow`, `useOnline`, `usePaymentStore`, `usePrecision`,
|
|
41
|
-
`usePreferredDark`, `useQueueStore`, `useRound`, `useScrollLock`, `useStorage`,
|
|
42
|
-
`useSum`, `useTimeoutFn`, `useToggle`, `useTrunc`, `useUserStore`.
|
|
11
|
+
154 reactive composables for STX templates. **A fixed set of them is available
|
|
12
|
+
bare**, listed below; everything else needs an explicit import from
|
|
13
|
+
`@stacksjs/composables`.
|
|
14
|
+
|
|
15
|
+
The stx runtime decides this, not `browser-auto-imports.json`. That manifest
|
|
16
|
+
feeds an ambient `.d.ts` and nothing reads it at build time, so it says what the
|
|
17
|
+
compiler accepts and not what the browser has; the two disagree in both
|
|
18
|
+
directions (stacksjs/stacks#2585).
|
|
19
|
+
|
|
20
|
+
This page said "All are auto-imported in STX templates", which is the mistake
|
|
21
|
+
`AGENTS.md` carries a scar about under "200+ composables": an agent reaching for
|
|
22
|
+
a name on that authority writes a template that does not run, and reads the
|
|
23
|
+
failure as a framework bug.
|
|
24
|
+
|
|
25
|
+
## What you can write bare in a template
|
|
26
|
+
|
|
27
|
+
<!-- auto-imported:begin - checked against the stx runtime by
|
|
28
|
+
core/composables/tests/skill-runtime-globals.test.ts. These are the names
|
|
29
|
+
`getCachedSignalsRuntime()` attaches to `window`, which is what decides
|
|
30
|
+
whether a bare call resolves in a template. Do not derive this list from
|
|
31
|
+
`browser-auto-imports.json`: that manifest is compile-time only, and 22 of
|
|
32
|
+
the 27 `use*` it declares are absent from the runtime. -->
|
|
33
|
+
|
|
34
|
+
`useAsync`, `useClickOutside`, `useColorMode`, `useCounter`, `useDark`,
|
|
35
|
+
`useDebounce`, `useDebouncedValue`, `useEventListener`, `useFetch`, `useFocus`,
|
|
36
|
+
`useHead`, `useInterval`, `useLocalStorage`, `useMutation`, `useQuery`,
|
|
37
|
+
`useRef`, `useRoute`, `useSearchParams`, `useSeoMeta`, `useSessionStorage`,
|
|
38
|
+
`useStore`, `useThrottle`, `useTimeout`, `useToggle`, `useWebSocket`.
|
|
43
39
|
|
|
44
40
|
<!-- auto-imported:end -->
|
|
45
41
|
|
|
46
|
-
|
|
42
|
+
Everything else needs an explicit import, and that is most of what the sections
|
|
43
|
+
below list:
|
|
47
44
|
|
|
48
45
|
```ts
|
|
49
|
-
import {
|
|
46
|
+
import { useStorage } from '@stacksjs/composables'
|
|
50
47
|
```
|
|
51
48
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
49
|
+
**`buddy typecheck` will not tell you which is which, and currently disagrees
|
|
50
|
+
with the browser in both directions** (stacksjs/stacks#2585).
|
|
51
|
+
`storage/framework/browser-auto-imports.json` feeds an ambient `.d.ts`, so the
|
|
52
|
+
compiler accepts every name it declares - and only five of its 27 `use*` are in
|
|
53
|
+
the runtime. `useStorage`, `useNow`, `useDateFormat`, `useForm` and the `use*Store`
|
|
54
|
+
composables typecheck and then throw a ReferenceError during setup, which takes
|
|
55
|
+
the page down rather than failing the one call. In the other direction
|
|
56
|
+
`useLocalStorage`, `useColorMode`, `useCounter` and `useMediaQuery` all work in
|
|
57
|
+
a template and `tsc` rejects them.
|
|
58
|
+
|
|
59
|
+
The list above is the runtime's, so it is the one that predicts whether the page
|
|
60
|
+
loads.
|
|
59
61
|
|
|
60
62
|
## Key Path
|
|
61
63
|
- Core package: `storage/framework/core/composables/src/`
|
|
@@ -200,9 +202,11 @@ isRef(val) // type guard
|
|
|
200
202
|
- `and`, `or`, `logicNot`, `logicOr`
|
|
201
203
|
|
|
202
204
|
## Gotchas
|
|
203
|
-
- Only
|
|
204
|
-
`
|
|
205
|
-
|
|
205
|
+
- Only the names listed above are available bare in an STX template, and they
|
|
206
|
+
come from the stx runtime, not from `browser-auto-imports.json` - that
|
|
207
|
+
manifest is compile-time only and disagrees with the runtime in both
|
|
208
|
+
directions (stacksjs/stacks#2585). Everything else needs
|
|
209
|
+
`import { … } from '@stacksjs/composables'`
|
|
206
210
|
- NEVER use vanilla JS (`var`, `document.*`, `window.*`) in STX `<script>` tags
|
|
207
211
|
- Only use stx-compatible code: signals, composables, directives
|
|
208
212
|
- Auto-imports defined in `storage/framework/browser-auto-imports.json`
|
package/ide/vscode/package.json
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/defaults",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.74.
|
|
5
|
+
"version": "0.74.46",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/stacksjs/stacks.git",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@iconify-json/f7": "^1.2.2",
|
|
57
57
|
"@iconify-json/hugeicons": "^1.2.27",
|
|
58
|
-
"@stacksjs/mobile": "^0.74.
|
|
58
|
+
"@stacksjs/mobile": "^0.74.46",
|
|
59
59
|
"@stacksjs/sanitizer": "^0.2.113",
|
|
60
60
|
"ts-qr-codes": "^0.1.8"
|
|
61
61
|
}
|