@stacksjs/defaults 0.74.43 → 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.
@@ -66,7 +66,7 @@ globalThis.toggleDark = toggleDark
66
66
  - **Custom Functions**: From `resources/functions/` (counter, dark mode, GPX, geo utilities)
67
67
 
68
68
  ### Server Auto-Imports (100+)
69
- - **All ORM Models**: User, Post, Author, Product, Order, Payment, Customer, etc. (102 models)
69
+ - **All ORM Models**: User, Post, Author, Product, Order, Payment, Customer, etc. (103 models)
70
70
  - **Request Models**: UserRequest, PostRequest, OrderRequest, etc.
71
71
  - **Actions**: Action types and helpers
72
72
  - **Schema**: validation schema builder
@@ -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`
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: stacks-models
3
- description: Use when working with data models in Stacks - the defineModel() API, model attributes with validation and factories, relationships (hasOne/hasMany/belongsTo/belongsToMany), traits (useAuth, useUuid, useTimestamps, useSearch, useApi, billable, taggable, categorizable, commentable, likeable, observe), computed properties (get/set), model generation, and the 102 built-in framework models. Covers model definitions and storage/framework/defaults/app/Models/.
3
+ description: Use when working with data models in Stacks - the defineModel() API, model attributes with validation and factories, relationships (hasOne/hasMany/belongsTo/belongsToMany), traits (useAuth, useUuid, useTimestamps, useSearch, useApi, billable, taggable, categorizable, commentable, likeable, observe), computed properties (get/set), model generation, and the 103 built-in framework models. Covers model definitions and storage/framework/defaults/app/Models/.
4
4
  license: MIT
5
5
  compatibility: Bun >= 1.3.0, TypeScript, SQLite >= 3.47.2
6
6
  allowed-tools: Read Edit Write Bash Grep Glob
@@ -265,7 +265,7 @@ pass `--allow-protected` to override.
265
265
  ## Built-in models by category
266
266
 
267
267
  The ones below are worth knowing by name. They are a selection, not the set:
268
- `storage/framework/defaults/app/Models/` holds 102, and that directory is the
268
+ `storage/framework/defaults/app/Models/` holds 103, and that directory is the
269
269
  authority. This section said "All 62 built-in models by category" while
270
270
  listing fewer than that against 102 on disk, so an agent reading to the end
271
271
  had no way to tell it was short.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: stacks-orm
3
- description: Use when working with the Stacks ORM - defining models with defineModel(), model relationships (hasOne, hasMany, belongsTo, belongsToMany, morphOne, hasManyThrough), attributes, traits, factories, computed properties, query building, transactions, or the 102 built-in models. Covers @stacksjs/orm, storage/framework/orm/, and storage/framework/defaults/app/Models/.
3
+ description: Use when working with the Stacks ORM - defining models with defineModel(), model relationships (hasOne, hasMany, belongsTo, belongsToMany, morphOne, hasManyThrough), attributes, traits, factories, computed properties, query building, transactions, or the 103 built-in models. Covers @stacksjs/orm, storage/framework/orm/, and storage/framework/defaults/app/Models/.
4
4
  license: MIT
5
5
  compatibility: Bun >= 1.3.0, TypeScript, SQLite >= 3.47.2
6
6
  allowed-tools: Read Edit Write Bash Grep Glob
@@ -11,7 +11,7 @@ allowed-tools: Read Edit Write Bash Grep Glob
11
11
  ## Key Paths
12
12
  - Core ORM package: `storage/framework/core/orm/src/`
13
13
  - ORM implementation: `storage/framework/orm/`
14
- - Model definitions: `storage/framework/defaults/app/Models/` (102 models)
14
+ - Model definitions: `storage/framework/defaults/app/Models/` (103 models)
15
15
  - Application models: `app/Models/`
16
16
  - Default model templates: `storage/framework/defaults/app/Models/`
17
17
  - ORM type globals: `storage/framework/types/orm-globals.d.ts`
@@ -0,0 +1,55 @@
1
+ import { defineModel } from '@stacksjs/orm'
2
+ import { schema } from '@stacksjs/validation'
3
+
4
+ // The CMS catalogue already exists in categorizables. Commerce's Category
5
+ // model owns a different table and its IDs cannot be used by this pivot.
6
+ export default defineModel({
7
+ name: 'Categorizable',
8
+ table: 'categorizables',
9
+ primaryKey: 'id',
10
+ autoIncrement: true,
11
+ ownership: false,
12
+ traits: { useTimestamps: true },
13
+ indexes: [
14
+ { name: 'categorizables_type_slug_unique', columns: ['categorizable_type', 'slug'], unique: true },
15
+ { name: 'categorizables_owner_slug_unique', columns: ['categorizable_type', 'categorizable_id', 'slug'], unique: true },
16
+ ],
17
+ attributes: {
18
+ name: {
19
+ required: true,
20
+ fillable: true,
21
+ validation: { rule: schema.string() },
22
+ },
23
+ slug: {
24
+ required: true,
25
+ fillable: true,
26
+ validation: { rule: schema.string() },
27
+ },
28
+ description: {
29
+ required: false,
30
+ nullable: true,
31
+ fillable: true,
32
+ validation: { rule: schema.string() },
33
+ },
34
+ isActive: {
35
+ required: true,
36
+ fillable: true,
37
+ default: true,
38
+ validation: { rule: schema.boolean() },
39
+ },
40
+ categorizableId: {
41
+ // Runtime trait-table setup adds this column to older catalogues.
42
+ // Zero denotes a catalogue entry with no individual owner.
43
+ type: 'integer',
44
+ required: true,
45
+ fillable: true,
46
+ default: 0,
47
+ validation: { rule: schema.number().integer().min(0) },
48
+ },
49
+ categorizableType: {
50
+ required: true,
51
+ fillable: true,
52
+ validation: { rule: schema.string() },
53
+ },
54
+ },
55
+ } as const)
@@ -44,7 +44,7 @@ export default defineModel({
44
44
  belongsTo: ['Author', 'Site'],
45
45
  belongsToMany: {
46
46
  categories: {
47
- model: 'Category',
47
+ model: 'Categorizable',
48
48
  table: 'categorizable_models',
49
49
  foreignKey: 'categorizable_id',
50
50
  relatedKey: 'category_id',
@@ -2,7 +2,7 @@
2
2
  "publisher": "Stacks",
3
3
  "name": "vscode-stacks",
4
4
  "displayName": "Stacks",
5
- "version": "0.74.43",
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.43",
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.43",
58
+ "@stacksjs/mobile": "^0.74.46",
59
59
  "@stacksjs/sanitizer": "^0.2.113",
60
60
  "ts-qr-codes": "^0.1.8"
61
61
  }