@stacksjs/stx 0.2.153 → 0.2.155
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/animation.js +6 -6
- package/dist/app-shell.js +1 -27
- package/dist/build-message.d.ts +10 -0
- package/dist/build-message.js +26 -0
- package/dist/builtins/attrs.js +6 -1
- package/dist/cli.js +1481 -1231
- package/dist/client-script-bundler.js +2 -4
- package/dist/client-script.d.ts +29 -0
- package/dist/client-script.js +140 -95
- package/dist/color-mode-boot.d.ts +31 -0
- package/dist/color-mode-boot.js +41 -5
- package/dist/component-renderer.js +10 -21
- package/dist/composables/index.d.ts +2 -0
- package/dist/composables/use-clipboard.d.ts +1 -5
- package/dist/composables/use-clipboard.js +57 -46
- package/dist/composables/use-color-mode.js +13 -5
- package/dist/composables/use-router.d.ts +28 -11
- package/dist/composables/use-router.js +63 -9
- package/dist/config.js +22 -7
- package/dist/craft.js +1029 -789
- package/dist/dev-server/crosswind.js +8 -6
- package/dist/dev-server/serve-app.js +4 -2
- package/dist/dev-server/serve-markdown.js +4 -1
- package/dist/dev-server/serve-multi.js +32 -20
- package/dist/document-shell.d.ts +65 -0
- package/dist/document-shell.js +59 -12
- package/dist/dynamic-components.js +123 -4
- package/dist/events.d.ts +26 -49
- package/dist/events.js +23 -9
- package/dist/expressions.d.ts +1 -1
- package/dist/expressions.js +3 -3
- package/dist/framework-composables.d.ts +41 -0
- package/dist/framework-composables.js +115 -0
- package/dist/hot-reload.js +8 -2
- package/dist/includes.js +2 -2
- package/dist/isolated-build.d.ts +12 -0
- package/dist/isolated-build.js +18 -0
- package/dist/plugin-system.d.ts +1 -1
- package/dist/process.js +40 -10
- package/dist/production-server.js +4 -1
- package/dist/prop-sentinels.d.ts +31 -0
- package/dist/prop-sentinels.js +7 -0
- package/dist/pwa.js +966 -726
- package/dist/reactive.js +1 -1
- package/dist/reactivity.d.ts +0 -15
- package/dist/reactivity.js +15 -6
- package/dist/runtime-globals.d.ts +40 -2
- package/dist/runtime-globals.js +90 -0
- package/dist/runtime-injection.d.ts +51 -0
- package/dist/runtime-injection.js +13 -0
- package/dist/script-emit.d.ts +20 -0
- package/dist/script-emit.js +11 -0
- package/dist/script-validation.js +12 -7
- package/dist/signal-processing.js +25 -40
- package/dist/signals-api.d.ts +30 -0
- package/dist/signals-api.js +18 -0
- package/dist/signals.js +258 -47
- package/dist/site-builder/build.js +21 -7
- package/dist/site-builder/seo.js +19 -10
- package/dist/site-builder/theme.js +5 -4
- package/dist/site-builder/types.d.ts +1 -0
- package/dist/ssg.js +986 -746
- package/dist/state-management.js +4 -1
- package/dist/store-loader.d.ts +0 -11
- package/dist/store-loader.js +27 -3
- package/dist/strict-lint.d.ts +9 -6
- package/dist/strict-lint.js +2 -21
- package/dist/stx.d.ts +111 -16
- package/dist/unresolved-identifiers.d.ts +50 -0
- package/dist/unresolved-identifiers.js +146 -0
- package/dist/utils.js +3 -3
- package/dist/variable-extractor.js +17 -1
- package/dist/x-element.js +1 -1
- package/package.json +5 -5
- package/stx.d.ts +111 -16
package/stx.d.ts
CHANGED
|
@@ -82,23 +82,49 @@ declare function onMount(_fn: () => void | StxCleanup): void
|
|
|
82
82
|
declare function onDestroy(_fn: () => void): void
|
|
83
83
|
declare function onBeforeMount(_fn: () => void): void
|
|
84
84
|
declare function onMounted(_fn: () => void | StxCleanup): void
|
|
85
|
-
declare function onBeforeUpdate(_fn: () => void): void
|
|
86
|
-
declare function onUpdated(_fn: () => void): void
|
|
87
85
|
declare function onBeforeUnmount(_fn: () => void): void
|
|
88
86
|
declare function onUnmounted(_fn: () => void): void
|
|
89
|
-
|
|
87
|
+
// onBeforeUpdate / onUpdated / onErrorCaptured are NOT declared: they exist in
|
|
88
|
+
// reactivity.ts and composition-api.ts but have no client-runtime counterpart,
|
|
89
|
+
// so declaring them promised a global that resolved to undefined (#1804).
|
|
90
90
|
|
|
91
91
|
// ============================================================================
|
|
92
92
|
// Template refs
|
|
93
93
|
// ============================================================================
|
|
94
94
|
|
|
95
|
+
/** Stable per-component id, unique across instances. */
|
|
96
|
+
declare function useId(_prefix?: string): string
|
|
97
|
+
/**
|
|
98
|
+
* Signal tracking a parent-driven `:prop="signal()"` attribute on the
|
|
99
|
+
* component's root element. One-way: parent to child.
|
|
100
|
+
*/
|
|
101
|
+
declare function useReactiveProp<T = unknown>(
|
|
102
|
+
_name: string,
|
|
103
|
+
_defaultValue?: T,
|
|
104
|
+
_options?: { parse?: (_value: string) => T },
|
|
105
|
+
): StxSignal<T>
|
|
95
106
|
declare function useRef<T = HTMLElement>(_name: string): { current: T | null }
|
|
96
107
|
|
|
97
108
|
// ============================================================================
|
|
98
109
|
// Routing / navigation
|
|
99
110
|
// ============================================================================
|
|
100
111
|
|
|
101
|
-
|
|
112
|
+
interface StxNavigateOptions {
|
|
113
|
+
/** Replace the current history entry instead of pushing a new one. */
|
|
114
|
+
replace?: boolean
|
|
115
|
+
/** Bypass the SPA router and perform a full document load. */
|
|
116
|
+
reload?: boolean
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Navigate via the SPA router.
|
|
121
|
+
*
|
|
122
|
+
* The second argument is deliberately NOT typed to also accept a boolean. The
|
|
123
|
+
* legacy positional `forceReload` boolean still works at runtime — it was the
|
|
124
|
+
* shape that actually shipped — but keeping it out of the type means nothing
|
|
125
|
+
* that type-checks today changes meaning (#1807).
|
|
126
|
+
*/
|
|
127
|
+
declare function navigate(_url: string, _options?: StxNavigateOptions): void
|
|
102
128
|
declare function goBack(): void
|
|
103
129
|
declare function goForward(): void
|
|
104
130
|
declare function useRoute(): {
|
|
@@ -108,11 +134,39 @@ declare function useRoute(): {
|
|
|
108
134
|
hash: string
|
|
109
135
|
}
|
|
110
136
|
declare function setRouteParams(_params: Record<string, string>): void
|
|
137
|
+
/** How a search-param mutation is written to session history (#1825). */
|
|
138
|
+
interface StxSearchParamsCommitOptions {
|
|
139
|
+
/** Replace the current history entry instead of pushing a new one. */
|
|
140
|
+
replace?: boolean
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Reactive access to the URL query string.
|
|
145
|
+
*
|
|
146
|
+
* The declaration was wrong in both directions (#1806): it promised `delete`
|
|
147
|
+
* and `has`, which did not exist at runtime, and omitted `setAll` and `data`,
|
|
148
|
+
* which did. `delete`/`has` are now implemented rather than dropped; `get`
|
|
149
|
+
* returns `undefined` for a missing key, not `null`, which is what the runtime
|
|
150
|
+
* and the docs have always said.
|
|
151
|
+
*/
|
|
111
152
|
declare function useSearchParams(): {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
has: (
|
|
153
|
+
/** The backing signal — read it to make a binding reactive to the query. */
|
|
154
|
+
data: StxSignal<Record<string, string>>
|
|
155
|
+
get: (_key: string) => string | undefined
|
|
156
|
+
has: (_key: string) => boolean
|
|
157
|
+
/** Set a param. Pushes a history entry unless `{ replace: true }` is passed. */
|
|
158
|
+
set: (_key: string, _value: string, _options?: StxSearchParamsCommitOptions) => void
|
|
159
|
+
/**
|
|
160
|
+
* Remove a param. Pushes a history entry unless `{ replace: true }` is passed.
|
|
161
|
+
*
|
|
162
|
+
* CONSUMING a one-shot param — an OAuth callback result, `?checkout=success`,
|
|
163
|
+
* a flash token — needs `{ replace: true }`. Under the default push, the URL
|
|
164
|
+
* that still carries the param becomes the previous history entry, so Back
|
|
165
|
+
* replays the callback and re-runs whatever consuming it triggered (#1825).
|
|
166
|
+
*/
|
|
167
|
+
delete: (_key: string, _options?: StxSearchParamsCommitOptions) => void
|
|
168
|
+
/** Set several params. Pushes a history entry unless `{ replace: true }` is passed. */
|
|
169
|
+
setAll: (_values: Record<string, string>, _options?: StxSearchParamsCommitOptions) => void
|
|
116
170
|
}
|
|
117
171
|
|
|
118
172
|
// ============================================================================
|
|
@@ -160,7 +214,6 @@ declare function useEventListener(
|
|
|
160
214
|
declare function useScrollLock(
|
|
161
215
|
_target?: HTMLElement | null | { current?: HTMLElement | null, value?: HTMLElement | null } | (() => HTMLElement | null | undefined),
|
|
162
216
|
): StxSignal<boolean>
|
|
163
|
-
declare function useMeta(_meta: Record<string, string>): void
|
|
164
217
|
declare function useClickOutside(_target: HTMLElement | StxRef<HTMLElement | null> | string | null, _handler: (event: MouseEvent) => void): StxCleanup
|
|
165
218
|
declare function useFocus(_target: HTMLElement | StxRef<HTMLElement | null> | string | null): { focused: StxSignal<boolean>, focus: () => void, blur: () => void }
|
|
166
219
|
|
|
@@ -209,6 +262,44 @@ declare function useAsync<T>(_fn: () => Promise<T>): {
|
|
|
209
262
|
declare function useLocalStorage<T>(_key: string, _defaultValue: T): StxSignal<T>
|
|
210
263
|
declare function useSessionStorage<T>(_key: string, _defaultValue: T): StxSignal<T>
|
|
211
264
|
|
|
265
|
+
/**
|
|
266
|
+
* Options accepted by the auto-imported `useCookie` global.
|
|
267
|
+
*
|
|
268
|
+
* This describes the CLIENT RUNTIME's cookie composable, which is what a bare
|
|
269
|
+
* `useCookie(...)` in a `<script client>` block resolves to. The module export
|
|
270
|
+
* `@stacksjs/stx/composables` accepts a slightly wider `expires` (Date, epoch ms
|
|
271
|
+
* or parseable string); the runtime calls `.toUTCString()` on it, so only a Date
|
|
272
|
+
* works there. See #1710.
|
|
273
|
+
*/
|
|
274
|
+
interface StxCookieOptions {
|
|
275
|
+
/** Max age in seconds. */
|
|
276
|
+
maxAge?: number
|
|
277
|
+
/** Expiration date. */
|
|
278
|
+
expires?: Date
|
|
279
|
+
/** Cookie path. Defaults to '/'. */
|
|
280
|
+
path?: string
|
|
281
|
+
/** Cookie domain. */
|
|
282
|
+
domain?: string
|
|
283
|
+
/** Secure flag. Defaults to true when location.protocol is https:. */
|
|
284
|
+
secure?: boolean
|
|
285
|
+
/** SameSite attribute. Defaults to 'Lax'. */
|
|
286
|
+
sameSite?: 'Strict' | 'Lax' | 'None' | 'strict' | 'lax' | 'none'
|
|
287
|
+
/** Value returned when the cookie is absent. Defaults to ''. */
|
|
288
|
+
defaultValue?: string
|
|
289
|
+
/** Custom encoder. Defaults to encodeURIComponent. */
|
|
290
|
+
encode?: (_value: string) => string
|
|
291
|
+
/** Custom decoder. Defaults to decodeURIComponent. */
|
|
292
|
+
decode?: (_value: string) => string
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Reactive binding to a single cookie (#1808).
|
|
297
|
+
*
|
|
298
|
+
* Returns a signal, like `useLocalStorage` — writes serialise straight to
|
|
299
|
+
* `document.cookie`, and `.set('')` deletes by emitting `max-age=0`.
|
|
300
|
+
*/
|
|
301
|
+
declare function useCookie(_name: string, _options?: StxCookieOptions): StxSignal<string>
|
|
302
|
+
|
|
212
303
|
// ============================================================================
|
|
213
304
|
// WebSocket
|
|
214
305
|
// ============================================================================
|
|
@@ -317,6 +408,8 @@ interface StxSeoMetaConfig {
|
|
|
317
408
|
|
|
318
409
|
declare function useHead(_config: StxHeadConfig): void
|
|
319
410
|
declare function useSeoMeta(_config: StxSeoMetaConfig): void
|
|
411
|
+
/** No-op on the client; the real one runs at SSR/SSG time. */
|
|
412
|
+
declare function definePageMeta(_meta: Record<string, unknown>): void
|
|
320
413
|
|
|
321
414
|
// ============================================================================
|
|
322
415
|
// Vue-style reactivity (alternative API)
|
|
@@ -348,9 +441,9 @@ declare function defineExpose<T extends Record<string, any>>(_exposed: T): void
|
|
|
348
441
|
declare function defineSlots<T extends Record<string, (..._args: any[]) => any> = Record<string, (..._args: any[]) => any>>(): T
|
|
349
442
|
declare function provide<T>(_key: string | symbol, _value: T): void
|
|
350
443
|
declare function inject<T>(_key: string | symbol, _defaultValue?: T): T | undefined
|
|
351
|
-
declare function getCurrentInstance(): any
|
|
352
444
|
declare function useSlots(): Record<string, any>
|
|
353
|
-
|
|
445
|
+
// getCurrentInstance / useAttrs are NOT declared — composition-api.ts exports
|
|
446
|
+
// them for server use; no client-runtime counterpart exists (#1804).
|
|
354
447
|
declare function $computed<T>(_getter: () => T): StxRef<T>
|
|
355
448
|
declare function $watch<T>(
|
|
356
449
|
_source: (() => T) | StxRef<T> | StxSignal<T>,
|
|
@@ -462,16 +555,18 @@ declare function defineStore<S extends Record<string, any>, G extends Record<str
|
|
|
462
555
|
},
|
|
463
556
|
): () => S & G & A
|
|
464
557
|
declare function useStore<T = any>(_id: string): T
|
|
465
|
-
declare function
|
|
466
|
-
|
|
467
|
-
|
|
558
|
+
declare function registerStoresClient(_stores: Record<string, unknown>): void
|
|
559
|
+
// createStore / createSelector are exported by state-management.ts for server
|
|
560
|
+
// use and `action` has no implementation anywhere; none reaches window.stx, so
|
|
561
|
+
// none is declared as an ambient global (#1804).
|
|
468
562
|
|
|
469
563
|
// ============================================================================
|
|
470
564
|
// JSX runtime (Vue/React style)
|
|
471
565
|
// ============================================================================
|
|
472
566
|
|
|
473
|
-
|
|
474
|
-
|
|
567
|
+
// h / Fragment belong to the JSX runtime (jsx-runtime.ts) and are resolved by
|
|
568
|
+
// the transform, not destructured off window.stx — so they are not ambient
|
|
569
|
+
// globals (#1804). Import them explicitly if you call them directly.
|
|
475
570
|
|
|
476
571
|
// ============================================================================
|
|
477
572
|
// window.stx registry
|