@vesk/compiler 0.1.14 → 0.2.8
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/api-routes.d.ts +6 -1
- package/dist/api-routes.d.ts.map +1 -1
- package/dist/api-routes.js +52 -7
- package/dist/client-codegen.d.ts +15 -0
- package/dist/client-codegen.d.ts.map +1 -1
- package/dist/client-codegen.js +73 -10
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +25 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +33 -4
- package/dist/ir-generator.d.ts.map +1 -1
- package/dist/ir-generator.js +109 -1
- package/dist/md-inline.d.ts +17 -0
- package/dist/md-inline.d.ts.map +1 -0
- package/dist/md-inline.js +149 -0
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +42 -7
- package/dist/router.d.ts +2 -0
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +48 -3
- package/dist/server-codegen.d.ts +1 -1
- package/dist/server-codegen.d.ts.map +1 -1
- package/dist/server-codegen.js +1 -1
- package/dist/server-jsgen.js +1 -1
- package/dist/server-render.d.ts.map +1 -1
- package/dist/server-render.js +14 -8
- package/dist/server-utils.d.ts +31 -0
- package/dist/server-utils.d.ts.map +1 -1
- package/dist/server-utils.js +478 -52
- package/dist/typecheck.d.ts +2 -2
- package/dist/typecheck.d.ts.map +1 -1
- package/dist/typecheck.js +66 -27
- package/dist/types.d.ts +4 -129
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/dist/vesk-plugin.d.ts +2 -0
- package/dist/vesk-plugin.d.ts.map +1 -1
- package/dist/vesk-plugin.js +152 -0
- package/dist/vsk-tsx.d.ts.map +1 -1
- package/dist/vsk-tsx.js +15 -5
- package/package.json +2 -1
package/dist/typecheck.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ export interface TypecheckError {
|
|
|
9
9
|
code: string;
|
|
10
10
|
message: string;
|
|
11
11
|
}
|
|
12
|
-
export declare const AMBIENT = "\ndeclare namespace JSX {\n type VeskEventHandler<E extends Event = Event> = (event: E) => void;\n interface VeskCommonAttributes {\n key?: string | number;\n class?: string;\n id?: string;\n style?: string;\n title?: string;\n hidden?: boolean | string;\n lang?: string;\n dir?: 'ltr' | 'rtl' | 'auto';\n tabIndex?: number;\n role?: string;\n }\n interface VeskEventAttributes {\n onClick?: VeskEventHandler<MouseEvent>;\n onDblClick?: VeskEventHandler<MouseEvent>;\n onMouseDown?: VeskEventHandler<MouseEvent>;\n onMouseUp?: VeskEventHandler<MouseEvent>;\n onMouseEnter?: VeskEventHandler<MouseEvent>;\n onMouseLeave?: VeskEventHandler<MouseEvent>;\n onMouseMove?: VeskEventHandler<MouseEvent>;\n onKeyDown?: VeskEventHandler<KeyboardEvent>;\n onKeyUp?: VeskEventHandler<KeyboardEvent>;\n onFocus?: VeskEventHandler<FocusEvent>;\n onBlur?: VeskEventHandler<FocusEvent>;\n onInput?: VeskEventHandler<InputEvent>;\n onChange?: VeskEventHandler<Event>;\n onSubmit?: VeskEventHandler<SubmitEvent>;\n onScroll?: VeskEventHandler<UIEvent>;\n onWheel?: VeskEventHandler<WheelEvent>;\n // Lowercase aliases \u2014 HTML attribute names are case-insensitive and real\n // code writes onclick=/oninput=. Keep in sync with the camelCase members.\n onclick?: VeskEventHandler<MouseEvent>;\n ondblclick?: VeskEventHandler<MouseEvent>;\n onmousedown?: VeskEventHandler<MouseEvent>;\n onmouseup?: VeskEventHandler<MouseEvent>;\n onmouseenter?: VeskEventHandler<MouseEvent>;\n onmouseleave?: VeskEventHandler<MouseEvent>;\n onmousemove?: VeskEventHandler<MouseEvent>;\n onkeydown?: VeskEventHandler<KeyboardEvent>;\n onkeyup?: VeskEventHandler<KeyboardEvent>;\n onfocus?: VeskEventHandler<FocusEvent>;\n onblur?: VeskEventHandler<FocusEvent>;\n oninput?: VeskEventHandler<InputEvent>;\n onchange?: VeskEventHandler<Event>;\n onsubmit?: VeskEventHandler<SubmitEvent>;\n }\n interface VeskGlobalAttributes extends VeskCommonAttributes, VeskEventAttributes {\n children?: unknown;\n }\n interface VeskAnchorAttributes extends VeskGlobalAttributes {\n href?: string;\n target?: string;\n rel?: string;\n download?: string | boolean;\n type?: string;\n hreflang?: string;\n }\n interface VeskMediaAttributes extends VeskGlobalAttributes {\n src?: string;\n width?: string | number;\n height?: string | number;\n }\n interface VeskInputAttributes extends VeskGlobalAttributes {\n type?: string;\n name?: string;\n value?: string | number | readonly string[];\n placeholder?: string;\n checked?: boolean | string;\n disabled?: boolean | string;\n readOnly?: boolean | string;\n required?: boolean | string;\n min?: string | number;\n max?: string | number;\n step?: string | number;\n pattern?: string;\n autoComplete?: string;\n autoFocus?: boolean | string;\n multiple?: boolean | string;\n accept?: string;\n size?: number;\n list?: string;\n }\n interface IntrinsicElements {\n html?: VeskGlobalAttributes & { manifest?: string };\n head?: VeskGlobalAttributes;\n body?: VeskGlobalAttributes;\n div?: VeskGlobalAttributes;\n span?: VeskGlobalAttributes;\n p?: VeskGlobalAttributes;\n h1?: VeskGlobalAttributes;\n h2?: VeskGlobalAttributes;\n h3?: VeskGlobalAttributes;\n h4?: VeskGlobalAttributes;\n h5?: VeskGlobalAttributes;\n h6?: VeskGlobalAttributes;\n a?: VeskAnchorAttributes;\n nav?: VeskGlobalAttributes;\n header?: VeskGlobalAttributes;\n footer?: VeskGlobalAttributes;\n main?: VeskGlobalAttributes;\n section?: VeskGlobalAttributes;\n article?: VeskGlobalAttributes;\n aside?: VeskGlobalAttributes;\n button?: VeskGlobalAttributes & {\n type?: 'button' | 'submit' | 'reset';\n disabled?: boolean | string;\n name?: string;\n value?: string | number;\n };\n form?: VeskGlobalAttributes & {\n action?: string;\n method?: 'get' | 'post';\n target?: string;\n encType?: string;\n noValidate?: boolean | string;\n name?: string;\n autoComplete?: string;\n };\n input?: VeskInputAttributes;\n textarea?: VeskGlobalAttributes & {\n rows?: number;\n cols?: number;\n placeholder?: string;\n value?: string | number;\n disabled?: boolean | string;\n readOnly?: boolean | string;\n required?: boolean | string;\n name?: string;\n };\n select?: VeskGlobalAttributes & {\n name?: string;\n value?: string | number | readonly string[];\n disabled?: boolean | string;\n required?: boolean | string;\n multiple?: boolean | string;\n size?: number;\n autoComplete?: string;\n };\n option?: VeskGlobalAttributes & {\n value?: string | number;\n selected?: boolean | string;\n disabled?: boolean | string;\n label?: string;\n };\n optgroup?: VeskGlobalAttributes & { label?: string; disabled?: boolean | string };\n label?: VeskGlobalAttributes & { htmlFor?: string };\n fieldset?: VeskGlobalAttributes & { disabled?: boolean | string; name?: string; form?: string };\n legend?: VeskGlobalAttributes;\n datalist?: VeskGlobalAttributes;\n img?: VeskGlobalAttributes & {\n src?: string;\n alt?: string;\n width?: string | number;\n height?: string | number;\n srcSet?: string;\n sizes?: string;\n loading?: 'eager' | 'lazy';\n decoding?: 'sync' | 'async' | 'auto';\n };\n picture?: VeskGlobalAttributes;\n source?: VeskGlobalAttributes & { src?: string; srcSet?: string; sizes?: string; media?: string; type?: string };\n video?: VeskMediaAttributes & {\n controls?: boolean | string;\n autoPlay?: boolean | string;\n loop?: boolean | string;\n muted?: boolean | string;\n preload?: 'none' | 'metadata' | 'auto' | '';\n poster?: string;\n playsInline?: boolean | string;\n };\n audio?: VeskGlobalAttributes & {\n src?: string;\n controls?: boolean | string;\n autoPlay?: boolean | string;\n loop?: boolean | string;\n muted?: boolean | string;\n preload?: 'none' | 'metadata' | 'auto' | '';\n };\n track?: VeskGlobalAttributes & {\n src?: string;\n kind?: string;\n srclang?: string;\n label?: string;\n default?: boolean | string;\n };\n canvas?: VeskGlobalAttributes & { width?: number; height?: number };\n iframe?: VeskGlobalAttributes & {\n src?: string;\n srcDoc?: string;\n width?: string | number;\n height?: string | number;\n allow?: string;\n loading?: 'eager' | 'lazy';\n sandbox?: string;\n allowFullScreen?: boolean | string;\n referrerPolicy?: string;\n };\n embed?: VeskGlobalAttributes & { src?: string; type?: string; width?: string | number; height?: string | number };\n object?: VeskGlobalAttributes & { data?: string; type?: string; name?: string; width?: string | number; height?: string | number };\n table?: VeskGlobalAttributes;\n caption?: VeskGlobalAttributes;\n thead?: VeskGlobalAttributes;\n tbody?: VeskGlobalAttributes;\n tfoot?: VeskGlobalAttributes;\n tr?: VeskGlobalAttributes;\n th?: VeskGlobalAttributes & { colSpan?: number; rowSpan?: number; scope?: string; headers?: string };\n td?: VeskGlobalAttributes & { colSpan?: number; rowSpan?: number; headers?: string };\n col?: VeskGlobalAttributes & { span?: number };\n colgroup?: VeskGlobalAttributes & { span?: number };\n ul?: VeskGlobalAttributes;\n ol?: VeskGlobalAttributes & { start?: number; reversed?: boolean | string; type?: string };\n li?: VeskGlobalAttributes & { value?: number };\n dl?: VeskGlobalAttributes;\n dt?: VeskGlobalAttributes;\n dd?: VeskGlobalAttributes;\n br?: VeskGlobalAttributes;\n hr?: VeskGlobalAttributes;\n pre?: VeskGlobalAttributes;\n code?: VeskGlobalAttributes;\n blockquote?: VeskGlobalAttributes & { cite?: string };\n q?: VeskGlobalAttributes & { cite?: string };\n strong?: VeskGlobalAttributes;\n em?: VeskGlobalAttributes;\n small?: VeskGlobalAttributes;\n s?: VeskGlobalAttributes;\n cite?: VeskGlobalAttributes;\n dfn?: VeskGlobalAttributes;\n abbr?: VeskGlobalAttributes & { title?: string };\n time?: VeskGlobalAttributes & { dateTime?: string };\n data?: VeskGlobalAttributes & { value?: string | number };\n mark?: VeskGlobalAttributes;\n del?: VeskGlobalAttributes & { cite?: string; dateTime?: string };\n ins?: VeskGlobalAttributes & { cite?: string; dateTime?: string };\n sub?: VeskGlobalAttributes;\n sup?: VeskGlobalAttributes;\n u?: VeskGlobalAttributes;\n kbd?: VeskGlobalAttributes;\n samp?: VeskGlobalAttributes;\n var?: VeskGlobalAttributes;\n figure?: VeskGlobalAttributes;\n figcaption?: VeskGlobalAttributes;\n details?: VeskGlobalAttributes & { open?: boolean | string };\n summary?: VeskGlobalAttributes;\n dialog?: VeskGlobalAttributes & { open?: boolean | string };\n menu?: VeskGlobalAttributes;\n address?: VeskGlobalAttributes;\n b?: VeskGlobalAttributes;\n i?: VeskGlobalAttributes;\n ruby?: VeskGlobalAttributes;\n rt?: VeskGlobalAttributes;\n rp?: VeskGlobalAttributes;\n bdi?: VeskGlobalAttributes;\n bdo?: VeskGlobalAttributes;\n wbr?: VeskGlobalAttributes;\n area?: VeskGlobalAttributes & {\n coords?: string;\n shape?: string;\n href?: string;\n target?: string;\n alt?: string;\n };\n map?: VeskGlobalAttributes & { name?: string };\n noscript?: VeskGlobalAttributes;\n template?: VeskGlobalAttributes;\n slot?: VeskGlobalAttributes & { name?: string };\n meta?: VeskGlobalAttributes & { name?: string; content?: string; charSet?: string; httpEquiv?: string };\n title?: VeskGlobalAttributes;\n base?: VeskGlobalAttributes & { href?: string; target?: string };\n link?: VeskGlobalAttributes & {\n rel?: string;\n href?: string;\n sizes?: string;\n media?: string;\n as?: string;\n crossOrigin?: string;\n integrity?: string;\n };\n style?: VeskGlobalAttributes & { media?: string };\n script?: VeskGlobalAttributes & {\n src?: string;\n async?: boolean | string;\n defer?: boolean | string;\n type?: string;\n crossOrigin?: string;\n integrity?: string;\n nonce?: string;\n noModule?: boolean | string;\n };\n svg?: VeskGlobalAttributes & {\n viewBox?: string;\n xmlns?: string;\n width?: string | number;\n height?: string | number;\n fill?: string;\n stroke?: string;\n strokeWidth?: string | number;\n };\n g?: VeskGlobalAttributes & { transform?: string; fill?: string; stroke?: string; strokeWidth?: string | number };\n path?: VeskGlobalAttributes & {\n d?: string;\n fill?: string;\n stroke?: string;\n strokeWidth?: string | number;\n fillRule?: string;\n clipRule?: string;\n };\n circle?: VeskGlobalAttributes & {\n cx?: string | number;\n cy?: string | number;\n r?: string | number;\n fill?: string;\n stroke?: string;\n strokeWidth?: string | number;\n };\n ellipse?: VeskGlobalAttributes & {\n cx?: string | number;\n cy?: string | number;\n rx?: string | number;\n ry?: string | number;\n fill?: string;\n };\n rect?: VeskGlobalAttributes & {\n x?: string | number;\n y?: string | number;\n width?: string | number;\n height?: string | number;\n rx?: string | number;\n ry?: string | number;\n fill?: string;\n };\n line?: VeskGlobalAttributes & {\n x1?: string | number;\n y1?: string | number;\n x2?: string | number;\n y2?: string | number;\n stroke?: string;\n strokeWidth?: string | number;\n };\n polyline?: VeskGlobalAttributes & { points?: string; fill?: string; stroke?: string };\n polygon?: VeskGlobalAttributes & { points?: string; fill?: string; stroke?: string };\n text?: VeskGlobalAttributes & { x?: string | number; y?: string | number; fill?: string; fontSize?: string | number };\n defs?: VeskGlobalAttributes;\n linearGradient?: VeskGlobalAttributes;\n radialGradient?: VeskGlobalAttributes;\n stop?: VeskGlobalAttributes & { offset?: string | number; stopColor?: string; stopOpacity?: string | number };\n\n // Unknown/custom tags stay permissive \u2014 components and web components\n // resolve through the index signature, known tags get the typed members.\n [elemName: string]: unknown;\n }\n}\ndeclare const Head: (props: { children?: unknown }) => unknown;\ndeclare class Cell<T> {\n get(): T;\n set(value: T): void;\n peek(): T;\n update(fn: (current: T) => T): boolean;\n unsubscribe(effect: unknown): void;\n}\ndeclare function track<T>(initialValue: T): Cell<T>;\ndeclare function derived<T>(fn: () => T): Cell<T>;\ndeclare function effect(fn: () => void): unknown;\ndeclare function untrack<T>(fn: () => T): T;\ndeclare function peek<T>(fn: () => T): T;\ndeclare function tick(): Promise<void>;\ndeclare function flushSync(fn: () => void): void;\ndeclare function on_destroy(fn: () => void): void;\ndeclare function createContext<T>(defaultValue?: T): { id: symbol; defaultValue: T | undefined };\n// useFetch returns a THENABLE resource, not the data itself. In async\n// components you must `await` it before reading/iterating the payload;\n// passing `into: <tracked cell>` writes the payload into the cell and makes\n// awaiting unnecessary (the return value can be ignored).\ninterface VeskResource<T> {\n loading: boolean;\n error: unknown;\n data: T | undefined;\n refresh(): void;\n abort(): void;\n then<TResult1 = T, TResult2 = never>(\n onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | undefined | null,\n ): PromiseLike<TResult1 | TResult2>;\n}\ninterface VeskUseFetchOptions<T> {\n /** Cache/SSR key \u2014 defaults to the URL string. */\n key?: string;\n /** Target tracked cell (from track<T>()) \u2014 the payload is written into it, so awaiting is unnecessary. */\n into?: Cell<T>;\n staleTime?: number;\n keepPreviousData?: boolean;\n retry?: number;\n retryDelay?: number;\n timeout?: number;\n enabled?: boolean;\n dedupe?: boolean;\n method?: string;\n headers?: Record<string, string>;\n body?: unknown;\n credentials?: 'omit' | 'same-origin' | 'include';\n signal?: { readonly aborted: boolean };\n}\ndeclare function useFetch<T = unknown>(\n urlOrFn: string | (() => Promise<T>),\n options?: VeskUseFetchOptions<T>,\n): VeskResource<T>;\ndeclare function useRouter(): unknown;\ndeclare function useParams(): Record<string, string>;\ndeclare function usePathname(): string;\ndeclare function useSearchParams(): URLSearchParams;\ndeclare function useNavigate(): (to: string) => void;\ndeclare function defineAction(...args: unknown[]): unknown;\ndeclare const Form: (props: { [k: string]: unknown; children?: unknown }) => unknown;\ndeclare const Field: (props: { [k: string]: unknown; children?: unknown }) => unknown;\ndeclare function required(...args: unknown[]): unknown;\ndeclare function email(...args: unknown[]): unknown;\ndeclare function minLength(...args: unknown[]): unknown;\ndeclare function maxLength(...args: unknown[]): unknown;\ndeclare function pattern(...args: unknown[]): unknown;\ndeclare function custom(...args: unknown[]): unknown;\ndeclare const Link: (props: { [k: string]: unknown; children?: unknown }) => unknown;\ndeclare const NavLink: (props: { [k: string]: unknown; children?: unknown }) => unknown;\ndeclare const Outlet: (props: { [k: string]: unknown; children?: unknown }) => unknown;\ndeclare const Image: (props: { [k: string]: unknown; children?: unknown }) => unknown;\ndeclare const Portal: (props: { [k: string]: unknown; children?: unknown }) => unknown;\ndeclare const Experiment: (props: { [k: string]: unknown; children?: unknown }) => unknown;\ndeclare const JsonLd: (props: { [k: string]: unknown; children?: unknown }) => unknown;\ndeclare const ArticleSchema: (props: { [k: string]: unknown; children?: unknown }) => unknown;\ndeclare const ProductSchema: (props: { [k: string]: unknown; children?: unknown }) => unknown;\ndeclare const FAQPageSchema: (props: { [k: string]: unknown; children?: unknown }) => unknown;\ndeclare const BreadcrumbListSchema: (props: { [k: string]: unknown; children?: unknown }) => unknown;\ndeclare const OrganizationSchema: (props: { [k: string]: unknown; children?: unknown }) => unknown;\ndeclare const LocalBusinessSchema: (props: { [k: string]: unknown; children?: unknown }) => unknown;\ndeclare const VideoSchema: (props: { [k: string]: unknown; children?: unknown }) => unknown;\ndeclare function redirect(...args: unknown[]): unknown;\ndeclare function permanentRedirect(...args: unknown[]): unknown;\ndeclare function notFound(...args: unknown[]): never;\ndeclare class NotFoundError extends Error {}\ndeclare function createResource(...args: unknown[]): unknown;\ndeclare function getAction(...args: unknown[]): unknown;\ndeclare function validateActionInput(...args: unknown[]): unknown;\ndeclare function issuesToFieldMap(...args: unknown[]): unknown;\ndeclare function isFormAction(...args: unknown[]): unknown;\n";
|
|
13
|
-
export declare const RUNTIME_OVERRIDE = "\nimport '@vesk/runtime';\ndeclare module '@vesk/runtime' {\n export function track<T>(initialValue: T):
|
|
12
|
+
export declare const AMBIENT = "\ndeclare namespace JSX {\n type VeskEventHandler<E extends Event = Event> = (event: E) => void;\n interface VeskCommonAttributes {\n key?: string | number;\n class?: string;\n id?: string;\n style?: string;\n title?: string;\n hidden?: boolean | string;\n lang?: string;\n dir?: 'ltr' | 'rtl' | 'auto';\n tabIndex?: number;\n role?: string;\n }\n interface VeskEventAttributes {\n onClick?: VeskEventHandler<MouseEvent>;\n onDblClick?: VeskEventHandler<MouseEvent>;\n onMouseDown?: VeskEventHandler<MouseEvent>;\n onMouseUp?: VeskEventHandler<MouseEvent>;\n onMouseEnter?: VeskEventHandler<MouseEvent>;\n onMouseLeave?: VeskEventHandler<MouseEvent>;\n onMouseMove?: VeskEventHandler<MouseEvent>;\n onKeyDown?: VeskEventHandler<KeyboardEvent>;\n onKeyUp?: VeskEventHandler<KeyboardEvent>;\n onFocus?: VeskEventHandler<FocusEvent>;\n onBlur?: VeskEventHandler<FocusEvent>;\n onInput?: VeskEventHandler<InputEvent>;\n onChange?: VeskEventHandler<Event>;\n onSubmit?: VeskEventHandler<SubmitEvent>;\n onScroll?: VeskEventHandler<UIEvent>;\n onWheel?: VeskEventHandler<WheelEvent>;\n // Lowercase aliases \u2014 HTML attribute names are case-insensitive and real\n // code writes onclick=/oninput=. Keep in sync with the camelCase members.\n onclick?: VeskEventHandler<MouseEvent>;\n ondblclick?: VeskEventHandler<MouseEvent>;\n onmousedown?: VeskEventHandler<MouseEvent>;\n onmouseup?: VeskEventHandler<MouseEvent>;\n onmouseenter?: VeskEventHandler<MouseEvent>;\n onmouseleave?: VeskEventHandler<MouseEvent>;\n onmousemove?: VeskEventHandler<MouseEvent>;\n onkeydown?: VeskEventHandler<KeyboardEvent>;\n onkeyup?: VeskEventHandler<KeyboardEvent>;\n onfocus?: VeskEventHandler<FocusEvent>;\n onblur?: VeskEventHandler<FocusEvent>;\n oninput?: VeskEventHandler<InputEvent>;\n onchange?: VeskEventHandler<Event>;\n onsubmit?: VeskEventHandler<SubmitEvent>;\n }\n type Component = string | number | boolean | null | undefined | Component[];\n interface VeskGlobalAttributes extends VeskCommonAttributes, VeskEventAttributes {\n children?: Component;\n }\n interface VeskAnchorAttributes extends VeskGlobalAttributes {\n href?: string;\n target?: string;\n rel?: string;\n download?: string | boolean;\n type?: string;\n hreflang?: string;\n }\n interface VeskMediaAttributes extends VeskGlobalAttributes {\n src?: string;\n width?: string | number;\n height?: string | number;\n }\n interface VeskInputAttributes extends VeskGlobalAttributes {\n type?: string;\n name?: string;\n value?: string | number | readonly string[];\n placeholder?: string;\n checked?: boolean | string;\n disabled?: boolean | string;\n readOnly?: boolean | string;\n required?: boolean | string;\n min?: string | number;\n max?: string | number;\n step?: string | number;\n pattern?: string;\n autoComplete?: string;\n autoFocus?: boolean | string;\n multiple?: boolean | string;\n accept?: string;\n size?: number;\n list?: string;\n }\n interface IntrinsicElements {\n html?: VeskGlobalAttributes & { manifest?: string };\n head?: VeskGlobalAttributes;\n body?: VeskGlobalAttributes;\n div?: VeskGlobalAttributes;\n span?: VeskGlobalAttributes;\n p?: VeskGlobalAttributes;\n h1?: VeskGlobalAttributes;\n h2?: VeskGlobalAttributes;\n h3?: VeskGlobalAttributes;\n h4?: VeskGlobalAttributes;\n h5?: VeskGlobalAttributes;\n h6?: VeskGlobalAttributes;\n a?: VeskAnchorAttributes;\n nav?: VeskGlobalAttributes;\n header?: VeskGlobalAttributes;\n footer?: VeskGlobalAttributes;\n main?: VeskGlobalAttributes;\n section?: VeskGlobalAttributes;\n article?: VeskGlobalAttributes;\n aside?: VeskGlobalAttributes;\n button?: VeskGlobalAttributes & {\n type?: 'button' | 'submit' | 'reset';\n disabled?: boolean | string;\n name?: string;\n value?: string | number;\n };\n form?: VeskGlobalAttributes & {\n action?: string;\n method?: 'get' | 'post';\n target?: string;\n encType?: string;\n noValidate?: boolean | string;\n name?: string;\n autoComplete?: string;\n };\n input?: VeskInputAttributes;\n textarea?: VeskGlobalAttributes & {\n rows?: number;\n cols?: number;\n placeholder?: string;\n value?: string | number;\n disabled?: boolean | string;\n readOnly?: boolean | string;\n required?: boolean | string;\n name?: string;\n };\n select?: VeskGlobalAttributes & {\n name?: string;\n value?: string | number | readonly string[];\n disabled?: boolean | string;\n required?: boolean | string;\n multiple?: boolean | string;\n size?: number;\n autoComplete?: string;\n };\n option?: VeskGlobalAttributes & {\n value?: string | number;\n selected?: boolean | string;\n disabled?: boolean | string;\n label?: string;\n };\n optgroup?: VeskGlobalAttributes & { label?: string; disabled?: boolean | string };\n label?: VeskGlobalAttributes & { htmlFor?: string };\n fieldset?: VeskGlobalAttributes & { disabled?: boolean | string; name?: string; form?: string };\n legend?: VeskGlobalAttributes;\n datalist?: VeskGlobalAttributes;\n img?: VeskGlobalAttributes & {\n src?: string;\n alt?: string;\n width?: string | number;\n height?: string | number;\n srcSet?: string;\n sizes?: string;\n loading?: 'eager' | 'lazy';\n decoding?: 'sync' | 'async' | 'auto';\n };\n picture?: VeskGlobalAttributes;\n source?: VeskGlobalAttributes & { src?: string; srcSet?: string; sizes?: string; media?: string; type?: string };\n video?: VeskMediaAttributes & {\n controls?: boolean | string;\n autoPlay?: boolean | string;\n loop?: boolean | string;\n muted?: boolean | string;\n preload?: 'none' | 'metadata' | 'auto' | '';\n poster?: string;\n playsInline?: boolean | string;\n };\n audio?: VeskGlobalAttributes & {\n src?: string;\n controls?: boolean | string;\n autoPlay?: boolean | string;\n loop?: boolean | string;\n muted?: boolean | string;\n preload?: 'none' | 'metadata' | 'auto' | '';\n };\n track?: VeskGlobalAttributes & {\n src?: string;\n kind?: string;\n srclang?: string;\n label?: string;\n default?: boolean | string;\n };\n canvas?: VeskGlobalAttributes & { width?: number; height?: number };\n iframe?: VeskGlobalAttributes & {\n src?: string;\n srcDoc?: string;\n width?: string | number;\n height?: string | number;\n allow?: string;\n loading?: 'eager' | 'lazy';\n sandbox?: string;\n allowFullScreen?: boolean | string;\n referrerPolicy?: string;\n };\n embed?: VeskGlobalAttributes & { src?: string; type?: string; width?: string | number; height?: string | number };\n object?: VeskGlobalAttributes & { data?: string; type?: string; name?: string; width?: string | number; height?: string | number };\n table?: VeskGlobalAttributes;\n caption?: VeskGlobalAttributes;\n thead?: VeskGlobalAttributes;\n tbody?: VeskGlobalAttributes;\n tfoot?: VeskGlobalAttributes;\n tr?: VeskGlobalAttributes;\n th?: VeskGlobalAttributes & { colSpan?: number; rowSpan?: number; scope?: string; headers?: string };\n td?: VeskGlobalAttributes & { colSpan?: number; rowSpan?: number; headers?: string };\n col?: VeskGlobalAttributes & { span?: number };\n colgroup?: VeskGlobalAttributes & { span?: number };\n ul?: VeskGlobalAttributes;\n ol?: VeskGlobalAttributes & { start?: number; reversed?: boolean | string; type?: string };\n li?: VeskGlobalAttributes & { value?: number };\n dl?: VeskGlobalAttributes;\n dt?: VeskGlobalAttributes;\n dd?: VeskGlobalAttributes;\n br?: VeskGlobalAttributes;\n hr?: VeskGlobalAttributes;\n pre?: VeskGlobalAttributes;\n code?: VeskGlobalAttributes;\n blockquote?: VeskGlobalAttributes & { cite?: string };\n q?: VeskGlobalAttributes & { cite?: string };\n strong?: VeskGlobalAttributes;\n em?: VeskGlobalAttributes;\n small?: VeskGlobalAttributes;\n s?: VeskGlobalAttributes;\n cite?: VeskGlobalAttributes;\n dfn?: VeskGlobalAttributes;\n abbr?: VeskGlobalAttributes & { title?: string };\n time?: VeskGlobalAttributes & { dateTime?: string };\n data?: VeskGlobalAttributes & { value?: string | number };\n mark?: VeskGlobalAttributes;\n del?: VeskGlobalAttributes & { cite?: string; dateTime?: string };\n ins?: VeskGlobalAttributes & { cite?: string; dateTime?: string };\n sub?: VeskGlobalAttributes;\n sup?: VeskGlobalAttributes;\n u?: VeskGlobalAttributes;\n kbd?: VeskGlobalAttributes;\n samp?: VeskGlobalAttributes;\n var?: VeskGlobalAttributes;\n figure?: VeskGlobalAttributes;\n figcaption?: VeskGlobalAttributes;\n details?: VeskGlobalAttributes & { open?: boolean | string };\n summary?: VeskGlobalAttributes;\n dialog?: VeskGlobalAttributes & { open?: boolean | string };\n menu?: VeskGlobalAttributes;\n address?: VeskGlobalAttributes;\n b?: VeskGlobalAttributes;\n i?: VeskGlobalAttributes;\n ruby?: VeskGlobalAttributes;\n rt?: VeskGlobalAttributes;\n rp?: VeskGlobalAttributes;\n bdi?: VeskGlobalAttributes;\n bdo?: VeskGlobalAttributes;\n wbr?: VeskGlobalAttributes;\n area?: VeskGlobalAttributes & {\n coords?: string;\n shape?: string;\n href?: string;\n target?: string;\n alt?: string;\n };\n map?: VeskGlobalAttributes & { name?: string };\n noscript?: VeskGlobalAttributes;\n template?: VeskGlobalAttributes;\n slot?: VeskGlobalAttributes & { name?: string };\n meta?: VeskGlobalAttributes & { name?: string; content?: string; charSet?: string; httpEquiv?: string };\n title?: VeskGlobalAttributes;\n base?: VeskGlobalAttributes & { href?: string; target?: string };\n link?: VeskGlobalAttributes & {\n rel?: string;\n href?: string;\n sizes?: string;\n media?: string;\n as?: string;\n crossOrigin?: string;\n integrity?: string;\n type?: string;\n };\n style?: VeskGlobalAttributes & { media?: string };\n script?: VeskGlobalAttributes & {\n src?: string;\n async?: boolean | string;\n defer?: boolean | string;\n type?: string;\n crossOrigin?: string;\n integrity?: string;\n nonce?: string;\n noModule?: boolean | string;\n };\n svg?: VeskGlobalAttributes & {\n viewBox?: string;\n xmlns?: string;\n width?: string | number;\n height?: string | number;\n fill?: string;\n stroke?: string;\n strokeWidth?: string | number;\n };\n g?: VeskGlobalAttributes & { transform?: string; fill?: string; stroke?: string; strokeWidth?: string | number };\n path?: VeskGlobalAttributes & {\n d?: string;\n fill?: string;\n stroke?: string;\n strokeWidth?: string | number;\n fillRule?: string;\n clipRule?: string;\n };\n circle?: VeskGlobalAttributes & {\n cx?: string | number;\n cy?: string | number;\n r?: string | number;\n fill?: string;\n stroke?: string;\n strokeWidth?: string | number;\n };\n ellipse?: VeskGlobalAttributes & {\n cx?: string | number;\n cy?: string | number;\n rx?: string | number;\n ry?: string | number;\n fill?: string;\n };\n rect?: VeskGlobalAttributes & {\n x?: string | number;\n y?: string | number;\n width?: string | number;\n height?: string | number;\n rx?: string | number;\n ry?: string | number;\n fill?: string;\n };\n line?: VeskGlobalAttributes & {\n x1?: string | number;\n y1?: string | number;\n x2?: string | number;\n y2?: string | number;\n stroke?: string;\n strokeWidth?: string | number;\n };\n polyline?: VeskGlobalAttributes & { points?: string; fill?: string; stroke?: string };\n polygon?: VeskGlobalAttributes & { points?: string; fill?: string; stroke?: string };\n text?: VeskGlobalAttributes & { x?: string | number; y?: string | number; fill?: string; fontSize?: string | number };\n defs?: VeskGlobalAttributes;\n linearGradient?: VeskGlobalAttributes;\n radialGradient?: VeskGlobalAttributes;\n stop?: VeskGlobalAttributes & { offset?: string | number; stopColor?: string; stopOpacity?: string | number };\n\n // Unknown/custom tags stay permissive \u2014 components and web components\n // resolve through the index signature, known tags get the typed members.\n [elemName: string]: unknown;\n }\n type Component = string | number | boolean | null | undefined | Component[];\n}\ndeclare type Component = string | number | boolean | null | undefined | Component[];\ndeclare const Head: (props: { children?: Component }) => Component;\ninterface Tracked<T> {\n get(): T;\n set(value: T): void;\n}\ninterface Derived<T> {\n get(): T;\n set(value: T): void;\n}\ndeclare function track<T>(initialValue: T): Tracked<T>;\ndeclare function track<T>(fn: () => T): Derived<T>;\ndeclare function derived<T>(fn: () => T): Derived<T>;\ndeclare function effect(fn: () => void): unknown;\ndeclare function untrack<T>(fn: () => T): T;\ndeclare function peek<T>(fn: () => T): T;\ndeclare function tick(): Promise<void>;\ndeclare function flushSync(fn: () => void): void;\ndeclare function on_destroy(fn: () => void): void;\ndeclare function createContext<T>(defaultValue?: T): { id: symbol; defaultValue: T | undefined };\n// useFetch returns a THENABLE resource, not the data itself. In async\n// components you must `await` it before reading/iterating the payload;\n// passing `into: <tracked cell>` writes the payload into the cell and makes\n// awaiting unnecessary (the return value can be ignored).\ninterface VeskResource<T> {\n loading: boolean;\n error: unknown;\n data: T | undefined;\n refresh(): void;\n abort(): void;\n then<TResult1 = T, TResult2 = never>(\n onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | undefined | null,\n ): PromiseLike<TResult1 | TResult2>;\n}\ninterface VeskUseFetchOptions<T> {\n /** Cache/SSR key \u2014 defaults to the URL string. */\n key?: string;\n /** Target tracked cell (from track<T>()) \u2014 the payload is written into it, so awaiting is unnecessary. */\n into?: Tracked<T>;\n staleTime?: number;\n keepPreviousData?: boolean;\n retry?: number;\n retryDelay?: number;\n timeout?: number;\n enabled?: boolean;\n dedupe?: boolean;\n method?: string;\n headers?: Record<string, string>;\n body?: unknown;\n credentials?: 'omit' | 'same-origin' | 'include';\n signal?: { readonly aborted: boolean };\n}\ndeclare function useFetch<T = unknown>(\n urlOrFn: string | (() => Promise<T>),\n options?: VeskUseFetchOptions<T>,\n): VeskResource<T>;\ndeclare function useRouter(): unknown;\ndeclare function useParams(): Record<string, string>;\ndeclare function usePathname(): string;\ndeclare function useSearchParams(): URLSearchParams;\ndeclare function useNavigate(): (to: string) => void;\ndeclare function defineAction(...args: unknown[]): unknown;\ndeclare const Form: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const Field: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare function required(...args: unknown[]): unknown;\ndeclare function email(...args: unknown[]): unknown;\ndeclare function minLength(...args: unknown[]): unknown;\ndeclare function maxLength(...args: unknown[]): unknown;\ndeclare function pattern(...args: unknown[]): unknown;\ndeclare function custom(...args: unknown[]): unknown;\ndeclare const Link: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const NavLink: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const Outlet: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const Image: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const Portal: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const Experiment: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare function useLoadingIndicator(options?: {\n duration?: number;\n throttle?: number;\n hideDelay?: number;\n resetDelay?: number;\n estimatedProgress?: (duration: number, elapsed: number) => number;\n}): {\n progress: Tracked<number>;\n isLoading: Tracked<boolean>;\n error: Tracked<boolean>;\n start(opts?: { force?: boolean }): void;\n set(value: number, opts?: { force?: boolean }): void;\n finish(opts?: { force?: boolean; error?: boolean }): void;\n clear(): void;\n};\ndeclare const LoadingIndicator: (props: {\n color?: string | false;\n errorColor?: string;\n height?: number | string;\n position?: 'top' | 'bottom';\n zIndex?: number;\n duration?: number;\n throttle?: number;\n hideDelay?: number;\n resetDelay?: number;\n estimatedProgress?: (duration: number, elapsed: number) => number;\n class?: string;\n className?: string;\n style?: string;\n children?: Component;\n [k: string]: unknown;\n}) => Component;\ndeclare const JsonLd: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const ArticleSchema: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const ProductSchema: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const FAQPageSchema: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const BreadcrumbListSchema: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const OrganizationSchema: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const LocalBusinessSchema: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const VideoSchema: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare function redirect(...args: unknown[]): unknown;\ndeclare function permanentRedirect(...args: unknown[]): unknown;\ndeclare function notFound(...args: unknown[]): never;\ndeclare class NotFoundError extends Error {}\ndeclare function createResource(...args: unknown[]): unknown;\ndeclare function getAction(...args: unknown[]): unknown;\ndeclare function validateActionInput(...args: unknown[]): unknown;\ndeclare function issuesToFieldMap(...args: unknown[]): unknown;\ndeclare function isFormAction(...args: unknown[]): unknown;\n";
|
|
13
|
+
export declare const RUNTIME_OVERRIDE = "\nimport '@vesk/runtime';\ndeclare module '@vesk/runtime' {\n export function track<T>(initialValue: T): Tracked<T>;\n export function track<T>(fn: () => T): Derived<T>;\n export function derived<T>(fn: () => T): Derived<T>;\n}\n";
|
|
14
14
|
export interface TypecheckResult {
|
|
15
15
|
errors: TypecheckError[];
|
|
16
16
|
warnings: TypecheckError[];
|
package/dist/typecheck.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typecheck.d.ts","sourceRoot":"","sources":["../src/typecheck.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAKD,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"typecheck.d.ts","sourceRoot":"","sources":["../src/typecheck.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAKD,eAAO,MAAM,OAAO,66kBAmenB,CAAC;AAEF,eAAO,MAAM,gBAAgB,6OAO5B,CAAC;AAyLF,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,QAAQ,EAAE,cAAc,EAAE,CAAC;CAC5B;AAED,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,GAAE,gBAAqB,GAAG,eAAe,CA0FlG;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,CAItE;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,MAAM,CAI1E"}
|
package/dist/typecheck.js
CHANGED
|
@@ -54,8 +54,9 @@ declare namespace JSX {
|
|
|
54
54
|
onchange?: VeskEventHandler<Event>;
|
|
55
55
|
onsubmit?: VeskEventHandler<SubmitEvent>;
|
|
56
56
|
}
|
|
57
|
+
type Component = string | number | boolean | null | undefined | Component[];
|
|
57
58
|
interface VeskGlobalAttributes extends VeskCommonAttributes, VeskEventAttributes {
|
|
58
|
-
children?:
|
|
59
|
+
children?: Component;
|
|
59
60
|
}
|
|
60
61
|
interface VeskAnchorAttributes extends VeskGlobalAttributes {
|
|
61
62
|
href?: string;
|
|
@@ -284,6 +285,7 @@ declare namespace JSX {
|
|
|
284
285
|
as?: string;
|
|
285
286
|
crossOrigin?: string;
|
|
286
287
|
integrity?: string;
|
|
288
|
+
type?: string;
|
|
287
289
|
};
|
|
288
290
|
style?: VeskGlobalAttributes & { media?: string };
|
|
289
291
|
script?: VeskGlobalAttributes & {
|
|
@@ -358,17 +360,21 @@ declare namespace JSX {
|
|
|
358
360
|
// resolve through the index signature, known tags get the typed members.
|
|
359
361
|
[elemName: string]: unknown;
|
|
360
362
|
}
|
|
363
|
+
type Component = string | number | boolean | null | undefined | Component[];
|
|
364
|
+
}
|
|
365
|
+
declare type Component = string | number | boolean | null | undefined | Component[];
|
|
366
|
+
declare const Head: (props: { children?: Component }) => Component;
|
|
367
|
+
interface Tracked<T> {
|
|
368
|
+
get(): T;
|
|
369
|
+
set(value: T): void;
|
|
361
370
|
}
|
|
362
|
-
|
|
363
|
-
declare class Cell<T> {
|
|
371
|
+
interface Derived<T> {
|
|
364
372
|
get(): T;
|
|
365
373
|
set(value: T): void;
|
|
366
|
-
peek(): T;
|
|
367
|
-
update(fn: (current: T) => T): boolean;
|
|
368
|
-
unsubscribe(effect: unknown): void;
|
|
369
374
|
}
|
|
370
|
-
declare function track<T>(initialValue: T):
|
|
371
|
-
declare function
|
|
375
|
+
declare function track<T>(initialValue: T): Tracked<T>;
|
|
376
|
+
declare function track<T>(fn: () => T): Derived<T>;
|
|
377
|
+
declare function derived<T>(fn: () => T): Derived<T>;
|
|
372
378
|
declare function effect(fn: () => void): unknown;
|
|
373
379
|
declare function untrack<T>(fn: () => T): T;
|
|
374
380
|
declare function peek<T>(fn: () => T): T;
|
|
@@ -395,7 +401,7 @@ interface VeskUseFetchOptions<T> {
|
|
|
395
401
|
/** Cache/SSR key — defaults to the URL string. */
|
|
396
402
|
key?: string;
|
|
397
403
|
/** Target tracked cell (from track<T>()) — the payload is written into it, so awaiting is unnecessary. */
|
|
398
|
-
into?:
|
|
404
|
+
into?: Tracked<T>;
|
|
399
405
|
staleTime?: number;
|
|
400
406
|
keepPreviousData?: boolean;
|
|
401
407
|
retry?: number;
|
|
@@ -419,28 +425,60 @@ declare function usePathname(): string;
|
|
|
419
425
|
declare function useSearchParams(): URLSearchParams;
|
|
420
426
|
declare function useNavigate(): (to: string) => void;
|
|
421
427
|
declare function defineAction(...args: unknown[]): unknown;
|
|
422
|
-
declare const Form: (props: { [k: string]: unknown; children?:
|
|
423
|
-
declare const Field: (props: { [k: string]: unknown; children?:
|
|
428
|
+
declare const Form: (props: { [k: string]: unknown; children?: Component }) => Component;
|
|
429
|
+
declare const Field: (props: { [k: string]: unknown; children?: Component }) => Component;
|
|
424
430
|
declare function required(...args: unknown[]): unknown;
|
|
425
431
|
declare function email(...args: unknown[]): unknown;
|
|
426
432
|
declare function minLength(...args: unknown[]): unknown;
|
|
427
433
|
declare function maxLength(...args: unknown[]): unknown;
|
|
428
434
|
declare function pattern(...args: unknown[]): unknown;
|
|
429
435
|
declare function custom(...args: unknown[]): unknown;
|
|
430
|
-
declare const Link: (props: { [k: string]: unknown; children?:
|
|
431
|
-
declare const NavLink: (props: { [k: string]: unknown; children?:
|
|
432
|
-
declare const Outlet: (props: { [k: string]: unknown; children?:
|
|
433
|
-
declare const Image: (props: { [k: string]: unknown; children?:
|
|
434
|
-
declare const Portal: (props: { [k: string]: unknown; children?:
|
|
435
|
-
declare const Experiment: (props: { [k: string]: unknown; children?:
|
|
436
|
-
declare
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
436
|
+
declare const Link: (props: { [k: string]: unknown; children?: Component }) => Component;
|
|
437
|
+
declare const NavLink: (props: { [k: string]: unknown; children?: Component }) => Component;
|
|
438
|
+
declare const Outlet: (props: { [k: string]: unknown; children?: Component }) => Component;
|
|
439
|
+
declare const Image: (props: { [k: string]: unknown; children?: Component }) => Component;
|
|
440
|
+
declare const Portal: (props: { [k: string]: unknown; children?: Component }) => Component;
|
|
441
|
+
declare const Experiment: (props: { [k: string]: unknown; children?: Component }) => Component;
|
|
442
|
+
declare function useLoadingIndicator(options?: {
|
|
443
|
+
duration?: number;
|
|
444
|
+
throttle?: number;
|
|
445
|
+
hideDelay?: number;
|
|
446
|
+
resetDelay?: number;
|
|
447
|
+
estimatedProgress?: (duration: number, elapsed: number) => number;
|
|
448
|
+
}): {
|
|
449
|
+
progress: Tracked<number>;
|
|
450
|
+
isLoading: Tracked<boolean>;
|
|
451
|
+
error: Tracked<boolean>;
|
|
452
|
+
start(opts?: { force?: boolean }): void;
|
|
453
|
+
set(value: number, opts?: { force?: boolean }): void;
|
|
454
|
+
finish(opts?: { force?: boolean; error?: boolean }): void;
|
|
455
|
+
clear(): void;
|
|
456
|
+
};
|
|
457
|
+
declare const LoadingIndicator: (props: {
|
|
458
|
+
color?: string | false;
|
|
459
|
+
errorColor?: string;
|
|
460
|
+
height?: number | string;
|
|
461
|
+
position?: 'top' | 'bottom';
|
|
462
|
+
zIndex?: number;
|
|
463
|
+
duration?: number;
|
|
464
|
+
throttle?: number;
|
|
465
|
+
hideDelay?: number;
|
|
466
|
+
resetDelay?: number;
|
|
467
|
+
estimatedProgress?: (duration: number, elapsed: number) => number;
|
|
468
|
+
class?: string;
|
|
469
|
+
className?: string;
|
|
470
|
+
style?: string;
|
|
471
|
+
children?: Component;
|
|
472
|
+
[k: string]: unknown;
|
|
473
|
+
}) => Component;
|
|
474
|
+
declare const JsonLd: (props: { [k: string]: unknown; children?: Component }) => Component;
|
|
475
|
+
declare const ArticleSchema: (props: { [k: string]: unknown; children?: Component }) => Component;
|
|
476
|
+
declare const ProductSchema: (props: { [k: string]: unknown; children?: Component }) => Component;
|
|
477
|
+
declare const FAQPageSchema: (props: { [k: string]: unknown; children?: Component }) => Component;
|
|
478
|
+
declare const BreadcrumbListSchema: (props: { [k: string]: unknown; children?: Component }) => Component;
|
|
479
|
+
declare const OrganizationSchema: (props: { [k: string]: unknown; children?: Component }) => Component;
|
|
480
|
+
declare const LocalBusinessSchema: (props: { [k: string]: unknown; children?: Component }) => Component;
|
|
481
|
+
declare const VideoSchema: (props: { [k: string]: unknown; children?: Component }) => Component;
|
|
444
482
|
declare function redirect(...args: unknown[]): unknown;
|
|
445
483
|
declare function permanentRedirect(...args: unknown[]): unknown;
|
|
446
484
|
declare function notFound(...args: unknown[]): never;
|
|
@@ -454,8 +492,9 @@ declare function isFormAction(...args: unknown[]): unknown;
|
|
|
454
492
|
export const RUNTIME_OVERRIDE = `
|
|
455
493
|
import '@vesk/runtime';
|
|
456
494
|
declare module '@vesk/runtime' {
|
|
457
|
-
export function track<T>(initialValue: T):
|
|
458
|
-
export function
|
|
495
|
+
export function track<T>(initialValue: T): Tracked<T>;
|
|
496
|
+
export function track<T>(fn: () => T): Derived<T>;
|
|
497
|
+
export function derived<T>(fn: () => T): Derived<T>;
|
|
459
498
|
}
|
|
460
499
|
`;
|
|
461
500
|
function walkProjectFiles(projectRoot) {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,147 +1,22 @@
|
|
|
1
1
|
import type { IRRoot } from '@vesk/compiler/src/ir';
|
|
2
|
-
export
|
|
3
|
-
path: string;
|
|
4
|
-
fullPath: string;
|
|
5
|
-
isGroup: boolean;
|
|
6
|
-
isDynamic: boolean;
|
|
7
|
-
isCatchAll: boolean;
|
|
8
|
-
page: string | null;
|
|
9
|
-
layout: string | null;
|
|
10
|
-
loading: string | null;
|
|
11
|
-
error: string | null;
|
|
12
|
-
notFound: string | null;
|
|
13
|
-
hasMiddleware: boolean;
|
|
14
|
-
children: RouteNode[];
|
|
15
|
-
sourceDir: string;
|
|
16
|
-
segmentCount: number;
|
|
17
|
-
}
|
|
18
|
-
export interface ApiRouteNode {
|
|
19
|
-
path: string;
|
|
20
|
-
fullPath: string;
|
|
21
|
-
isDynamic: boolean;
|
|
22
|
-
isCatchAll: boolean;
|
|
23
|
-
filePath: string | null;
|
|
24
|
-
children: ApiRouteNode[];
|
|
25
|
-
}
|
|
26
|
-
export interface MiddlewareContext {
|
|
27
|
-
request: Request;
|
|
28
|
-
params: Record<string, string>;
|
|
29
|
-
url: URL;
|
|
30
|
-
locals: Record<string, unknown>;
|
|
31
|
-
cookies: Record<string, string>;
|
|
32
|
-
set(key: string, value: unknown): void;
|
|
33
|
-
get(key: string): unknown;
|
|
34
|
-
[key: string]: unknown;
|
|
35
|
-
}
|
|
36
|
-
export interface VeskPlugin {
|
|
37
|
-
name: string;
|
|
38
|
-
provides?: Record<string, (() => unknown | Promise<unknown>) | unknown>;
|
|
39
|
-
onRequest?: (ctx: MiddlewareContext) => void | Promise<void>;
|
|
40
|
-
onCSS?: (content: string, filePath: string) => string | null | Promise<string | null>;
|
|
41
|
-
onFileWatch?: (filePath: string) => {
|
|
42
|
-
handled: boolean;
|
|
43
|
-
} | Promise<{
|
|
44
|
-
handled: boolean;
|
|
45
|
-
}>;
|
|
46
|
-
onTransformJS?: (code: string, filePath: string) => string | null | Promise<string | null>;
|
|
47
|
-
onBuildStart?: () => void | Promise<void>;
|
|
48
|
-
onBuildEnd?: () => void | Promise<void>;
|
|
49
|
-
}
|
|
50
|
-
export interface VeskCors {
|
|
51
|
-
origin: string | string[];
|
|
52
|
-
methods?: string;
|
|
53
|
-
headers?: string;
|
|
54
|
-
credentials?: boolean;
|
|
55
|
-
maxAge?: number;
|
|
56
|
-
}
|
|
57
|
-
export interface VeskRateLimit {
|
|
58
|
-
windowMs?: number;
|
|
59
|
-
max?: number;
|
|
60
|
-
}
|
|
61
|
-
export type VeskSecurityPreset = 'strict' | 'default' | 'minimal' | 'off';
|
|
62
|
-
export interface VeskSecurity {
|
|
63
|
-
xFrameOptions?: string | false;
|
|
64
|
-
hsts?: string | false;
|
|
65
|
-
referrerPolicy?: string | false;
|
|
66
|
-
contentSecurityPolicy?: boolean | string;
|
|
67
|
-
autoEscape?: boolean;
|
|
68
|
-
csrf?: boolean;
|
|
69
|
-
cors?: VeskCors;
|
|
70
|
-
trustProxy?: boolean | string;
|
|
71
|
-
rateLimit?: VeskRateLimit;
|
|
72
|
-
redactLogs?: boolean;
|
|
73
|
-
}
|
|
74
|
-
export interface VeskConfig {
|
|
75
|
-
appDir?: string;
|
|
76
|
-
outDir?: string;
|
|
77
|
-
publicDir?: string;
|
|
78
|
-
ssg?: {
|
|
79
|
-
getStaticPaths?: () => Promise<{
|
|
80
|
-
paths: Array<{
|
|
81
|
-
params: Record<string, string>;
|
|
82
|
-
}>;
|
|
83
|
-
}>;
|
|
84
|
-
};
|
|
85
|
-
plugins?: VeskPlugin[];
|
|
86
|
-
security?: VeskSecurity | VeskSecurityPreset | false | ((preset: (name: string, overrides?: VeskSecurity) => VeskSecurity) => VeskSecurity);
|
|
87
|
-
/** Client router route-data freshness TTL in milliseconds. The SPA router
|
|
88
|
-
* refetches a route's server data when it is older than this. Default 0 =
|
|
89
|
-
* always fetch fresh data on every SPA visit. */
|
|
90
|
-
routeDataCache?: number;
|
|
91
|
-
}
|
|
92
|
-
export interface MiddlewareEntry {
|
|
93
|
-
sourcePath: string;
|
|
94
|
-
node: RouteNode;
|
|
95
|
-
}
|
|
96
|
-
export interface MiddlewareChainOptions {
|
|
97
|
-
onLast?: (rewriteUrl: string | null) => Response | Promise<Response>;
|
|
98
|
-
plugins?: VeskPlugin[];
|
|
99
|
-
}
|
|
2
|
+
export type { RouteNode, ApiRouteNode, MiddlewareContext, VeskPlugin, VeskCors, VeskRateLimit, VeskSecurityPreset, VeskSecurity, VeskConfig, MdConfig, MdHtmlMode, MiddlewareEntry, MiddlewareChainOptions, RenderPageResult, SSGResult, DataScriptPayload, ExternalDataScript, } from '@vesk/types';
|
|
100
3
|
export interface CompileFileResult {
|
|
101
4
|
ir: IRRoot;
|
|
102
5
|
componentMap: Map<string, Function>;
|
|
103
6
|
__vesk: Record<string, unknown>;
|
|
104
7
|
}
|
|
105
|
-
export interface RenderPageResult {
|
|
106
|
-
body: string;
|
|
107
|
-
head: string;
|
|
108
|
-
props: Record<string, unknown>;
|
|
109
|
-
}
|
|
110
|
-
export interface SSGResult {
|
|
111
|
-
html: string;
|
|
112
|
-
body: string;
|
|
113
|
-
head: string;
|
|
114
|
-
props: string;
|
|
115
|
-
clientCode: string;
|
|
116
|
-
static: boolean;
|
|
117
|
-
staticLists: boolean;
|
|
118
|
-
}
|
|
119
|
-
export interface DataScriptPayload {
|
|
120
|
-
props?: Record<string, unknown>;
|
|
121
|
-
ssrData?: Record<string, unknown>;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* When provided, hydration data (serialized props + useFetch SSR data) is
|
|
125
|
-
* served as an external classic script (`<script src="...">`) instead of an
|
|
126
|
-
* inline `<script>globalThis.__vsk_ssr_data = ...</script>`. Inline data
|
|
127
|
-
* scripts are blocked by strict Content-Security-Policy headers
|
|
128
|
-
* (`script-src 'self'` without `'unsafe-inline'`), so servers must deliver
|
|
129
|
-
* the payload through an origin-served file. The callback stores the payload
|
|
130
|
-
* server-side and returns the script src URL (or null to fall back to inline).
|
|
131
|
-
*/
|
|
132
|
-
export type ExternalDataScript = (payload: DataScriptPayload) => string | null;
|
|
133
8
|
export interface FullPageOptions {
|
|
134
9
|
cssUrl?: string;
|
|
135
10
|
cssUrls?: string[];
|
|
136
11
|
clientScriptUrl?: string;
|
|
137
12
|
pageHead?: string;
|
|
138
|
-
security?: VeskSecurity;
|
|
13
|
+
security?: import('@vesk/types').VeskSecurity;
|
|
139
14
|
__vesk?: Record<string, unknown>;
|
|
140
15
|
hydrate?: boolean;
|
|
141
16
|
sourcePath?: string;
|
|
142
|
-
externalDataScript?: ExternalDataScript;
|
|
17
|
+
externalDataScript?: import('@vesk/types').ExternalDataScript;
|
|
143
18
|
cached?: CompileFileResult;
|
|
144
19
|
}
|
|
145
|
-
export declare const VESK_BUILTINS: readonly ["useFetch", "useRouter", "useParams", "usePathname", "useSearchParams", "useNavigate", "useHead", "useTitle", "Form", "Field", "Link", "NavLink", "Outlet", "Image", "Portal", "Experiment", "defineAction", "required", "email", "minLength", "maxLength", "pattern", "custom", "track", "get", "set", "derived", "effect", "batch", "untrack", "cookies", "headers", "locals", "VeskResponse", "VeskRequest", "ServerRequest", "ServerResponse", "redirect", "permanentRedirect", "notFound"];
|
|
20
|
+
export declare const VESK_BUILTINS: readonly ["useFetch", "useRouter", "useParams", "usePathname", "useSearchParams", "useNavigate", "useHead", "useTitle", "Form", "Field", "Link", "NavLink", "Outlet", "Image", "Portal", "Experiment", "LoadingIndicator", "useLoadingIndicator", "defineAction", "required", "email", "minLength", "maxLength", "pattern", "custom", "track", "get", "set", "derived", "effect", "batch", "untrack", "cookies", "headers", "locals", "VeskResponse", "VeskRequest", "ServerRequest", "ServerResponse", "redirect", "permanentRedirect", "notFound"];
|
|
146
21
|
export type VeskBuiltin = typeof VESK_BUILTINS[number];
|
|
147
22
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAIpD,YAAY,EACV,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,UAAU,EACV,QAAQ,EACR,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,UAAU,EACV,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,SAAS,EACT,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACpC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,aAAa,EAAE,YAAY,CAAC;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,OAAO,aAAa,EAAE,kBAAkB,CAAC;IAC9D,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC5B;AAED,eAAO,MAAM,aAAa,shBAahB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC"}
|
package/dist/types.js
CHANGED
|
@@ -4,6 +4,7 @@ export const VESK_BUILTINS = [
|
|
|
4
4
|
'Form', 'Field', 'Link', 'NavLink', 'Outlet',
|
|
5
5
|
'Image', 'Portal',
|
|
6
6
|
'Experiment',
|
|
7
|
+
'LoadingIndicator', 'useLoadingIndicator',
|
|
7
8
|
'defineAction',
|
|
8
9
|
'required', 'email', 'minLength', 'maxLength', 'pattern', 'custom',
|
|
9
10
|
'track', 'get', 'set', 'derived', 'effect', 'batch', 'untrack',
|
package/dist/vesk-plugin.d.ts
CHANGED
|
@@ -23,11 +23,13 @@ declare module 'acorn' {
|
|
|
23
23
|
exitScope(): void;
|
|
24
24
|
semicolon(): void;
|
|
25
25
|
raise(pos: number, message: string): void;
|
|
26
|
+
unexpected(pos?: number): void;
|
|
26
27
|
next(): void;
|
|
27
28
|
eat(token: any): boolean;
|
|
28
29
|
jsx_parseElementAt(startPos: number, startLoc?: any): any;
|
|
29
30
|
jsx_parseElement(): any;
|
|
30
31
|
jsx_parseExpressionContainer(): any;
|
|
32
|
+
jsx_parseOpeningElementAt(startPos: number, startLoc?: any): any;
|
|
31
33
|
jsx_parseClosingElementAt(pos: number, loc: any): any;
|
|
32
34
|
jsx_parseElementName(): any;
|
|
33
35
|
parseIdent(allowBinding?: boolean): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vesk-plugin.d.ts","sourceRoot":"","sources":["../src/vesk-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,QAAQ,OAAO,CAAC;IACrB,UAAU,MAAM;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,GAAG,CAAC;QACV,KAAK,EAAE,GAAG,CAAC;QACX,WAAW,EAAE,OAAO,CAAC;QACrB,MAAM,EAAE,OAAO,CAAC;QAChB,UAAU,IAAI,GAAG,CAAC;QAClB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC;QAC7B,KAAK,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC;QAC7B,gBAAgB,IAAI,GAAG,CAAC;QACxB,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,GAAG,GAAG,GAAG,CAAC;QACjE,cAAc,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;QAClD,UAAU,CAAC,qBAAqB,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,EAAE,OAAO,GAAG,GAAG,CAAC;QACnF,SAAS,IAAI,GAAG,CAAC;QACjB,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC;QACzC,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC;QACzC,MAAM,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;QACzB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QAChC,SAAS,IAAI,IAAI,CAAC;QAClB,SAAS,IAAI,IAAI,CAAC;QAClB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1C,IAAI,IAAI,IAAI,CAAC;QACb,GAAG,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC;QACzB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC;QAC1D,gBAAgB,IAAI,GAAG,CAAC;QACxB,4BAA4B,IAAI,GAAG,CAAC;QACpC,yBAAyB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG,CAAC;QACtD,oBAAoB,IAAI,GAAG,CAAC;QAC5B,UAAU,CAAC,YAAY,CAAC,EAAE,OAAO,GAAG,GAAG,CAAC;QACxC,mBAAmB,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC;QACrC,aAAa,IAAI,GAAG,CAAC;QACrB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QACpC,QAAQ,EAAE,GAAG,CAAC;QACd,MAAM,EAAE,GAAG,CAAC;QACZ,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,EAAE,GAAG,CAAC;QACnB,eAAe,EAAE,GAAG,CAAC;QACrB,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC;QACzC,eAAe,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAAC;KAChC;CACF;AAED,MAAM,WAAW,gBAAgB;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;
|
|
1
|
+
{"version":3,"file":"vesk-plugin.d.ts","sourceRoot":"","sources":["../src/vesk-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,QAAQ,OAAO,CAAC;IACrB,UAAU,MAAM;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,GAAG,CAAC;QACV,KAAK,EAAE,GAAG,CAAC;QACX,WAAW,EAAE,OAAO,CAAC;QACrB,MAAM,EAAE,OAAO,CAAC;QAChB,UAAU,IAAI,GAAG,CAAC;QAClB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC;QAC7B,KAAK,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC;QAC7B,gBAAgB,IAAI,GAAG,CAAC;QACxB,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,GAAG,GAAG,GAAG,CAAC;QACjE,cAAc,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;QAClD,UAAU,CAAC,qBAAqB,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,EAAE,OAAO,GAAG,GAAG,CAAC;QACnF,SAAS,IAAI,GAAG,CAAC;QACjB,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC;QACzC,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC;QACzC,MAAM,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;QACzB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QAChC,SAAS,IAAI,IAAI,CAAC;QAClB,SAAS,IAAI,IAAI,CAAC;QAClB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1C,UAAU,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC/B,IAAI,IAAI,IAAI,CAAC;QACb,GAAG,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC;QACzB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC;QAC1D,gBAAgB,IAAI,GAAG,CAAC;QACxB,4BAA4B,IAAI,GAAG,CAAC;QACpC,yBAAyB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC;QACjE,yBAAyB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG,CAAC;QACtD,oBAAoB,IAAI,GAAG,CAAC;QAC5B,UAAU,CAAC,YAAY,CAAC,EAAE,OAAO,GAAG,GAAG,CAAC;QACxC,mBAAmB,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC;QACrC,aAAa,IAAI,GAAG,CAAC;QACrB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QACpC,QAAQ,EAAE,GAAG,CAAC;QACd,MAAM,EAAE,GAAG,CAAC;QACZ,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,EAAE,GAAG,CAAC;QACnB,eAAe,EAAE,GAAG,CAAC;QACrB,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC;QACzC,eAAe,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAAC;KAChC;CACF;AAED,MAAM,WAAW,gBAAgB;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAqHD,wBAAgB,gBAAgB,CAAC,MAAM,GAAE,gBAAqB,IACpD,QAAQ,OAAO,KAAK,CAAC,MAAM,KAAG,OAAO,KAAK,CAAC,MAAM,CAud1D"}
|
package/dist/vesk-plugin.js
CHANGED
|
@@ -1,4 +1,116 @@
|
|
|
1
1
|
import * as acorn from 'acorn';
|
|
2
|
+
const VOID_ELEMENTS = new Set([
|
|
3
|
+
'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',
|
|
4
|
+
'link', 'meta', 'param', 'source', 'track', 'wbr',
|
|
5
|
+
]);
|
|
6
|
+
function getJSXElementName(node) {
|
|
7
|
+
if (!node)
|
|
8
|
+
return null;
|
|
9
|
+
if (node.type === 'JSXIdentifier')
|
|
10
|
+
return node.name;
|
|
11
|
+
if (node.type === 'JSXNamespacedName' && node.namespace && node.name) {
|
|
12
|
+
return `${node.namespace.name}:${node.name.name}`;
|
|
13
|
+
}
|
|
14
|
+
if (node.type === 'JSXMemberExpression') {
|
|
15
|
+
const parts = [];
|
|
16
|
+
let cur = node;
|
|
17
|
+
while (cur && cur.type === 'JSXMemberExpression') {
|
|
18
|
+
if (cur.property && cur.property.name)
|
|
19
|
+
parts.unshift(cur.property.name);
|
|
20
|
+
cur = cur.object;
|
|
21
|
+
}
|
|
22
|
+
if (cur && cur.type === 'JSXIdentifier' && cur.name)
|
|
23
|
+
parts.unshift(cur.name);
|
|
24
|
+
return parts.join('.') || null;
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
function isIdentStartCode(code) {
|
|
29
|
+
return (code >= 65 && code <= 90) || (code >= 97 && code <= 122) || code === 95 || code === 36;
|
|
30
|
+
}
|
|
31
|
+
function isIdentCharCode(code) {
|
|
32
|
+
return isIdentStartCode(code) || (code >= 48 && code <= 57);
|
|
33
|
+
}
|
|
34
|
+
function looksLikeGenericArrowAt(input, pos) {
|
|
35
|
+
let i = pos + 1;
|
|
36
|
+
while (i < input.length && isWsChar(input.charCodeAt(i)))
|
|
37
|
+
i++;
|
|
38
|
+
if (i >= input.length || !isIdentStartCode(input.charCodeAt(i)))
|
|
39
|
+
return false;
|
|
40
|
+
while (i < input.length && isIdentCharCode(input.charCodeAt(i)))
|
|
41
|
+
i++;
|
|
42
|
+
while (i < input.length && isWsChar(input.charCodeAt(i)))
|
|
43
|
+
i++;
|
|
44
|
+
if (input.charCodeAt(i) !== 44)
|
|
45
|
+
return false; // ','
|
|
46
|
+
i++;
|
|
47
|
+
while (i < input.length && isWsChar(input.charCodeAt(i)))
|
|
48
|
+
i++;
|
|
49
|
+
if (input.charCodeAt(i) !== 62)
|
|
50
|
+
return false; // '>'
|
|
51
|
+
i++;
|
|
52
|
+
while (i < input.length && isWsChar(input.charCodeAt(i)))
|
|
53
|
+
i++;
|
|
54
|
+
if (input.charCodeAt(i) !== 40)
|
|
55
|
+
return false; // '('
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
const TS_PRIMITIVE_TYPES = new Set(['number', 'string', 'boolean', 'any', 'unknown', 'never', 'void', 'object', 'symbol', 'bigint', 'undefined', 'null']);
|
|
59
|
+
const HTML_TAGS = new Set(['a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'cite', 'code', 'col', 'colgroup', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'menu', 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'slot', 'small', 'source', 'span', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr']);
|
|
60
|
+
function looksLikeTypeAssertionAt(input, pos) {
|
|
61
|
+
let i = pos + 1;
|
|
62
|
+
while (i < input.length && isWsChar(input.charCodeAt(i)))
|
|
63
|
+
i++;
|
|
64
|
+
const nameStart = i;
|
|
65
|
+
if (i >= input.length || !isIdentStartCode(input.charCodeAt(i)))
|
|
66
|
+
return false;
|
|
67
|
+
while (i < input.length && isIdentCharCode(input.charCodeAt(i)))
|
|
68
|
+
i++;
|
|
69
|
+
const name = input.slice(nameStart, i);
|
|
70
|
+
// If it's a known HTML tag (lowercase), it's JSX, not a type assertion
|
|
71
|
+
if (HTML_TAGS.has(name) || VOID_ELEMENTS.has(name))
|
|
72
|
+
return false;
|
|
73
|
+
// Only treat as type assertion if name is a TS primitive or capitalized type
|
|
74
|
+
const isPrimitive = TS_PRIMITIVE_TYPES.has(name);
|
|
75
|
+
const isCapitalized = name[0] >= 'A' && name[0] <= 'Z';
|
|
76
|
+
if (!isPrimitive && !isCapitalized)
|
|
77
|
+
return false;
|
|
78
|
+
// allow qualified type like `ns.Type` or `Array<string>`? For now only single identifier, skip generics check
|
|
79
|
+
// If next is '<', skip balanced <...>
|
|
80
|
+
if (input.charCodeAt(i) === 60) {
|
|
81
|
+
let depth = 0;
|
|
82
|
+
let j = i;
|
|
83
|
+
while (j < input.length) {
|
|
84
|
+
const c = input.charCodeAt(j);
|
|
85
|
+
if (c === 60)
|
|
86
|
+
depth++;
|
|
87
|
+
else if (c === 62) {
|
|
88
|
+
depth--;
|
|
89
|
+
if (depth === 0) {
|
|
90
|
+
i = j + 1;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
j++;
|
|
95
|
+
if (j - i > 100)
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
while (i < input.length && isWsChar(input.charCodeAt(i)))
|
|
100
|
+
i++;
|
|
101
|
+
if (input.charCodeAt(i) !== 62)
|
|
102
|
+
return false; // '>'
|
|
103
|
+
i++;
|
|
104
|
+
while (i < input.length && isWsChar(input.charCodeAt(i)))
|
|
105
|
+
i++;
|
|
106
|
+
if (i >= input.length)
|
|
107
|
+
return false;
|
|
108
|
+
const c = input.charCodeAt(i);
|
|
109
|
+
// expression start: identifier, (, [, {, ", ', `, !, ~, +, -, number, this/super etc.
|
|
110
|
+
if (isIdentStartCode(c) || c === 40 || c === 91 || c === 123 || c === 34 || c === 39 || c === 96 || c === 33 || c === 126 || c === 43 || c === 45 || (c >= 48 && c <= 57))
|
|
111
|
+
return true;
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
2
114
|
function isWsChar(code) {
|
|
3
115
|
return code === 32 || code === 9 || code === 10 || code === 13 || code === 12;
|
|
4
116
|
}
|
|
@@ -58,6 +170,10 @@ export function VeskParserPlugin(config = {}) {
|
|
|
58
170
|
};
|
|
59
171
|
if (inType) {
|
|
60
172
|
if (startsNewStatement) {
|
|
173
|
+
if (looksLikeGenericArrowAt(this.input, this.pos) || looksLikeTypeAssertionAt(this.input, this.pos)) {
|
|
174
|
+
this.#jsxStartsStatement = false;
|
|
175
|
+
return super.readToken(code);
|
|
176
|
+
}
|
|
61
177
|
this.#jsxStartsStatement = true;
|
|
62
178
|
++this.pos;
|
|
63
179
|
return this.finishToken(tstt.jsxTagStart);
|
|
@@ -70,6 +186,10 @@ export function VeskParserPlugin(config = {}) {
|
|
|
70
186
|
prev === tt._this || prev === tt._super || prev === tt._true || prev === tt._false ||
|
|
71
187
|
prev === tt._null || prev === tt.jsxTagEnd;
|
|
72
188
|
if (!canEndExpr || startsNewStatement) {
|
|
189
|
+
if (looksLikeGenericArrowAt(this.input, this.pos) || looksLikeTypeAssertionAt(this.input, this.pos)) {
|
|
190
|
+
this.#jsxStartsStatement = false;
|
|
191
|
+
return super.readToken(code);
|
|
192
|
+
}
|
|
73
193
|
this.#jsxStartsStatement = true;
|
|
74
194
|
return forceJsx();
|
|
75
195
|
}
|
|
@@ -379,6 +499,38 @@ export function VeskParserPlugin(config = {}) {
|
|
|
379
499
|
}
|
|
380
500
|
return super.jsx_parseElementAt(startPos, startLoc);
|
|
381
501
|
}
|
|
502
|
+
jsx_parseOpeningElementAt(startPos, startLoc) {
|
|
503
|
+
// Manual implementation that treats HTML void elements as
|
|
504
|
+
// self-closing even without `/>`. Delegating to super would leave
|
|
505
|
+
// a stale tc_expr context (the `>` updateContext only pops the
|
|
506
|
+
// extra level when a `/` was present), so the following `}` is
|
|
507
|
+
// mis-read as JSX text: "Unexpected token `}`".
|
|
508
|
+
const node = this.startNodeAt(startPos, startLoc);
|
|
509
|
+
node.attributes = [];
|
|
510
|
+
const nodeName = this.jsx_parseElementName();
|
|
511
|
+
if (nodeName)
|
|
512
|
+
node.name = nodeName;
|
|
513
|
+
const nameStr = getJSXElementName(nodeName);
|
|
514
|
+
const isVoid = !!(nameStr && VOID_ELEMENTS.has(nameStr));
|
|
515
|
+
while (this.type !== tt.slash && this.type !== tstt.jsxTagEnd) {
|
|
516
|
+
node.attributes.push(this.jsx_parseAttribute());
|
|
517
|
+
}
|
|
518
|
+
const hasSlash = this.eat(tt.slash);
|
|
519
|
+
node.selfClosing = hasSlash || isVoid;
|
|
520
|
+
if (this.type !== tstt.jsxTagEnd)
|
|
521
|
+
this.unexpected();
|
|
522
|
+
if (isVoid && !hasSlash) {
|
|
523
|
+
const stack = this.context;
|
|
524
|
+
if (stack.length > 0 && stack[stack.length - 1].token === '<tag>...</tag>') {
|
|
525
|
+
stack.pop();
|
|
526
|
+
this.exprAllowed = true;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
// Consume `>`. For void `>` we already popped tc_expr above so the
|
|
530
|
+
// following `}` is read as a normal JS token, not JSX text.
|
|
531
|
+
this.next();
|
|
532
|
+
return this.finishNode(node, nodeName ? 'JSXOpeningElement' : 'JSXOpeningFragment');
|
|
533
|
+
}
|
|
382
534
|
parseStyleElement(startPos, startLoc) {
|
|
383
535
|
const el = this.startNodeAt(startPos, startLoc);
|
|
384
536
|
const openNode = this.startNodeAt(startPos, startLoc);
|