@stacksjs/stx-vscode 0.2.357 → 0.2.358

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/README.md CHANGED
@@ -28,6 +28,16 @@ The static half has to be in your extension's manifest, because VS Code reads gr
28
28
 
29
29
  `vscode`, `prettier` and `@stacksjs/ts-css` are imported, not bundled: bundle the library into your extension.
30
30
 
31
+ ## Type checking `.stx` files
32
+
33
+ The TypeScript server plugin ships too, as a complete package in `dist/typescript-plugin/` (`@stacksjs/stx-typescript-plugin/...` is exported as `@stacksjs/stx-vscode/typescript-plugin/*`). To type-check `.stx` files in the editor:
34
+
35
+ 1. Declare `typescriptServerPlugins` from `contributes.json` in your manifest.
36
+ 2. Put the package where tsserver looks for it: tsserver loads a plugin only by package name, from `<your extension>/node_modules/@stacksjs/stx-typescript-plugin`. If you package with `vsce --no-dependencies`, which leaves `node_modules` out, ship the directory elsewhere in the VSIX and add a two-file forwarder package under `node_modules` after `vsce` writes it, as the Stacks extension does.
37
+ 3. Call `configureTypeScriptPlugin(vscode, context.subscriptions)` in `activate`. It starts VS Code's TypeScript extension, which does not activate on `stx` by itself, and forwards `stxTypescriptPlugin.enabled` to the plugin.
38
+
39
+ The stx extension contributes the same plugin under the same name. With both extensions installed, tsserver loads it once per contribution, and the plugin decorates each project only the first time.
40
+
31
41
  ## License
32
42
 
33
43
  MIT
@@ -166,5 +166,14 @@
166
166
  "markdownDescription": "Pixels per `rem` for the px values utility-class hovers show next to `rem` values. `0` hides them. Replaces `css.remToPxRatio`, which is still read when this is not set."
167
167
  }
168
168
  }
169
- }
169
+ },
170
+ "typescriptServerPlugins": [
171
+ {
172
+ "name": "@stacksjs/stx-typescript-plugin",
173
+ "enableForWorkspaceTypeScriptVersions": true,
174
+ "languages": [
175
+ "stx"
176
+ ]
177
+ }
178
+ ]
170
179
  }
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Written by hand rather than generated: the implementation (packages/vscode/src)
5
5
  * is typed against `@types/vscode`, and generating from it would make every
6
- * consumer install those types to read four functions.
6
+ * consumer install those types to read a handful of functions.
7
7
  */
8
8
 
9
9
  /** The marketplace ID of the standalone stx extension. */
