@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. **27 of them are auto-imported**;
12
- the rest need an explicit import from `@stacksjs/composables`.
13
-
14
- `storage/framework/browser-auto-imports.json` is the authority, and it declares
15
- 83 names in total, 27 of which are `use*`. This page said "All are auto-imported
16
- in STX templates", which is the same mistake `AGENTS.md` carries a scar about
17
- under "200+ composables": an agent reaching for a name on that authority writes
18
- a template that does not run, and reads the failure as a framework bug.
19
-
20
- ## The 27 you can write bare in a template
21
-
22
- Everything else on this page needs an explicit import, and that is most of what
23
- the sections below list - `useCounter`, `useLocalStorage`, `useMouse`,
24
- `useScroll`, `useIntersectionObserver` and `usePreferredReducedMotion` among
25
- them, which are exactly the names `AGENTS.md` calls out for having been wrongly
26
- listed as free.
27
-
28
- No count of how many fall on each side, deliberately. That number is
29
- maintained by hand and moves whenever a name is added to any section on this
30
- page - it was wrong within one edit of being written. The list below is the
31
- whole of the free side; anything not on it is on the other.
32
-
33
- <!-- auto-imported:begin - checked against browser-auto-imports.json by
34
- core/server/tests/composables-skill-auto-imports.test.ts. Both directions:
35
- every name here must be in the manifest, and every `use*` in the manifest
36
- must be here. Edit the manifest, not this list. -->
37
-
38
- `useAbs`, `useAuth`, `useAverage`, `useCeil`, `useClamp`, `useDark`,
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
- A name not on that list is imported:
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 { useCounter } from '@stacksjs/composables'
46
+ import { useStorage } from '@stacksjs/composables'
50
47
  ```
51
48
 
52
- **And the 27 are free only in the STX script entry.** The injection does not
53
- reach a TypeScript module that entry imports - bindings there do not leak into
54
- bundled module scope - so a `.ts` file beside your template imports every one
55
- of these explicitly, same as any other name. `AGENTS.md` states the same limit
56
- under Auto-imports. Referencing an uninjected name is a ReferenceError thrown
57
- before any binding applies, which takes the whole page down rather than
58
- degrading the one call.
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 27 of the 154 composables are auto-imported in STX templates. Check
204
- `storage/framework/browser-auto-imports.json` before relying on a bare name;
205
- everything else needs `import { … } from '@stacksjs/composables'`
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`
@@ -2,7 +2,7 @@
2
2
  "publisher": "Stacks",
3
3
  "name": "vscode-stacks",
4
4
  "displayName": "Stacks",
5
- "version": "0.74.45",
5
+ "version": "0.74.46",
6
6
  "description": "A modern Stacks development environment.",
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.74.45",
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.45",
58
+ "@stacksjs/mobile": "^0.74.46",
59
59
  "@stacksjs/sanitizer": "^0.2.113",
60
60
  "ts-qr-codes": "^0.1.8"
61
61
  }