import { t as __name } from "./chunks/rolldown-runtime.mjs"; import { LikeC4Model } from "@likec4/core/model"; import { DependencyList } from "react"; import { LayoutedElementView, LayoutedLikeC4ModelData, LayoutedView, ProjectId, ViewChange, ViewId } from "@likec4/core/types"; import { AdhocViewPredicate } from "@likec4/core/compute-view"; //#region ../vite-plugin/dist/internal/chunks/libs/@nanostores/react.d.mts //#region ../../node_modules/.pnpm/nanostores@1.2.0/node_modules/nanostores/atom/index.d.ts type AllKeys = T extends any ? keyof T : never; type Primitive = boolean | number | string; type ReadonlyIfObject = Value extends undefined ? Value : Value extends ((...args: any) => any) ? Value : Value extends Primitive ? Value : Value extends object ? Readonly : Value; /** * Store object. */ interface ReadableAtom { /** * Get store value. * * In contrast with {@link ReadableAtom#value} this value will be always * initialized even if store had no listeners. * * ```js * $store.get() * ``` * * @returns Store value. */ get(): Value; /** * Low-level attribute to read store’s initial value. */ readonly init: undefined | Value; /** * Listeners count. */ readonly lc: number; /** * Subscribe to store changes. * * In contrast with {@link Store#subscribe} it do not call listener * immediately. * * @param listener Callback with store value and old value. * @returns Function to remove listener. */ listen(listener: (value: ReadonlyIfObject, oldValue: ReadonlyIfObject) => void): () => void; /** * Low-level method to notify listeners about changes in the store. * * Can cause unexpected behaviour when combined with frontend frameworks * that perform equality checks for values, such as React. */ notify(oldValue?: ReadonlyIfObject): void; /** * Unbind all listeners. */ off(): void; /** * Subscribe to store changes and call listener immediately. * * ``` * import { $router } from '../store' * * $router.subscribe(page => { * console.log(page) * }) * ``` * * @param listener Callback with store value and old value. * @returns Function to remove listener. */ subscribe(listener: (value: ReadonlyIfObject, oldValue?: ReadonlyIfObject) => void): () => void; /** * Low-level method to read store’s value without calling `onStart`. * * Try to use only {@link ReadableAtom#get}. * Without subscribers, value can be undefined. */ readonly value: undefined | Value; } /** * Store with a way to manually change the value. */ interface WritableAtom extends ReadableAtom { /** * Change store value. * * ```js * $router.set({ path: location.pathname, page: parse(location.pathname) }) * ``` * * @param newValue New store value. */ set(newValue: Value): void; } interface PreinitializedWritableAtom extends WritableAtom { readonly value: Value; } type Atom = ReadableAtom | WritableAtom; /** * Create store with atomic value. It could be a string or an object, which you * will replace completely. * * If you want to change keys in the object inside store, use {@link map}. * * ```js * import { atom, onMount } from 'nanostores' * * // Initial value * export const $router = atom({ path: '', page: 'home' }) * * function parse () { * $router.set({ path: location.pathname, page: parse(location.pathname) }) * } * * // Listen for URL changes on first store’s listener. * onMount($router, () => { * parse() * window.addEventListener('popstate', parse) * return () => { * window.removeEventListener('popstate', parse) * } * }) * ``` * * @param initialValue Initial value of the store. * @returns The store object with methods to subscribe. */ declare function atom(...args: undefined extends Value ? [] | [Value] : [Value]): PreinitializedWritableAtom & StoreExt; //#endregion //#region ../../node_modules/.pnpm/nanostores@1.2.0/node_modules/nanostores/map/index.d.ts type KeyofBase = keyof any; type Get = Extract[K]; type HasIndexSignature = string extends keyof T ? true : false; type ValueWithUndefinedForIndexSignatures = HasIndexSignature extends true ? undefined | Value[Key] : Value[Key]; type WritableStore = (Value extends object ? MapStore : never) | WritableAtom; type Store = ReadableAtom | WritableStore; type AnyStore = { get(): Value; readonly value: undefined | Value; }; type StoreValue = SomeStore extends { get(): infer Value; } ? Value : any; interface MapStore extends WritableAtom { /** * Subscribe to store changes. * * In contrast with {@link Store#subscribe} it do not call listener * immediately. * * @param listener Callback with store value and old value. * @param changedKey Key that was changed. Will present only if `setKey` * has been used to change a store. * @returns Function to remove listener. */ listen(listener: (value: ReadonlyIfObject, oldValue: ReadonlyIfObject, changedKey: AllKeys) => void): () => void; /** * Low-level method to notify listeners about changes in the store. * * Can cause unexpected behaviour when combined with frontend frameworks * that perform equality checks for values, such as React. */ notify(oldValue?: ReadonlyIfObject, changedKey?: AllKeys): void; /** * Change store value. * * ```js * $settings.set({ theme: 'dark' }) * ``` * * Operation is atomic, subscribers will be notified once with the new value. * `changedKey` will be undefined * * @param newValue New store value. */ set(newValue: Value): void; /** * Change key in store value. * * ```js * $settings.setKey('theme', 'dark') * ``` * * To delete key set `undefined`. * * ```js * $settings.setKey('theme', undefined) * ``` * * @param key The key name. * @param value New value. */ setKey>(key: Key, value: Get | ValueWithUndefinedForIndexSignatures): void; /** * Subscribe to store changes and call listener immediately. * * ``` * import { $router } from '../store' * * $router.subscribe(page => { * console.log(page) * }) * ``` * * @param listener Callback with store value and old value. * @param changedKey Key that was changed. Will present only * if `setKey` has been used to change a store. * @returns Function to remove listener. */ subscribe(listener: (value: ReadonlyIfObject, oldValue: ReadonlyIfObject | undefined, changedKey: AllKeys | undefined) => void): () => void; } interface PreinitializedMapStore extends MapStore { readonly value: Value; } /** * Create map store. Map store is a store with key-value object * as a store value. * * @param init Initialize store and return store destructor. * @returns The store object with methods to subscribe. */ declare function map(value?: Value): PreinitializedMapStore & StoreExt; //#endregion //#region ../../node_modules/.pnpm/@nanostores+react@1.1.0_nanostores@1.2.0_react@19.2.6/node_modules/@nanostores/react/index.d.ts type StoreKeys = T extends { setKey: (k: infer K, v: any) => unknown; } ? K : never; interface UseStoreOptions { /** * @default * ```ts * [store, options.keys] * ``` */ deps?: DependencyList; /** * Will re-render components only on specific key changes. */ keys?: StoreKeys[]; /** * Enable SSR support. Set `initial` when store's initial value is the same on * server and client, or provide a function to return the server store state * for advanced cases (per useSyncExternalStore's getServerSnapshot). */ ssr?: (() => StoreValue) | 'initial' | false; } /** * Subscribe to store changes and get store’s value. * * Can be user with store builder too. * * ```js * import { useStore } from 'nanostores/react' * * import { router } from '../store/router' * * export const Layout = () => { * let page = useStore(router) * if (page.route === 'home') { * return * } else { * return * } * } * ``` * * @param store Store instance. * @returns Store value. */ declare function useStore(store: SomeStore, options?: UseStoreOptions): StoreValue; //#endregion //#endregion //#region ../vite-plugin/dist/internal/chunks/libs/nanostores.d.mts //#region ../../node_modules/.pnpm/nanostores@1.2.0/node_modules/nanostores/task/index.d.ts interface Task extends Promise { t: true; } //#endregion //#region ../../node_modules/.pnpm/nanostores@1.2.0/node_modules/nanostores/computed/index.d.ts type StoreValues = { [Index in keyof Stores]: StoreValue }; interface Computed { /** * @deprecated Use `@nanostores/async`. */ (stores: OriginStore, cb: (value: StoreValue) => Task): ReadableAtom; /** * @deprecated Use `@nanostores/async`. */ (stores: [...OriginStores], cb: (...values: StoreValues) => Task): ReadableAtom; (stores: OriginStore, cb: (value: StoreValue) => Value): ReadableAtom; /** * Create derived store, which use generates value from another stores. * * ```js * import { computed } from 'nanostores' * * import { $users } from './users.js' * * export const $admins = computed($users, users => { * return users.filter(user => user.isAdmin) * }) * ``` * * Use `@nanostores/async` for async function. */ (stores: [...OriginStores], cb: (...values: StoreValues) => Task | Value): ReadableAtom; } declare const computed: Computed; interface Batched { (stores: OriginStore, cb: (value: StoreValue) => Task | Value): ReadableAtom; /** * Create derived store, which use generates value from another stores. * * ```js * import { batched } from 'nanostores' * * const $sortBy = atom('id') * const $category = atom('') * * export const $link = batched([$sortBy, $category], (sortBy, category) => { * return `/api/entities?sortBy=${sortBy}&category=${category}` * }) * ``` */ (stores: [...OriginStores], cb: (...values: StoreValues) => Task | Value): ReadableAtom; } declare const batched: Batched; //#endregion //#endregion //#region ../vite-plugin/dist/internal/index.d.mts //#region src/rpc/protocol.d.ts interface LikeC4VitePluginRpc { /** * Apply semantic layout (if AI is available) * See vite-plugin for more details * * (Available in the dev server) */ applySemanticLayout(payload: { projectId: ProjectId; viewId: ViewId; }): Promise; /** * Send a view change to the server * (Available in the dev server) */ updateView(payload: { projectId: ProjectId; viewId: ViewId; change: ViewChange; }): Promise; /** * Calculate an adhoc view * (Available in the dev server) */ calcAdhocView(payload: { projectId: ProjectId; predicates: AdhocViewPredicate[]; }): Promise; } //#endregion //#region src/internal.d.ts interface LikeC4VitePluginRpcOptions { /** * Function to post raw message */ send: (event: string, data: any) => void; /** * Listener to receive raw message */ on: (event: string, fn: (data: any, ...extras: any[]) => void) => void; } /** * Create a PluginRPC instance for the LikeC4 Vite plugin * used by the Vite plugin in virtual modules */ declare function createRpc(options: LikeC4VitePluginRpcOptions): LikeC4VitePluginRpc; declare function createHooksForModel($atom: WritableAtom): { updateModel: (data: LayoutedLikeC4ModelData) => void; $likec4model: Atom; useLikeC4Model: () => LikeC4Model.Layouted; useLikeC4Views: () => ReadonlyArray; useLikeC4View: (viewId: string) => LayoutedView | null; }; //#endregion //#endregion export { type Atom, type LikeC4VitePluginRpc, LikeC4VitePluginRpcOptions, type ReadableAtom, type WritableAtom, atom, batched, computed, createHooksForModel, createRpc, map, useStore };