@@ -46,3 +46,35 @@ export interface StxLanguageOptions {
46
46
  export declare function activateStxLanguage(context: StxExtensionContext, options: StxLanguageOptions): Promise<void>
47
47
 
48
48
  export declare function deactivateStxLanguage(): void
49
+
50
+ /** The name the TypeScript server plugin is contributed and configured under. */
51
+ export declare const TS_PLUGIN_NAME: '@stacksjs/stx-typescript-plugin'
52
+
53
+ /** The settings section the plugin reads (`stxTypescriptPlugin.enabled`). */
54
+ export declare const TS_PLUGIN_SETTINGS: 'stxTypescriptPlugin'
55
+
56
+ /** VS Code's built-in TypeScript extension. */
57
+ export declare const TYPESCRIPT_EXTENSION_ID: 'vscode.typescript-language-features'
58
+
59
+ /** The part of the `vscode` API `configureTypeScriptPlugin` uses. */
60
+ export interface TsPluginHostApi {
61
+ extensions: {
62
+ getExtension: (id: string) => { isActive: boolean, exports: unknown, activate: () => PromiseLike<unknown> } | undefined
63
+ }
64
+ workspace: {
65
+ getConfiguration: (section: string) => { get: <T>(key: string, fallback: T) => T }
66
+ onDidChangeConfiguration: (listener: (event: { affectsConfiguration: (section: string) => boolean }) => void) => { dispose: () => void }
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Start VS Code's TypeScript extension, which does not activate on `stx` by
72
+ * itself, and forward `stxTypescriptPlugin.enabled` to the plugin now and on
73
+ * every change. Resolves to whether the TypeScript API was reached.
74
+ *
75
+ * Pass the `vscode` module as `api`. Call it from any extension that
76
+ * contributes the plugin (`typescriptServerPlugins` in `contributes.json`);
77
+ * with the stx extension installed too, both contribute and configure it and
78
+ * the plugin decorates each project once.
79
+ */
80
+ export declare function configureTypeScriptPlugin(api: TsPluginHostApi, subscriptions: Array<{ dispose: () => void }>): Promise<boolean>
package/dist/index.js CHANGED
@@ -7012,6 +7012,7 @@ export {
7012
7012
  createCssCompletionProvider,
7013
7013
  createCompletionProvider,
7014
7014
  createCodeActionsProvider,
7015
+ configureTypeScriptPlugin,
7015
7016
  addRemToPxComment,
7016
7017
  activateStxLanguage,
7017
7018
  activateCss,
@@ -7020,6 +7021,9 @@ export {
7020
7021
  TransitionType,
7021
7022
  TransitionEase,
7022
7023
  TransitionDirection,
7024
+ TYPESCRIPT_EXTENSION_ID,
7025
+ TS_PLUGIN_SETTINGS,
7026
+ TS_PLUGIN_NAME,
7023
7027
  STX_EXTENSION_ID,
7024
7028
  STACKS_EXTENSION_ID,
7025
7029
  PropsTypeExtractor,
@@ -0,0 +1,3 @@
1
+ const path = require('path')
2
+ const init = require('./typescript-stx-plugin.js')
3
+ module.exports = modules => init(modules, { declarationsDir: path.join(__dirname, './types') })
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "@stacksjs/stx-typescript-plugin",
3
+ "version": "0.2.358",
4
+ "private": true,
5
+ "main": "index.js"
6
+ }
@@ -0,0 +1,154 @@
1
+ /// <reference path="./stx.d.ts" />
2
+
3
+ /**
4
+ * The `stx` module, as a `.stx` script block sees it.
5
+ *
6
+ * `stx` is a VIRTUAL specifier. No package by that name is installed in an app,
7
+ * and `import { … } from 'stx'` works only because both script paths intercept
8
+ * it: a client block's import is stripped and its names destructured off
9
+ * `window.stx`, and a server block's names are handed in by the engine as
10
+ * parameters. So what this module exports is exactly what those two paths bind,
11
+ * and nothing else from `@stacksjs/stx` (see src/stx-module-imports.ts):
12
+ *
13
+ * - every name destructured off `window.stx` (STX_RUNTIME_GLOBALS), which a
14
+ * server block also receives where the engine binds it, and
15
+ * - the stx API names only the server engine binds, marked below.
16
+ *
17
+ * Each value is typed by the ambient global of the same name in `stx.d.ts`, so
18
+ * an imported `state` is exactly the auto-imported one; the module adds no
19
+ * second copy of any signature to drift.
20
+ *
21
+ * This file is NOT referenced from the package's types entry, on purpose. The
22
+ * specifier is virtual only inside a `.stx` block; a `.ts` file importing from
23
+ * `stx` has a real import that does not resolve. `stx typecheck` and the editor
24
+ * plugin add it to the programs they build for `.stx` files.
25
+ *
26
+ * Which block kind gets which name is checked separately, because one
27
+ * declaration cannot say it: `stxImportDiagnostics` reports a server-only name
28
+ * imported into a client block and the reverse.
29
+ *
30
+ * test/stx-module-declaration.test.ts keeps this list equal to the runtime's.
31
+ */
32
+ declare module 'stx' {
33
+ export const $props: Record<string, any> // <script server> only
34
+ export const batch: typeof globalThis.batch
35
+ export const clearServerData: typeof globalThis.clearServerData
36
+ export const computed: typeof globalThis.computed
37
+ export const configureFetch: typeof globalThis.configureFetch
38
+ export const defineClientPayload: (payload: Record<string, unknown>) => void // <script server> only
39
+ export const defineEmits: typeof globalThis.defineEmits
40
+ export const defineExpose: typeof globalThis.defineExpose
41
+ export const definePageMeta: typeof globalThis.definePageMeta
42
+ export const defineProps: typeof globalThis.defineProps
43
+ export const defineSlots: typeof globalThis.defineSlots
44
+ export const defineStore: typeof globalThis.defineStore
45
+ export const derived: typeof globalThis.derived
46
+ export const effect: typeof globalThis.effect
47
+ export const goBack: typeof globalThis.goBack
48
+ export const goForward: typeof globalThis.goForward
49
+ export const inject: typeof globalThis.inject
50
+ export const invalidateRoute: typeof globalThis.invalidateRoute
51
+ export const isDerived: typeof globalThis.isDerived
52
+ export const isSignal: typeof globalThis.isSignal
53
+ export const navigate: typeof globalThis.navigate
54
+ export const nextTick: typeof globalThis.nextTick
55
+ export const notFound: (status?: number) => void // <script server> only
56
+ export const onBeforeMount: typeof globalThis.onBeforeMount
57
+ export const onBeforeUnmount: typeof globalThis.onBeforeUnmount
58
+ export const onDestroy: typeof globalThis.onDestroy
59
+ export const onMount: typeof globalThis.onMount
60
+ export const onMounted: typeof globalThis.onMounted
61
+ export const onUnmounted: typeof globalThis.onUnmounted
62
+ export const params: Record<string, string> // <script server> only
63
+ export const peek: typeof globalThis.peek
64
+ export const props: Record<string, any> // <script server> only
65
+ export const provide: typeof globalThis.provide
66
+ export const reactive: typeof globalThis.reactive
67
+ export const ref: typeof globalThis.ref
68
+ export const refresh: typeof globalThis.refresh
69
+ export const registerStoresClient: typeof globalThis.registerStoresClient
70
+ export const setResponseHeader: (name: string, value: string) => void // <script server> only
71
+ export const setResponseStatus: (status: number) => void // <script server> only
72
+ export const setRouteParams: typeof globalThis.setRouteParams
73
+ export const state: typeof globalThis.state
74
+ export const untrack: typeof globalThis.untrack
75
+ export const useAsync: typeof globalThis.useAsync
76
+ export const useClickOutside: typeof globalThis.useClickOutside
77
+ export const useColorMode: typeof globalThis.useColorMode
78
+ export const useCookie: typeof globalThis.useCookie
79
+ export const useCounter: typeof globalThis.useCounter
80
+ export const useDark: typeof globalThis.useDark
81
+ export const useDebounce: typeof globalThis.useDebounce
82
+ export const useDebouncedValue: typeof globalThis.useDebouncedValue
83
+ export const useDocumentVisibility: typeof globalThis.useDocumentVisibility
84
+ export const useEventListener: typeof globalThis.useEventListener
85
+ export const useFetch: typeof globalThis.useFetch
86
+ export const useFocus: typeof globalThis.useFocus
87
+ export const useHead: typeof globalThis.useHead
88
+ export const useId: typeof globalThis.useId
89
+ export const useInterval: typeof globalThis.useInterval
90
+ export const useLocalStorage: typeof globalThis.useLocalStorage
91
+ export const useMediaQuery: typeof globalThis.useMediaQuery
92
+ export const useModel: typeof globalThis.useModel
93
+ export const useMutation: typeof globalThis.useMutation
94
+ export const useOptimistic: typeof globalThis.useOptimistic
95
+ export const usePreferredContrast: typeof globalThis.usePreferredContrast
96
+ export const usePreferredDark: typeof globalThis.usePreferredDark
97
+ export const usePreferredLight: typeof globalThis.usePreferredLight
98
+ export const usePreferredReducedMotion: typeof globalThis.usePreferredReducedMotion
99
+ export const useQuery: typeof globalThis.useQuery
100
+ export const useReactiveProp: typeof globalThis.useReactiveProp
101
+ export const useRef: typeof globalThis.useRef
102
+ export const useRoute: typeof globalThis.useRoute
103
+ export const useRouteParam: typeof globalThis.useRouteParam
104
+ export const useRouteParams: typeof globalThis.useRouteParams
105
+ export const useRouter: () => { push: (to: unknown) => void, replace: (to: unknown) => void, back: () => void, forward: () => void, go: (n: number) => void } // <script server> only
106
+ export const useRuntimeConfig: () => Readonly<Record<string, any>> // <script server> only
107
+ export const useScrollLock: typeof globalThis.useScrollLock
108
+ export const useSearchParams: typeof globalThis.useSearchParams
109
+ export const useSeoMeta: typeof globalThis.useSeoMeta
110
+ export const useServerData: typeof globalThis.useServerData // <script server> only
111
+ export const useServerRuntimeConfig: () => Readonly<{ public: Record<string, any>, private: Record<string, any> }> // <script server> only
112
+ export const useSessionStorage: typeof globalThis.useSessionStorage
113
+ export const useSlots: typeof globalThis.useSlots
114
+ export const useStore: typeof globalThis.useStore
115
+ export const useThrottle: typeof globalThis.useThrottle
116
+ export const useTimeout: typeof globalThis.useTimeout
117
+ export const useToggle: typeof globalThis.useToggle
118
+ export const useWebSocket: typeof globalThis.useWebSocket
119
+ export const watch: typeof globalThis.watch
120
+ export const watchEffect: typeof globalThis.watchEffect
121
+ export const watchMultiple: typeof globalThis.watchMultiple
122
+ export const withDefaults: typeof globalThis.withDefaults
123
+
124
+ export type StxSignal<T> = globalThis.StxSignal<T>
125
+ export type StxDerivedSignal<T> = globalThis.StxDerivedSignal<T>
126
+ export type StxRef<T> = globalThis.StxRef<T>
127
+ export type StxCleanup = globalThis.StxCleanup
128
+ export type StxModelOptions<T> = globalThis.StxModelOptions<T>
129
+ export type StxModelSignal<T> = globalThis.StxModelSignal<T>
130
+ export type StxTemplateRef<T> = globalThis.StxTemplateRef<T>
131
+ export type StxNavigateOptions = globalThis.StxNavigateOptions
132
+ export type StxSearchParamsCommitOptions = globalThis.StxSearchParamsCommitOptions
133
+ export type StxRefetchOptions = globalThis.StxRefetchOptions
134
+ export type StxFetchResult<T> = globalThis.StxFetchResult<T>
135
+ export type StxQueryResult<T> = globalThis.StxQueryResult<T>
136
+ export type StxMutationResult<T> = globalThis.StxMutationResult<T>
137
+ export type StxFetchRequestContext = globalThis.StxFetchRequestContext
138
+ export type StxFetchResponseContext = globalThis.StxFetchResponseContext
139
+ export type StxFetchErrorContext = globalThis.StxFetchErrorContext
140
+ export type StxEventListenerOptions = globalThis.StxEventListenerOptions
141
+ export type StxIntervalOptions = globalThis.StxIntervalOptions
142
+ export type StxIntervalControls = globalThis.StxIntervalControls
143
+ export type StxCookieOptions = globalThis.StxCookieOptions
144
+ export type StxColorModeOptions = globalThis.StxColorModeOptions
145
+ export type StxHeadConfig = globalThis.StxHeadConfig
146
+ export type StxSeoMetaConfig = globalThis.StxSeoMetaConfig
147
+ export type StxToastOptions = globalThis.StxToastOptions
148
+ export type StxToast = globalThis.StxToast
149
+ export type StxModal = globalThis.StxModal
150
+ export type StxDrawer = globalThis.StxDrawer
151
+ export type StxDialogOptions = globalThis.StxDialogOptions
152
+ export type StxStorePersistOptions = globalThis.StxStorePersistOptions
153
+ export type StxStoreOptions = globalThis.StxStoreOptions
154
+ }