@stacksjs/stx 0.2.155 → 0.2.156
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/a11y.d.ts +87 -46
- package/dist/animation.d.ts +96 -42
- package/dist/appearance-bootstrap.d.ts +49 -15
- package/dist/asset-roots.d.ts +32 -0
- package/dist/asset-roots.js +7 -0
- package/dist/assets.d.ts +9 -7
- package/dist/async-components.d.ts +78 -56
- package/dist/auth.d.ts +3 -0
- package/dist/build-externalize.d.ts +40 -0
- package/dist/build-externalize.js +63 -0
- package/dist/build-id.d.ts +22 -22
- package/dist/build-message.d.ts +73 -2
- package/dist/build-message.js +47 -8
- package/dist/builtins/attrs.d.ts +14 -0
- package/dist/builtins/drawer.d.ts +22 -0
- package/dist/builtins/icon.d.ts +16 -2
- package/dist/builtins/index.d.ts +5 -15
- package/dist/builtins/modal.d.ts +24 -0
- package/dist/builtins/safe-image.d.ts +42 -0
- package/dist/builtins/stx-image.d.ts +27 -0
- package/dist/builtins/stx-link.d.ts +9 -0
- package/dist/builtins/stx-loading-indicator.d.ts +11 -0
- package/dist/builtins/suspense.d.ts +28 -0
- package/dist/builtins/toast.d.ts +17 -0
- package/dist/builtins/transition-group.d.ts +25 -0
- package/dist/caching.d.ts +12 -15
- package/dist/cli.js +1798 -908
- package/dist/client/directive.d.ts +7 -0
- package/dist/client/index.d.ts +0 -1
- package/dist/client-script-bundler.d.ts +63 -5
- package/dist/client-script-bundler.js +30 -2
- package/dist/client-script.d.ts +102 -47
- package/dist/client-script.js +15 -3
- package/dist/codemod.d.ts +56 -0
- package/dist/codemod.js +192 -0
- package/dist/color-mode-boot.d.ts +83 -65
- package/dist/component-client-factories.d.ts +1 -6
- package/dist/component-processing.d.ts +58 -49
- package/dist/component-processing.js +1 -1
- package/dist/component-registry.d.ts +94 -31
- package/dist/component-renderer.d.ts +18 -0
- package/dist/composable-loader.d.ts +24 -0
- package/dist/composable-loader.js +12 -9
- package/dist/composables/index.d.ts +7 -0
- package/dist/composables/index.js +1 -0
- package/dist/composables/use-fetch.js +30 -2
- package/dist/composables/use-form.d.ts +91 -0
- package/dist/composables/use-form.js +112 -0
- package/dist/composables.d.ts +64 -60
- package/dist/computed.d.ts +86 -92
- package/dist/conditionals.d.ts +24 -8
- package/dist/conditionals.js +16 -0
- package/dist/config.d.ts +34 -21
- package/dist/config.js +35 -14
- package/dist/craft.js +1476 -768
- package/dist/crosswind-config.d.ts +58 -0
- package/dist/crosswind-config.js +40 -0
- package/dist/csp.d.ts +107 -41
- package/dist/defer.d.ts +24 -0
- package/dist/dev-server/crosswind.d.ts +35 -26
- package/dist/dev-server/crosswind.js +2 -18
- package/dist/dev-server/serve-app.js +4 -3
- package/dist/dev-server/terminal-colors.d.ts +32 -32
- package/dist/directive-api.d.ts +86 -43
- package/dist/document-shell.d.ts +54 -41
- package/dist/dynamic-components.d.ts +9 -0
- package/dist/error-boundaries.d.ts +47 -41
- package/dist/error-handling.d.ts +1 -1
- package/dist/errors/codes.d.ts +51 -43
- package/dist/errors/formatter.d.ts +58 -38
- package/dist/errors/index.d.ts +5 -61
- package/dist/errors/logger.d.ts +114 -40
- package/dist/errors/sanitizer.d.ts +53 -23
- package/dist/errors/types.d.ts +44 -31
- package/dist/events.d.ts +86 -25
- package/dist/expressions.d.ts +50 -42
- package/dist/forms-validation.d.ts +138 -123
- package/dist/forms-validation.js +1 -90
- package/dist/forms.d.ts +120 -66
- package/dist/forms.js +31 -11
- package/dist/fragment-container.d.ts +57 -0
- package/dist/fragment-container.js +109 -0
- package/dist/framework-composables.d.ts +32 -0
- package/dist/head.d.ts +156 -114
- package/dist/heatmap.d.ts +152 -72
- package/dist/html-masking.d.ts +40 -34
- package/dist/hydration-runtime.d.ts +20 -24
- package/dist/i18n.d.ts +93 -32
- package/dist/image-optimization/auto-sibling.d.ts +32 -4
- package/dist/includes.d.ts +69 -7
- package/dist/index.d.ts +66 -0
- package/dist/index.js +23 -0
- package/dist/internal-markdown.d.ts +12 -8
- package/dist/island-chunking.d.ts +30 -13
- package/dist/keep-alive.d.ts +72 -52
- package/dist/layout-types.d.ts +45 -0
- package/dist/layout-types.js +56 -0
- package/dist/lazy-module.d.ts +10 -0
- package/dist/loops.d.ts +66 -0
- package/dist/loops.js +47 -6
- package/dist/markdown.d.ts +0 -1
- package/dist/media/image/component.d.ts +25 -9
- package/dist/media/image/directive.d.ts +15 -1
- package/dist/media/image/placeholder.d.ts +20 -9
- package/dist/media/image/processor/cache.d.ts +40 -18
- package/dist/media/image/processor/index.d.ts +1 -10
- package/dist/media/image/processor/optimizer.d.ts +12 -1
- package/dist/media/image/processor/responsive.d.ts +16 -6
- package/dist/media/image/srcset.d.ts +47 -50
- package/dist/media/shared/cache.d.ts +51 -31
- package/dist/media/shared/hash.d.ts +7 -0
- package/dist/media/types.d.ts +1235 -754
- package/dist/media/video/directive.d.ts +15 -1
- package/dist/media/video/index.d.ts +39 -17
- package/dist/media/video/processor/cache.d.ts +42 -19
- package/dist/media/video/processor/index.d.ts +1 -18
- package/dist/media/video/processor/streaming.d.ts +17 -10
- package/dist/media/video/processor/thumbnail.d.ts +21 -15
- package/dist/media/video/processor/transcoder.d.ts +11 -1
- package/dist/method-spoofing.d.ts +7 -0
- package/dist/middleware.d.ts +60 -0
- package/dist/owned-routes.d.ts +42 -0
- package/dist/owned-routes.js +26 -0
- package/dist/page-meta.d.ts +38 -0
- package/dist/page-meta.js +16 -0
- package/dist/parser/directive-parser.d.ts +57 -45
- package/dist/parser/expression-parser.d.ts +33 -35
- package/dist/parser/index.d.ts +4 -39
- package/dist/parser/tokenizer.d.ts +61 -49
- package/dist/partial-hydration.d.ts +82 -50
- package/dist/performance-utils.d.ts +217 -124
- package/dist/placeholder.d.ts +18 -9
- package/dist/plugin-system.d.ts +264 -115
- package/dist/process.d.ts +11 -6
- package/dist/process.js +21 -4
- package/dist/production-builder.js +7 -0
- package/dist/prop-sentinels.d.ts +11 -11
- package/dist/public-env.d.ts +14 -0
- package/dist/pwa/directives.d.ts +12 -3
- package/dist/pwa/inject.d.ts +10 -0
- package/dist/pwa/precache.d.ts +22 -16
- package/dist/pwa/service-worker.d.ts +12 -0
- package/dist/pwa.js +1318 -610
- package/dist/reactive-bindings.d.ts +34 -11
- package/dist/reactive.d.ts +58 -30
- package/dist/reactive.js +56 -31
- package/dist/render.js +1 -0
- package/dist/route-middleware.d.ts +2 -35
- package/dist/route-types.d.ts +134 -0
- package/dist/route-types.js +24 -0
- package/dist/router.d.ts +5 -7
- package/dist/routes.d.ts +1 -3
- package/dist/runtime-globals.d.ts +147 -24
- package/dist/runtime-globals.js +16 -1
- package/dist/runtime-injection.d.ts +8 -0
- package/dist/runtime-injection.js +33 -24
- package/dist/script-emit.d.ts +30 -0
- package/dist/script-json.d.ts +36 -0
- package/dist/script-json.js +6 -0
- package/dist/script-validation.d.ts +21 -4
- package/dist/seo.d.ts +118 -47
- package/dist/server-bindings.d.ts +21 -0
- package/dist/sfc-template.d.ts +8 -8
- package/dist/signal-processing.d.ts +35 -15
- package/dist/signals-api.d.ts +117 -58
- package/dist/signals-api.js +7 -4
- package/dist/signals.d.ts +24 -17
- package/dist/signals.js +765 -60
- package/dist/site-builder/build.js +8 -0
- package/dist/site-url.d.ts +46 -0
- package/dist/site-url.js +70 -0
- package/dist/slots.d.ts +86 -20
- package/dist/source-signature.d.ts +45 -0
- package/dist/source-signature.js +20 -0
- package/dist/ssg.d.ts +285 -142
- package/dist/ssg.js +1268 -556
- package/dist/state-dir.d.ts +4 -4
- package/dist/state-management.d.ts +0 -12
- package/dist/state-management.js +8 -25
- package/dist/store-imports.d.ts +23 -0
- package/dist/store-imports.js +3 -0
- package/dist/store-loader.d.ts +10 -0
- package/dist/store-loader.js +10 -9
- package/dist/story/analytics.d.ts +138 -60
- package/dist/story/bookmarks.d.ts +87 -34
- package/dist/story/cli.d.ts +123 -69
- package/dist/story/collect/scanner.d.ts +4 -0
- package/dist/story/collect/tree.d.ts +8 -1
- package/dist/story/commands/build.d.ts +11 -6
- package/dist/story/commands/dev.d.ts +15 -8
- package/dist/story/commands/preview.d.ts +13 -7
- package/dist/story/config-watcher.d.ts +20 -13
- package/dist/story/config.d.ts +11 -8
- package/dist/story/context.d.ts +14 -8
- package/dist/story/hmr.d.ts +24 -26
- package/dist/story/hot-swap.d.ts +34 -23
- package/dist/story/keyboard-shortcuts.d.ts +23 -18
- package/dist/story/output.d.ts +46 -44
- package/dist/story/performance.d.ts +107 -45
- package/dist/story/presets.d.ts +107 -41
- package/dist/story/renderer.d.ts +41 -27
- package/dist/story/search.d.ts +23 -12
- package/dist/story/server.d.ts +21 -11
- package/dist/story/setup.d.ts +23 -15
- package/dist/story/testing.d.ts +65 -40
- package/dist/story/types.d.ts +262 -160
- package/dist/streaming.d.ts +119 -57
- package/dist/stx-virtual-ts.d.ts +165 -0
- package/dist/stx-virtual-ts.js +372 -0
- package/dist/stx.d.ts +78 -1
- package/dist/style-scoping.d.ts +17 -4
- package/dist/suspense.d.ts +67 -52
- package/dist/teleport.d.ts +22 -0
- package/dist/template-tag-balance.d.ts +22 -6
- package/dist/transitions.d.ts +66 -55
- package/dist/typecheck.d.ts +77 -0
- package/dist/typecheck.js +156 -0
- package/dist/types/component-types.d.ts +187 -122
- package/dist/types/config-types.d.ts +758 -297
- package/dist/types/context-types.d.ts +46 -24
- package/dist/types/csp-types.d.ts +70 -66
- package/dist/types/directive-types.d.ts +211 -155
- package/dist/types/index.d.ts +6 -109
- package/dist/types/pwa-types.d.ts +273 -148
- package/dist/types.d.ts +0 -1
- package/dist/typescript-templates.d.ts +11 -0
- package/dist/unresolved-identifiers.d.ts +24 -22
- package/dist/unresolved-identifiers.js +2 -0
- package/dist/utils.d.ts +24 -21
- package/dist/validator.d.ts +28 -26
- package/dist/variable-extractor.d.ts +48 -13
- package/dist/variable-extractor.js +27 -4
- package/dist/view-composers.d.ts +80 -81
- package/dist/virtual-scrolling.d.ts +101 -81
- package/dist/vue-template.d.ts +23 -0
- package/dist/web-components/css-scoping.d.ts +21 -11
- package/dist/web-components.d.ts +81 -58
- package/dist/x-element.d.ts +0 -1
- package/package.json +5 -5
- package/stx.d.ts +78 -1
package/dist/state-dir.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/** The directory used when nothing configures one. */
|
|
2
|
+
export declare const DEFAULT_STATE_DIR = ".stx";
|
|
3
|
+
/** Environment variable that overrides both the config and the default. */
|
|
4
|
+
export declare const STATE_DIR_ENV_VAR = "STX_DIR";
|
|
1
5
|
/**
|
|
2
6
|
* Records the `stateDir` coming from `stx.config.ts`.
|
|
3
7
|
*
|
|
@@ -30,7 +34,3 @@ export declare function stateDir(root?: string, ...segments: string[]): string;
|
|
|
30
34
|
*/
|
|
31
35
|
export declare function rebaseOntoStateDir(value: string): string;
|
|
32
36
|
export declare function rebaseOntoStateDir(value: string | undefined): string | undefined;
|
|
33
|
-
/** The directory used when nothing configures one. */
|
|
34
|
-
export declare const DEFAULT_STATE_DIR: '.stx';
|
|
35
|
-
/** Environment variable that overrides both the config and the default. */
|
|
36
|
-
export declare const STATE_DIR_ENV_VAR: 'STX_DIR';
|
|
@@ -75,18 +75,6 @@ export declare function createStoreDirective(storeName: string): {
|
|
|
75
75
|
hasEndTag: boolean
|
|
76
76
|
handler: () => string
|
|
77
77
|
};
|
|
78
|
-
/**
|
|
79
|
-
* Serialize all stores for SSR hydration.
|
|
80
|
-
*/
|
|
81
|
-
export declare function serializeStores(): string;
|
|
82
|
-
/**
|
|
83
|
-
* Hydrate stores from serialized state.
|
|
84
|
-
*/
|
|
85
|
-
export declare function hydrateStores(serialized: string): void;
|
|
86
|
-
/**
|
|
87
|
-
* Generate hydration script for SSR.
|
|
88
|
-
*/
|
|
89
|
-
export declare function generateHydrationScript(): string;
|
|
90
78
|
/**
|
|
91
79
|
* Initialize DevTools integration.
|
|
92
80
|
*/
|
package/dist/state-management.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { recordStoreMutation, registerStore as registerDevToolsStore } from "./devtools.js";
|
|
1
2
|
const globalState = {
|
|
2
3
|
stores: new Map,
|
|
3
4
|
subscriptions: new Map
|
|
@@ -105,8 +106,9 @@ export function createStore(initialValue, options = {}) {
|
|
|
105
106
|
console.error("[stx-store] Subscriber error:", error);
|
|
106
107
|
}
|
|
107
108
|
}, devToolsNotify = devtools ? (action, newValue) => {
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
recordStoreMutation(name || "unnamed", action, currentValue, newValue);
|
|
110
|
+
if (typeof window < "u")
|
|
111
|
+
window.__STX_DEVTOOLS__?.onStoreChange?.(name || "unnamed", action, newValue);
|
|
110
112
|
} : () => {}, baseSet = (value) => {
|
|
111
113
|
const prevValue = currentValue;
|
|
112
114
|
if (!equals(value, prevValue)) {
|
|
@@ -152,8 +154,11 @@ export function createStore(initialValue, options = {}) {
|
|
|
152
154
|
};
|
|
153
155
|
for (const mw of middleware.reverse())
|
|
154
156
|
wrappedSet = mw(baseSet, () => currentValue, store)(wrappedSet);
|
|
155
|
-
if (name)
|
|
157
|
+
if (name) {
|
|
156
158
|
registerStore(name, store);
|
|
159
|
+
if (devtools)
|
|
160
|
+
registerDevToolsStore(name, currentValue ?? {}, {}, []);
|
|
161
|
+
}
|
|
157
162
|
return store;
|
|
158
163
|
}
|
|
159
164
|
export function createReadonlyStore(getter, options = {}) {
|
|
@@ -324,28 +329,6 @@ export function createStoreDirective(storeName) {
|
|
|
324
329
|
}
|
|
325
330
|
};
|
|
326
331
|
}
|
|
327
|
-
export function serializeStores() {
|
|
328
|
-
const state = {};
|
|
329
|
-
for (const [name, store] of globalState.stores.entries())
|
|
330
|
-
state[name] = store.get();
|
|
331
|
-
return JSON.stringify(state);
|
|
332
|
-
}
|
|
333
|
-
export function hydrateStores(serialized) {
|
|
334
|
-
try {
|
|
335
|
-
const state = JSON.parse(serialized);
|
|
336
|
-
for (const [name, value] of Object.entries(state)) {
|
|
337
|
-
const store = getStore(name);
|
|
338
|
-
if (store)
|
|
339
|
-
store.set(value);
|
|
340
|
-
}
|
|
341
|
-
} catch (error) {
|
|
342
|
-
console.error("[stx-store] Hydration failed:", error);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
export function generateHydrationScript() {
|
|
346
|
-
return `<script>window.__STX_STORE_STATE__=${serializeStores()};
|
|
347
|
-
if(window.__STX_HYDRATE_STORES__){window.__STX_HYDRATE_STORES__()}</script>`;
|
|
348
|
-
}
|
|
349
332
|
export function initDevTools() {
|
|
350
333
|
if (typeof window > "u")
|
|
351
334
|
return;
|
package/dist/store-imports.d.ts
CHANGED
|
@@ -22,3 +22,26 @@
|
|
|
22
22
|
* Also transforms @composables imports to window.__composables.
|
|
23
23
|
*/
|
|
24
24
|
export declare function transformStoreImports(code: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Remove `import` statements from a store or composable module body.
|
|
27
|
+
*
|
|
28
|
+
* These files are concatenated into one browser IIFE, so their imports have to
|
|
29
|
+
* go: `state`, `derived` and `defineStore` are runtime globals rather than real
|
|
30
|
+
* modules, and leaving the statements in makes the transpiler emit `require()`
|
|
31
|
+
* calls that fail in the browser.
|
|
32
|
+
*
|
|
33
|
+
* The previous pattern was line-anchored (`^import\s+.*from …$`), so a
|
|
34
|
+
* multi-line specifier list survived it — and survived Bun's transpiler too,
|
|
35
|
+
* because `import` is legal at a module's top level. It only failed once the
|
|
36
|
+
* body had been wrapped in the shared IIFE, where an import is a SyntaxError
|
|
37
|
+
* that takes EVERY store in the bundle with it, reported as a misleading
|
|
38
|
+
* "Store not found" (stacksjs/stx#1859).
|
|
39
|
+
*
|
|
40
|
+
* `[^'"]` between `import` and `from` is what keeps a multi-line match from
|
|
41
|
+
* running past its own statement into the next one's specifier: the clause
|
|
42
|
+
* never contains a quote, and the module specifier always does.
|
|
43
|
+
*
|
|
44
|
+
* Shared by both loaders because they carried byte-identical copies, which is
|
|
45
|
+
* how one of them would have been fixed and the other left behind.
|
|
46
|
+
*/
|
|
47
|
+
export declare function stripModuleImports(code: string): string;
|
package/dist/store-imports.js
CHANGED
package/dist/store-loader.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Store Auto-Loader
|
|
3
|
+
*
|
|
4
|
+
* Discovers .ts files in storesDir, bundles them with Bun.build,
|
|
5
|
+
* and returns a <script> tag to inject into the page. Stores are
|
|
6
|
+
* registered before any <script client> blocks run, so useStore()
|
|
7
|
+
* always finds them.
|
|
8
|
+
*
|
|
9
|
+
* @module store-loader
|
|
10
|
+
*/
|
|
1
11
|
export declare function getStoreScript(storesDir?: string): Promise<string | null>;
|
|
2
12
|
/**
|
|
3
13
|
* Clear the cached store script (for dev mode hot reload).
|
package/dist/store-loader.js
CHANGED
|
@@ -2,7 +2,8 @@ import path from "node:path";
|
|
|
2
2
|
import { loadStxConfig } from "./config.js";
|
|
3
3
|
import { getPublicEnvDefine } from "./public-env.js";
|
|
4
4
|
import { STX_RUNTIME_GLOBALS } from "./runtime-globals.js";
|
|
5
|
-
import {
|
|
5
|
+
import { readSigned, sourceSignature, writeSigned } from "./source-signature.js";
|
|
6
|
+
import { stripModuleImports, transformStoreImports } from "./store-imports.js";
|
|
6
7
|
const _cachedStoreScripts = new Map;
|
|
7
8
|
function collectDeclaredNames(code, into) {
|
|
8
9
|
for (const match of code.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))
|
|
@@ -29,9 +30,6 @@ export async function getStoreScript(storesDir) {
|
|
|
29
30
|
const config = await loadStxConfig();
|
|
30
31
|
resolvedDir = path.resolve(config.root || process.cwd(), config.storesDir || "stores");
|
|
31
32
|
}
|
|
32
|
-
const cached = _cachedStoreScripts.get(resolvedDir);
|
|
33
|
-
if (cached !== void 0)
|
|
34
|
-
return cached || null;
|
|
35
33
|
const glob = new Bun.Glob("*.ts"), storeFiles = [];
|
|
36
34
|
try {
|
|
37
35
|
for await (const file of glob.scan({ cwd: resolvedDir, absolute: !0 })) {
|
|
@@ -43,11 +41,14 @@ export async function getStoreScript(storesDir) {
|
|
|
43
41
|
storeFiles.push(file);
|
|
44
42
|
}
|
|
45
43
|
} catch {
|
|
46
|
-
_cachedStoreScripts
|
|
44
|
+
writeSigned(_cachedStoreScripts, resolvedDir, "", "");
|
|
47
45
|
return null;
|
|
48
46
|
}
|
|
47
|
+
const signature = sourceSignature(storeFiles), cached = readSigned(_cachedStoreScripts, resolvedDir, signature);
|
|
48
|
+
if (cached !== void 0)
|
|
49
|
+
return cached || null;
|
|
49
50
|
if (storeFiles.length === 0) {
|
|
50
|
-
_cachedStoreScripts
|
|
51
|
+
writeSigned(_cachedStoreScripts, resolvedDir, signature, "");
|
|
51
52
|
return null;
|
|
52
53
|
}
|
|
53
54
|
const filesWithDeps = [];
|
|
@@ -70,7 +71,7 @@ export async function getStoreScript(storesDir) {
|
|
|
70
71
|
const storeName = path.basename(file, ".ts");
|
|
71
72
|
collectDeclaredNames(code, declaredNames);
|
|
72
73
|
code = transformStoreImports(code);
|
|
73
|
-
code = code
|
|
74
|
+
code = stripModuleImports(code);
|
|
74
75
|
code = code.replace(/^export\s+(default\s+)?/gm, "");
|
|
75
76
|
code = transpiler.transformSync(code);
|
|
76
77
|
chunks.push(`// Store: ${storeName}
|
|
@@ -79,7 +80,7 @@ ${code.trim()}`);
|
|
|
79
80
|
console.warn(`[stx] Failed to load store ${file}:`, e);
|
|
80
81
|
}
|
|
81
82
|
if (chunks.length === 0) {
|
|
82
|
-
_cachedStoreScripts
|
|
83
|
+
writeSigned(_cachedStoreScripts, resolvedDir, signature, "");
|
|
83
84
|
return null;
|
|
84
85
|
}
|
|
85
86
|
const joinedChunks = chunks.join(`
|
|
@@ -90,7 +91,7 @@ ${STX_RUNTIME_GLOBALS.filter((name) => !declaredNames.has(name) && new RegExp(`\
|
|
|
90
91
|
`)}
|
|
91
92
|
${joinedChunks}
|
|
92
93
|
})();`;
|
|
93
|
-
_cachedStoreScripts
|
|
94
|
+
writeSigned(_cachedStoreScripts, resolvedDir, signature, code);
|
|
94
95
|
return code;
|
|
95
96
|
}
|
|
96
97
|
export function clearStoreCache() {
|
|
@@ -1,85 +1,163 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* STX Story - Component Usage Analytics
|
|
3
|
+
* Track which components are viewed most, which props are changed most
|
|
3
4
|
*/
|
|
4
|
-
export declare function getAnalyticsDashboardHtml(mostViewed: Array<{ componentId: string, viewCount: number }>, mostChangedProps: Array<{ propName: string, changeCount: number }>): string;
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Analytics event types
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export type AnalyticsEventType = 'view' | 'prop_change' | 'variant_switch' | 'search' | 'bookmark' | 'copy_code' | 'test_run';
|
|
9
9
|
/**
|
|
10
10
|
* Analytics event
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
export interface AnalyticsEvent {
|
|
13
|
+
/** Event type */
|
|
14
|
+
type: AnalyticsEventType;
|
|
15
|
+
/** Timestamp */
|
|
16
|
+
timestamp: number;
|
|
17
|
+
/** Component ID */
|
|
18
|
+
componentId?: string;
|
|
19
|
+
/** Variant ID */
|
|
20
|
+
variantId?: string;
|
|
21
|
+
/** Prop name (for prop_change) */
|
|
22
|
+
propName?: string;
|
|
23
|
+
/** Search query (for search) */
|
|
24
|
+
query?: string;
|
|
25
|
+
/** Additional metadata */
|
|
26
|
+
metadata?: Record<string, any>;
|
|
20
27
|
}
|
|
21
28
|
/**
|
|
22
29
|
* Component analytics summary
|
|
23
30
|
*/
|
|
24
|
-
export
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
export interface ComponentAnalytics {
|
|
32
|
+
/** Component ID */
|
|
33
|
+
componentId: string;
|
|
34
|
+
/** Component name */
|
|
35
|
+
componentName: string;
|
|
36
|
+
/** Total views */
|
|
37
|
+
viewCount: number;
|
|
38
|
+
/** Unique view sessions */
|
|
39
|
+
uniqueViews: number;
|
|
40
|
+
/** Last viewed timestamp */
|
|
41
|
+
lastViewed?: number;
|
|
42
|
+
/** Prop change counts */
|
|
43
|
+
propChanges: Record<string, number>;
|
|
44
|
+
/** Most changed props */
|
|
45
|
+
topChangedProps: string[];
|
|
46
|
+
/** Variant view counts */
|
|
47
|
+
variantViews: Record<string, number>;
|
|
48
|
+
/** Average time spent (ms) */
|
|
49
|
+
avgTimeSpent: number;
|
|
34
50
|
}
|
|
35
51
|
/**
|
|
36
52
|
* Analytics storage
|
|
37
53
|
*/
|
|
38
|
-
export
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
54
|
+
export interface AnalyticsStorage {
|
|
55
|
+
version: number;
|
|
56
|
+
events: AnalyticsEvent[];
|
|
57
|
+
sessions: AnalyticsSession[];
|
|
42
58
|
}
|
|
43
59
|
/**
|
|
44
60
|
* Analytics session
|
|
45
61
|
*/
|
|
46
|
-
export
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
62
|
+
export interface AnalyticsSession {
|
|
63
|
+
id: string;
|
|
64
|
+
startTime: number;
|
|
65
|
+
endTime?: number;
|
|
66
|
+
componentViews: string[];
|
|
51
67
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Analytics event types
|
|
54
|
-
*/
|
|
55
|
-
export type AnalyticsEventType = | 'view'
|
|
56
|
-
| 'prop_change'
|
|
57
|
-
| 'variant_switch'
|
|
58
|
-
| 'search'
|
|
59
|
-
| 'bookmark'
|
|
60
|
-
| 'copy_code'
|
|
61
|
-
| 'test_run';
|
|
62
68
|
/**
|
|
63
69
|
* Analytics tracker
|
|
64
70
|
*/
|
|
65
71
|
export declare class AnalyticsTracker {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
72
|
+
private storage;
|
|
73
|
+
private storagePath;
|
|
74
|
+
private currentSession;
|
|
75
|
+
private dirty;
|
|
76
|
+
private viewStartTimes;
|
|
77
|
+
constructor(rootDir: string);
|
|
78
|
+
private loadStorage;
|
|
79
|
+
save(): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Start a new session
|
|
82
|
+
*/
|
|
83
|
+
startSession(): void;
|
|
84
|
+
/**
|
|
85
|
+
* End current session
|
|
86
|
+
*/
|
|
87
|
+
endSession(): void;
|
|
88
|
+
/**
|
|
89
|
+
* Track an event
|
|
90
|
+
*/
|
|
91
|
+
track(event: Omit<AnalyticsEvent, 'timestamp'>): void;
|
|
92
|
+
/**
|
|
93
|
+
* Track component view
|
|
94
|
+
*/
|
|
95
|
+
trackView(componentId: string, variantId?: string): void;
|
|
96
|
+
/**
|
|
97
|
+
* End view timing for a component
|
|
98
|
+
*/
|
|
99
|
+
private endViewTiming;
|
|
100
|
+
/**
|
|
101
|
+
* Track prop change
|
|
102
|
+
*/
|
|
103
|
+
trackPropChange(componentId: string, propName: string, value: any): void;
|
|
104
|
+
/**
|
|
105
|
+
* Track variant switch
|
|
106
|
+
*/
|
|
107
|
+
trackVariantSwitch(componentId: string, variantId: string): void;
|
|
108
|
+
/**
|
|
109
|
+
* Track search
|
|
110
|
+
*/
|
|
111
|
+
trackSearch(query: string, resultCount: number): void;
|
|
112
|
+
/**
|
|
113
|
+
* Get analytics for a component
|
|
114
|
+
*/
|
|
115
|
+
getComponentAnalytics(componentId: string, componentName: string): ComponentAnalytics;
|
|
116
|
+
/**
|
|
117
|
+
* Get most viewed components
|
|
118
|
+
*/
|
|
119
|
+
getMostViewedComponents(limit?: number): Array<{
|
|
120
|
+
componentId: string;
|
|
121
|
+
viewCount: number;
|
|
122
|
+
}>;
|
|
123
|
+
/**
|
|
124
|
+
* Get most changed props across all components
|
|
125
|
+
*/
|
|
126
|
+
getMostChangedProps(limit?: number): Array<{
|
|
127
|
+
propName: string;
|
|
128
|
+
changeCount: number;
|
|
129
|
+
}>;
|
|
130
|
+
/**
|
|
131
|
+
* Get search analytics
|
|
132
|
+
*/
|
|
133
|
+
getSearchAnalytics(): {
|
|
134
|
+
totalSearches: number;
|
|
135
|
+
topQueries: Array<{
|
|
136
|
+
query: string;
|
|
137
|
+
count: number;
|
|
138
|
+
}>;
|
|
139
|
+
avgResultCount: number;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Clear all analytics
|
|
143
|
+
*/
|
|
144
|
+
clear(): void;
|
|
145
|
+
/**
|
|
146
|
+
* Export analytics as JSON
|
|
147
|
+
*/
|
|
148
|
+
exportAnalytics(): string;
|
|
85
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Generate analytics dashboard HTML
|
|
152
|
+
*/
|
|
153
|
+
export declare function getAnalyticsDashboardHtml(mostViewed: Array<{
|
|
154
|
+
componentId: string;
|
|
155
|
+
viewCount: number;
|
|
156
|
+
}>, mostChangedProps: Array<{
|
|
157
|
+
propName: string;
|
|
158
|
+
changeCount: number;
|
|
159
|
+
}>): string;
|
|
160
|
+
/**
|
|
161
|
+
* Generate analytics styles
|
|
162
|
+
*/
|
|
163
|
+
export declare function getAnalyticsStyles(): string;
|
|
@@ -1,49 +1,102 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
export declare function getBookmarksPanelHtml(bookmarks: Bookmark[]): string;
|
|
5
|
-
/**
|
|
6
|
-
* Generate bookmarks panel styles
|
|
2
|
+
* STX Story - Bookmarks
|
|
3
|
+
* Bookmark component+variant+props combinations for quick access
|
|
7
4
|
*/
|
|
8
|
-
export declare function getBookmarksPanelStyles(): string;
|
|
9
|
-
/**
|
|
10
|
-
* Generate bookmarks client script
|
|
11
|
-
*/
|
|
12
|
-
export declare function getBookmarksScript(): string;
|
|
13
5
|
/**
|
|
14
6
|
* Bookmark entry
|
|
15
7
|
*/
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
8
|
+
export interface Bookmark {
|
|
9
|
+
/** Bookmark ID */
|
|
10
|
+
id: string;
|
|
11
|
+
/** Display name */
|
|
12
|
+
name: string;
|
|
13
|
+
/** Story ID */
|
|
14
|
+
storyId: string;
|
|
15
|
+
/** Variant ID */
|
|
16
|
+
variantId: string;
|
|
17
|
+
/** Props state */
|
|
18
|
+
props: Record<string, any>;
|
|
19
|
+
/** Created timestamp */
|
|
20
|
+
created: number;
|
|
21
|
+
/** Notes */
|
|
22
|
+
notes?: string;
|
|
23
|
+
/** Color label */
|
|
24
|
+
color?: string;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Bookmarks storage
|
|
28
28
|
*/
|
|
29
|
-
export
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
export interface BookmarksStorage {
|
|
30
|
+
version: number;
|
|
31
|
+
bookmarks: Bookmark[];
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* Bookmarks manager
|
|
35
35
|
*/
|
|
36
36
|
export declare class BookmarksManager {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
37
|
+
private storage;
|
|
38
|
+
private storagePath;
|
|
39
|
+
private dirty;
|
|
40
|
+
constructor(rootDir: string);
|
|
41
|
+
private loadStorage;
|
|
42
|
+
save(): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Add a bookmark
|
|
45
|
+
*/
|
|
46
|
+
addBookmark(storyId: string, variantId: string, props: Record<string, any>, options?: {
|
|
47
|
+
name?: string;
|
|
48
|
+
notes?: string;
|
|
49
|
+
color?: string;
|
|
50
|
+
}): Bookmark;
|
|
51
|
+
/**
|
|
52
|
+
* Get all bookmarks
|
|
53
|
+
*/
|
|
54
|
+
getAllBookmarks(): Bookmark[];
|
|
55
|
+
/**
|
|
56
|
+
* Get bookmarks for a story
|
|
57
|
+
*/
|
|
58
|
+
getBookmarksForStory(storyId: string): Bookmark[];
|
|
59
|
+
/**
|
|
60
|
+
* Get a bookmark by ID
|
|
61
|
+
*/
|
|
62
|
+
getBookmark(id: string): Bookmark | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Check if a combination is bookmarked
|
|
65
|
+
*/
|
|
66
|
+
isBookmarked(storyId: string, variantId: string): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Update a bookmark
|
|
69
|
+
*/
|
|
70
|
+
updateBookmark(id: string, updates: Partial<Omit<Bookmark, 'id' | 'created'>>): Bookmark | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Delete a bookmark
|
|
73
|
+
*/
|
|
74
|
+
deleteBookmark(id: string): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Toggle bookmark for a combination
|
|
77
|
+
*/
|
|
78
|
+
toggleBookmark(storyId: string, variantId: string, props: Record<string, any>): {
|
|
79
|
+
added: boolean;
|
|
80
|
+
bookmark?: Bookmark;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Export bookmarks
|
|
84
|
+
*/
|
|
85
|
+
exportBookmarks(): string;
|
|
86
|
+
/**
|
|
87
|
+
* Import bookmarks
|
|
88
|
+
*/
|
|
89
|
+
importBookmarks(json: string, merge?: boolean): number;
|
|
49
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Generate bookmarks panel HTML
|
|
93
|
+
*/
|
|
94
|
+
export declare function getBookmarksPanelHtml(bookmarks: Bookmark[]): string;
|
|
95
|
+
/**
|
|
96
|
+
* Generate bookmarks panel styles
|
|
97
|
+
*/
|
|
98
|
+
export declare function getBookmarksPanelStyles(): string;
|
|
99
|
+
/**
|
|
100
|
+
* Generate bookmarks client script
|
|
101
|
+
*/
|
|
102
|
+
export declare function getBookmarksScript(): string;
|