@lattice-php/lattice 0.39.0 → 0.41.0

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.
Files changed (53) hide show
  1. package/README.md +14 -0
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.js +1 -1
  4. package/dist/provider-base.js +1 -1
  5. package/dist/provider-base.js.map +1 -1
  6. package/dist/registry.js +1 -1
  7. package/dist/registry.js.map +1 -1
  8. package/dist/runtime.d.ts +11 -3
  9. package/dist/runtime.js +12 -3
  10. package/dist/types/core-augmentation.d.ts +2 -1
  11. package/dist/vite.js +2 -0
  12. package/dist/vite.js.map +1 -1
  13. package/dist-standalone/chunks/chart-view-DghsYabe.js +59 -0
  14. package/dist-standalone/chunks/format-context-DCYPeoEM.js +1 -0
  15. package/dist-standalone/chunks/{rich-editor-field-n-mtzlT-.js → rich-editor-field-DnkT5hlA.js} +40 -40
  16. package/dist-standalone/chunks/runtime-zkYqbYk4.js +27 -0
  17. package/dist-standalone/chunks/{icon-button-COE_nq4v.js → toolbar-button-BmtWFTk1.js} +1 -1
  18. package/dist-standalone/lattice.css +1 -1
  19. package/dist-standalone/lattice.js +1 -1
  20. package/dist-standalone/manifest.json +1 -1
  21. package/dist-standalone/react-dom.js +1 -0
  22. package/dist-standalone/runtime.js +1 -1
  23. package/package.json +8 -16
  24. package/dist/_virtual/_rolldown/runtime.js +0 -27
  25. package/dist/action/components/action-form.d.ts +0 -1
  26. package/dist/action/components/action-form.js +0 -10
  27. package/dist/action/components/action-form.js.map +0 -1
  28. package/dist/action/components/action-group.d.ts +0 -3
  29. package/dist/action/components/action-group.js +0 -51
  30. package/dist/action/components/action-group.js.map +0 -1
  31. package/dist/action/components/action-trigger-provider.d.ts +0 -10
  32. package/dist/action/components/action-trigger-provider.js +0 -24
  33. package/dist/action/components/action-trigger-provider.js.map +0 -1
  34. package/dist/action/components/action.d.ts +0 -3
  35. package/dist/action/components/action.js +0 -36
  36. package/dist/action/components/action.js.map +0 -1
  37. package/dist/action/hooks/use-action.d.ts +0 -18
  38. package/dist/action/hooks/use-action.js +0 -100
  39. package/dist/action/hooks/use-action.js.map +0 -1
  40. package/dist/action/index.d.ts +0 -8
  41. package/dist/action/index.js +0 -11
  42. package/dist/action/lib/action-label.d.ts +0 -2
  43. package/dist/action/lib/action-label.js +0 -9
  44. package/dist/action/lib/action-label.js.map +0 -1
  45. package/dist/action/lib/run-action.d.ts +0 -1
  46. package/dist/action/lib/run-action.js +0 -10
  47. package/dist/action/lib/run-action.js.map +0 -1
  48. package/dist/action/plugin.d.ts +0 -2
  49. package/dist/action/plugin.js +0 -15
  50. package/dist/action/plugin.js.map +0 -1
  51. package/dist-standalone/chunks/chart-view-DFSCMDuw.js +0 -59
  52. package/dist-standalone/chunks/number-DjNO0Pxv.js +0 -1
  53. package/dist-standalone/chunks/runtime-Bh_GyTCD.js +0 -23
package/README.md ADDED
@@ -0,0 +1,14 @@
1
+ # Lattice
2
+
3
+ Server-driven React components for Laravel and Inertia.
4
+
5
+ This is the full Lattice framework — the package you install as `lattice-php/lattice` and `@lattice-php/lattice`. It ties together [core](https://github.com/lattice-php/core), [ui](https://github.com/lattice-php/ui), [form](https://github.com/lattice-php/form), and [table](https://github.com/lattice-php/table) and adds actions, layouts, fragments, notifications, realtime, theming, and the Vite tooling.
6
+
7
+ ```bash
8
+ composer require lattice-php/lattice
9
+ npm install @lattice-php/lattice
10
+ ```
11
+
12
+ Documentation: [latticephp.com](https://latticephp.com)
13
+
14
+ Development happens in the [lattice-php/lattice monorepo](https://github.com/lattice-php/lattice); this repository is a read-only split. Please open issues and pull requests there.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import "./types/core-augmentation.js";
1
2
  export { registry } from './registry.js';
2
3
  export { useChat } from './chat/hooks/use-chat.js';
3
4
  export { chatComponents } from './chat/plugin.js';
package/dist/index.js CHANGED
@@ -20,8 +20,8 @@ import { LATTICE_REF_HEADER, withRefHeader } from "@lattice-php/core/component-r
20
20
  import { Icon, IconRenderer, IconRendererProvider, SpriteProvider } from "@lattice-php/ui/icons";
21
21
  import { Renderer } from "@lattice-php/core/renderer";
22
22
  import { LATTICE_EVENT } from "@lattice-php/core/event-names";
23
- import { useEffectDispatcher } from "@lattice-php/ui/effects/use-effect-dispatcher";
24
23
  import { dispatchActionError, dispatchEffects, getActionEffects, isActionEffect } from "@lattice-php/ui/effects/dispatch";
24
+ import { useEffectDispatcher } from "@lattice-php/ui/effects/use-effect-dispatcher";
25
25
  import { builtinEffectHandlers, effectHandler, mergeEffectHandlers } from "@lattice-php/ui/effects/registry";
26
26
  import { copyToClipboard } from "@lattice-php/ui/copyable-text";
27
27
  import { columnCell } from "@lattice-php/table/registry";
@@ -1,9 +1,9 @@
1
1
  import { updateAppearance } from "./appearance/index.js";
2
2
  import { Toaster } from "./toast/toaster.js";
3
- import { ActionInteractionProvider } from "./action/components/action-trigger-provider.js";
4
3
  import { EventBridge } from "./event-bridge.js";
5
4
  import { RegistryContext } from "@lattice-php/core/registry-context";
6
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { ActionInteractionProvider } from "@lattice-php/action/components/action-trigger-provider";
7
7
  import { useFlashEffects } from "@lattice-php/ui/effects/use-flash-effects";
8
8
  import { SpriteProvider } from "@lattice-php/ui/icons/sprite";
9
9
  //#region resources/js/provider-base.tsx
@@ -1 +1 @@
1
- {"version":3,"file":"provider-base.js","names":[],"sources":["../resources/js/provider-base.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { ActionInteractionProvider } from \"./action/components/action-trigger-provider\";\nimport type { Registry } from \"@lattice-php/core/registry\";\nimport { RegistryContext } from \"@lattice-php/core/registry-context\";\nimport { useFlashEffects } from \"@lattice-php/ui/effects/use-flash-effects\";\nimport { EventBridge } from \"./event-bridge\";\nimport type { SpriteValue } from \"@lattice-php/ui/icons/sprite\";\nimport { SpriteProvider } from \"@lattice-php/ui/icons/sprite\";\nimport { Toaster } from \"./toast\";\nimport { updateAppearance } from \"./appearance\";\n\nconst defaultSprite: SpriteValue = { href: \"\" };\n\nexport type ProviderBaseProps = {\n children: ReactNode;\n registry: Registry;\n sprite?: SpriteValue;\n toaster?: boolean;\n};\n\nexport function ProviderBase({\n children,\n registry,\n sprite = defaultSprite,\n toaster = true,\n}: ProviderBaseProps) {\n useFlashEffects();\n\n return (\n <RegistryContext.Provider value={registry}>\n <ActionInteractionProvider>\n <SpriteProvider sprite={sprite}>\n {children}\n <EventBridge onAppearanceChange={updateAppearance} />\n {toaster ? <Toaster /> : null}\n </SpriteProvider>\n </ActionInteractionProvider>\n </RegistryContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;;AAWA,IAAM,gBAA6B,EAAE,MAAM,GAAG;AAS9C,SAAgB,aAAa,EAC3B,UACA,UACA,SAAS,eACT,UAAU,QACU;CACpB,gBAAgB;CAEhB,OACE,oBAAC,gBAAgB,UAAjB;EAA0B,OAAO;EAC/B,UAAA,oBAAC,2BAAD,EAAA,UACE,qBAAC,gBAAD;GAAwB;GAAxB,UAAA;IACG;IACD,oBAAC,aAAD,EAAa,oBAAoB,iBAAmB,CAAA;IACnD,UAAU,oBAAC,SAAD,CAAU,CAAA,IAAI;GACX;EACS,CAAA,EAAA,CAAA;CACH,CAAA;AAE9B"}
1
+ {"version":3,"file":"provider-base.js","names":[],"sources":["../resources/js/provider-base.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { ActionInteractionProvider } from \"@lattice-php/action/components/action-trigger-provider\";\nimport type { Registry } from \"@lattice-php/core/registry\";\nimport { RegistryContext } from \"@lattice-php/core/registry-context\";\nimport { useFlashEffects } from \"@lattice-php/ui/effects/use-flash-effects\";\nimport { EventBridge } from \"./event-bridge\";\nimport type { SpriteValue } from \"@lattice-php/ui/icons/sprite\";\nimport { SpriteProvider } from \"@lattice-php/ui/icons/sprite\";\nimport { Toaster } from \"./toast\";\nimport { updateAppearance } from \"./appearance\";\n\nconst defaultSprite: SpriteValue = { href: \"\" };\n\nexport type ProviderBaseProps = {\n children: ReactNode;\n registry: Registry;\n sprite?: SpriteValue;\n toaster?: boolean;\n};\n\nexport function ProviderBase({\n children,\n registry,\n sprite = defaultSprite,\n toaster = true,\n}: ProviderBaseProps) {\n useFlashEffects();\n\n return (\n <RegistryContext.Provider value={registry}>\n <ActionInteractionProvider>\n <SpriteProvider sprite={sprite}>\n {children}\n <EventBridge onAppearanceChange={updateAppearance} />\n {toaster ? <Toaster /> : null}\n </SpriteProvider>\n </ActionInteractionProvider>\n </RegistryContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;;AAWA,IAAM,gBAA6B,EAAE,MAAM,GAAG;AAS9C,SAAgB,aAAa,EAC3B,UACA,UACA,SAAS,eACT,UAAU,QACU;CACpB,gBAAgB;CAEhB,OACE,oBAAC,gBAAgB,UAAjB;EAA0B,OAAO;EAC/B,UAAA,oBAAC,2BAAD,EAAA,UACE,qBAAC,gBAAD;GAAwB;GAAxB,UAAA;IACG;IACD,oBAAC,aAAD,EAAa,oBAAoB,iBAAmB,CAAA;IACnD,UAAU,oBAAC,SAAD,CAAU,CAAA,IAAI;GACX;EACS,CAAA,EAAA,CAAA;CACH,CAAA;AAE9B"}
package/dist/registry.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { layoutComponents } from "./layout/plugin.js";
2
- import { actionComponents } from "./action/plugin.js";
3
2
  import { chatComponents } from "./chat/plugin.js";
4
3
  import { fragmentComponents } from "./fragments/plugin.js";
5
4
  import { notificationsComponents } from "./notifications/plugin.js";
6
5
  import { remoteComponents } from "./remote/plugin.js";
7
6
  import { createRegistry } from "@lattice-php/core/registry";
7
+ import { actionComponents } from "@lattice-php/action/plugin";
8
8
  import { formComponents } from "@lattice-php/form";
9
9
  import { tableComponents } from "@lattice-php/table";
10
10
  import { uiComponents } from "@lattice-php/ui";
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","names":[],"sources":["../resources/js/registry.ts"],"sourcesContent":["import { createRegistry } from \"@lattice-php/core/registry\";\nimport type {\n ActionNodeType,\n ChatNodeType,\n FormNodeType,\n FragmentNodeType,\n LayoutNodeType,\n NodeType,\n NotificationNodeType,\n RemoteNodeType,\n TableNodeType,\n UiNodeType,\n} from \"@lattice-php/lattice/types/generated\";\nimport { actionComponents } from \"./action/plugin\";\nimport { chatComponents } from \"./chat/plugin\";\nimport { formComponents } from \"@lattice-php/form\";\nimport { fragmentComponents } from \"./fragments/plugin\";\nimport { layoutComponents } from \"./layout/plugin\";\nimport { notificationsComponents } from \"./notifications/plugin\";\nimport { remoteComponents } from \"./remote/plugin\";\nimport { tableComponents } from \"@lattice-php/table\";\nimport { uiComponents } from \"@lattice-php/ui\";\n\n// Compile-time totality: every generated NodeType must belong to a registered\n// plugin's union. A new PHP domain fails here until its plugin exists.\ntype RegisteredNodeType =\n | ActionNodeType\n | ChatNodeType\n | FormNodeType\n | FragmentNodeType\n | LayoutNodeType\n | NotificationNodeType\n | RemoteNodeType\n | TableNodeType\n | UiNodeType;\ntype Assert<T extends true> = T;\nexport type AllNodeTypesRegistered = Assert<\n Exclude<NodeType, RegisteredNodeType> extends never ? true : false\n>;\n\nexport const registry = createRegistry(\n uiComponents,\n fragmentComponents,\n actionComponents,\n formComponents,\n layoutComponents,\n tableComponents,\n chatComponents,\n notificationsComponents,\n remoteComponents,\n);\n"],"mappings":";;;;;;;;;;;AAwCA,IAAa,WAAW,eACtB,cACA,oBACA,kBACA,gBACA,kBACA,iBACA,gBACA,yBACA,gBACF"}
1
+ {"version":3,"file":"registry.js","names":[],"sources":["../resources/js/registry.ts"],"sourcesContent":["import { createRegistry } from \"@lattice-php/core/registry\";\nimport type {\n ActionNodeType,\n ChatNodeType,\n FormNodeType,\n FragmentNodeType,\n LayoutNodeType,\n NodeType,\n NotificationNodeType,\n RemoteNodeType,\n TableNodeType,\n UiNodeType,\n} from \"@lattice-php/lattice/types/generated\";\nimport { actionComponents } from \"@lattice-php/action/plugin\";\nimport { chatComponents } from \"./chat/plugin\";\nimport { formComponents } from \"@lattice-php/form\";\nimport { fragmentComponents } from \"./fragments/plugin\";\nimport { layoutComponents } from \"./layout/plugin\";\nimport { notificationsComponents } from \"./notifications/plugin\";\nimport { remoteComponents } from \"./remote/plugin\";\nimport { tableComponents } from \"@lattice-php/table\";\nimport { uiComponents } from \"@lattice-php/ui\";\n\n// Compile-time totality: every generated NodeType must belong to a registered\n// plugin's union. A new PHP domain fails here until its plugin exists.\ntype RegisteredNodeType =\n | ActionNodeType\n | ChatNodeType\n | FormNodeType\n | FragmentNodeType\n | LayoutNodeType\n | NotificationNodeType\n | RemoteNodeType\n | TableNodeType\n | UiNodeType;\ntype Assert<T extends true> = T;\nexport type AllNodeTypesRegistered = Assert<\n Exclude<NodeType, RegisteredNodeType> extends never ? true : false\n>;\n\nexport const registry = createRegistry(\n uiComponents,\n fragmentComponents,\n actionComponents,\n formComponents,\n layoutComponents,\n tableComponents,\n chatComponents,\n notificationsComponents,\n remoteComponents,\n);\n"],"mappings":";;;;;;;;;;;AAwCA,IAAa,WAAW,eACtB,cACA,oBACA,kBACA,gBACA,kBACA,iBACA,gBACA,yBACA,gBACF"}
package/dist/runtime.d.ts CHANGED
@@ -1,9 +1,17 @@
1
1
  export * from './index.js';
2
2
  export { router } from '@inertiajs/react';
3
- export { apiJson } from '@lattice-php/core/api';
3
+ export { runAction } from '@lattice-php/action';
4
+ export { apiFetch, apiJson, setRefRefreshEndpoint, xsrfToken } from '@lattice-php/core/api';
5
+ export { RenderNode } from '@lattice-php/core/renderer';
4
6
  export { nodeIdentity } from '@lattice-php/core/test-id';
5
- export { cn, usePersistentState } from '@lattice-php/ui';
6
- export { setRefRefreshEndpoint } from '@lattice-php/core/api';
7
+ export { requestSignedUpload, xhrTransfer } from '@lattice-php/core/upload';
8
+ export { SimpleField } from '@lattice-php/form/components/fields/simple-field';
9
+ export { RICH_EDITOR_EXTENSION, ToolbarIconButton } from '@lattice-php/form/rich-editor';
7
10
  export * from '@lattice-php/form/toolkit';
11
+ export { useTable } from '@lattice-php/table/hooks/use-table';
12
+ export { useTableSelection } from '@lattice-php/table/hooks/use-table-selection';
13
+ export { getBulkActions } from '@lattice-php/table/lib/bulk';
14
+ export { Button, Checkbox, cn, ConfirmDialog, Dialog, DialogContent, DialogHeader, formatDateValue, IconButton, Input, Label, NativeSelect, PreviewableImage, useDebouncedCallback, useFormatContext, usePersistentState, } from '@lattice-php/ui';
8
15
  export * from '@lattice-php/ui/i18n';
16
+ export { announce, attachTreeItemInstruction, combine, draggable, dropTargetForElements, extractTreeItemInstruction, } from './dnd/index.js';
9
17
  export type { Variant } from './toast/index.js';
package/dist/runtime.js CHANGED
@@ -15,10 +15,19 @@ import { registry } from "./registry.js";
15
15
  import { createLatticeApp } from "./create-app.js";
16
16
  import { Provider, useColumnRegistry, useComponentRegistry } from "./provider.js";
17
17
  import { Icon, IconRenderer, IconRendererProvider, LATTICE_EVENT, LATTICE_REF_HEADER, Renderer, SpriteProvider, builtinEffectHandlers, columnCell, copyToClipboard, createRegistry, dispatchActionError, dispatchEffects, eagerComponent, effectHandler, extendRegistry, getActionEffects, isActionEffect, lazyComponent, loadPluginModules, mergeEffectHandlers, useEffectDispatcher, withHeaders, withRefHeader } from "./index.js";
18
+ import { announce, attachTreeItemInstruction, combine, draggable, dropTargetForElements, extractTreeItemInstruction } from "./dnd/index.js";
18
19
  import { router } from "@inertiajs/react";
19
- import { apiJson, setRefRefreshEndpoint } from "@lattice-php/core/api";
20
+ import { apiFetch, apiJson, setRefRefreshEndpoint, xsrfToken } from "@lattice-php/core/api";
21
+ import { RenderNode } from "@lattice-php/core/renderer";
20
22
  import { nodeIdentity } from "@lattice-php/core/test-id";
21
- import { cn, usePersistentState } from "@lattice-php/ui";
23
+ import { Button, Checkbox, ConfirmDialog, Dialog, DialogContent, DialogHeader, IconButton, Input, Label, NativeSelect, PreviewableImage, cn, formatDateValue, useDebouncedCallback, useFormatContext, usePersistentState } from "@lattice-php/ui";
24
+ import { runAction } from "@lattice-php/action";
25
+ import { requestSignedUpload, xhrTransfer } from "@lattice-php/core/upload";
26
+ import { SimpleField } from "@lattice-php/form/components/fields/simple-field";
27
+ import { RICH_EDITOR_EXTENSION, ToolbarIconButton } from "@lattice-php/form/rich-editor";
28
+ import { useTable } from "@lattice-php/table/hooks/use-table";
29
+ import { useTableSelection } from "@lattice-php/table/hooks/use-table-selection";
30
+ import { getBulkActions } from "@lattice-php/table/lib/bulk";
22
31
  export * from "@lattice-php/ui/i18n";
23
32
  export * from "@lattice-php/form/toolkit";
24
- export { Callouts, EventBridge, Icon, IconRenderer, IconRendererProvider, LATTICE_EVENT, LATTICE_REF_HEADER, OutletContext, Provider, RealtimeListeners, Renderer, SchemaLayout, SidebarCollapsedContext, SpriteProvider, Toaster, apiJson, builtinEffectHandlers, chatComponents, cn, columnCell, copyToClipboard, createLatticeApp, createLayoutResolver, createPageResolver, createRegistry, dispatchActionError, dispatchEffects, eagerComponent, effectHandler, extendRegistry, getActionEffects, initializeAppearance, isActionEffect, layoutComponents, lazyComponent, loadPluginModules, mergeEffectHandlers, nodeIdentity, onCallout, onToast, pageComponentName, registry, router, setRefRefreshEndpoint, updateAppearance, useAppearance, useChat, useColumnRegistry, useComponentRegistry, useEffectDispatcher, usePersistentState, useSidebarCollapsed, withHeaders, withRefHeader, withVisitHeaders };
33
+ export { Button, Callouts, Checkbox, ConfirmDialog, Dialog, DialogContent, DialogHeader, EventBridge, Icon, IconButton, IconRenderer, IconRendererProvider, Input, LATTICE_EVENT, LATTICE_REF_HEADER, Label, NativeSelect, OutletContext, PreviewableImage, Provider, RICH_EDITOR_EXTENSION, RealtimeListeners, RenderNode, Renderer, SchemaLayout, SidebarCollapsedContext, SimpleField, SpriteProvider, Toaster, ToolbarIconButton, announce, apiFetch, apiJson, attachTreeItemInstruction, builtinEffectHandlers, chatComponents, cn, columnCell, combine, copyToClipboard, createLatticeApp, createLayoutResolver, createPageResolver, createRegistry, dispatchActionError, dispatchEffects, draggable, dropTargetForElements, eagerComponent, effectHandler, extendRegistry, extractTreeItemInstruction, formatDateValue, getActionEffects, getBulkActions, initializeAppearance, isActionEffect, layoutComponents, lazyComponent, loadPluginModules, mergeEffectHandlers, nodeIdentity, onCallout, onToast, pageComponentName, registry, requestSignedUpload, router, runAction, setRefRefreshEndpoint, updateAppearance, useAppearance, useChat, useColumnRegistry, useComponentRegistry, useDebouncedCallback, useEffectDispatcher, useFormatContext, usePersistentState, useSidebarCollapsed, useTable, useTableSelection, withHeaders, withRefHeader, withVisitHeaders, xhrTransfer, xsrfToken };
@@ -1,4 +1,5 @@
1
1
  import { ComponentPropsMap } from './generated.js';
2
2
  declare module "@lattice-php/core" {
3
- interface ComponentProps extends ComponentPropsMap {}
3
+ interface ComponentProps extends ComponentPropsMap {
4
+ }
4
5
  }
package/dist/vite.js CHANGED
@@ -102,6 +102,7 @@ function latticeConfig(options = {}) {
102
102
  ...options.source ? { alias: {
103
103
  "@lattice-php/lattice/css": path.resolve(root, "../ui/resources/css/lattice.css"),
104
104
  "@lattice-php/lattice": path.resolve(root, "resources/js"),
105
+ "@lattice-php/action": path.resolve(root, "../action/resources/js"),
105
106
  "@lattice-php/core": path.resolve(root, "../core/resources/js"),
106
107
  "@lattice-php/form": path.resolve(root, "../form/resources/js"),
107
108
  "@lattice-php/table": path.resolve(root, "../table/resources/js"),
@@ -117,6 +118,7 @@ function latticeConfig(options = {}) {
117
118
  server: options.source ? { fs: { allow: [searchForWorkspaceRoot(appRoot), root] } } : void 0,
118
119
  test: { server: { deps: { inline: [
119
120
  "@lattice-php/lattice",
121
+ "@lattice-php/action",
120
122
  "@lattice-php/core",
121
123
  "@lattice-php/form",
122
124
  "@lattice-php/table",
package/dist/vite.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vite.js","names":[],"sources":["../resources/js/vite.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { svgSprite } from \"@lattice-php/vite-svg-sprite\";\nimport type { IconTypesOptions, SvgSpriteOptions } from \"@lattice-php/vite-svg-sprite\";\nimport { searchForWorkspaceRoot } from \"vite\";\nimport type { Plugin, PluginOption, UserConfig } from \"vite\";\nimport { refreshTypeScriptTypes } from \"./vite-typescript-refresh.ts\";\n\ntype InlineDependency = string | RegExp;\n\ntype ConfigWithTest = UserConfig & {\n test?: {\n server?: {\n deps?: {\n inline?: InlineDependency[];\n };\n };\n };\n};\n\nexport type LatticeViteIconsOptions = Omit<SvgSpriteOptions, \"dts\" | \"iconDirs\"> & {\n dirs?: string[];\n dts?: Partial<IconTypesOptions> | false;\n};\n\nexport type LatticeViteOptions = {\n appRoot?: string;\n icons?: boolean | LatticeViteIconsOptions;\n root?: string;\n source?: boolean;\n /** Refresh generated TypeScript types via the dev server. Defaults to `true`. */\n typescript?: boolean;\n};\n\ntype Roots = {\n appRoot: string;\n root: string;\n};\n\nexport function lattice(options: LatticeViteOptions = {}): PluginOption[] {\n const { appRoot } = resolveRoots(options);\n const plugins: PluginOption[] = [\n corePlugin(options),\n optionalPeersPlugin(),\n componentPackagesPlugin(discoverComponentPackages(appRoot)),\n typescriptPlugin(options),\n ];\n const iconOptions = resolveIconOptions(options);\n\n if (iconOptions) {\n plugins.push(svgSprite(iconOptions));\n }\n\n return plugins;\n}\n\n/** A Composer package that contributes a Lattice component plugin. */\nexport type LatticeComponentPackage = {\n name: string;\n /** Absolute path to the package's installed directory. */\n dir: string;\n /** Absolute path to the package's JS plugin entry. */\n plugin: string;\n};\n\ntype InstalledPackage = {\n name: string;\n \"install-path\"?: string;\n extra?: { lattice?: { plugin?: string } };\n};\n\ntype RootPackageJson = {\n name?: string;\n extra?: { lattice?: { plugin?: string } };\n};\n\n/**\n * Resolve every Composer package that declares `extra.lattice.plugin` into an\n * absolute plugin-entry path. `installPathsRelativeTo` is `vendor/composer` (the\n * dir `installed.json` records its `install-path`s against).\n */\nexport function collectComponentPackages(\n installed: { packages?: InstalledPackage[] } | InstalledPackage[],\n installPathsRelativeTo: string,\n): LatticeComponentPackage[] {\n const packages = Array.isArray(installed) ? installed : (installed.packages ?? []);\n\n return packages.flatMap((pkg) => {\n const entry = pkg.extra?.lattice?.plugin;\n\n if (typeof entry !== \"string\") {\n return [];\n }\n\n const dir = path.resolve(installPathsRelativeTo, pkg[\"install-path\"] ?? `../${pkg.name}`);\n\n return [{ name: pkg.name, dir, plugin: path.resolve(dir, entry) }];\n });\n}\n\n/**\n * Resolve the composer ROOT project's own `extra.lattice.plugin` — Composer\n * never lists the root package in `installed.json`, so a component package\n * declaring the plugin entry in its own composer.json would otherwise be\n * invisible to its own dev server (e.g. inside a testbench workbench, where\n * the package itself is the app root).\n */\nexport function collectRootComponentPackage(\n composerJson: RootPackageJson,\n appRoot: string,\n): LatticeComponentPackage[] {\n const entry = composerJson.extra?.lattice?.plugin;\n\n if (typeof entry !== \"string\" || typeof composerJson.name !== \"string\") {\n return [];\n }\n\n return [{ name: composerJson.name, dir: appRoot, plugin: path.resolve(appRoot, entry) }];\n}\n\n/**\n * Read `<appRoot>/vendor/composer/installed.json` and `<appRoot>/composer.json`\n * and collect every component package they contribute.\n */\nexport function discoverComponentPackages(appRoot: string): LatticeComponentPackage[] {\n const composerDir = path.resolve(appRoot, \"vendor/composer\");\n\n let installed: LatticeComponentPackage[] = [];\n\n try {\n const raw = readFileSync(path.join(composerDir, \"installed.json\"), \"utf8\");\n installed = collectComponentPackages(JSON.parse(raw), composerDir);\n } catch {\n installed = [];\n }\n\n let root: LatticeComponentPackage[] = [];\n\n try {\n const raw = readFileSync(path.join(appRoot, \"composer.json\"), \"utf8\");\n root = collectRootComponentPackage(JSON.parse(raw), appRoot);\n } catch {\n root = [];\n }\n\n return [...installed, ...root];\n}\n\nconst VIRTUAL_PLUGINS_ID = \"virtual:lattice/plugins\";\nconst RESOLVED_VIRTUAL_PLUGINS_ID = `\\0${VIRTUAL_PLUGINS_ID}`;\n\n/**\n * Exposes the discovered component packages as `virtual:lattice/plugins` — a\n * module whose default export is the array of their plugin objects,\n * ready for `extendRegistry(registry, ...plugins)`. Also grants Vite filesystem\n * access to each package dir so its source compiles from `vendor/` (or a symlink).\n */\nexport function componentPackagesPlugin(packages: LatticeComponentPackage[]): Plugin {\n return {\n name: \"lattice:component-packages\",\n config(config) {\n if (packages.length === 0) {\n return {};\n }\n\n const workspaceRoot = searchForWorkspaceRoot(config.root ?? process.cwd());\n\n return { server: { fs: { allow: [workspaceRoot, ...packages.map((pkg) => pkg.dir)] } } };\n },\n resolveId(id) {\n return id === VIRTUAL_PLUGINS_ID ? RESOLVED_VIRTUAL_PLUGINS_ID : null;\n },\n load(id) {\n if (id !== RESOLVED_VIRTUAL_PLUGINS_ID) {\n return null;\n }\n\n const imports = packages\n .map((pkg, index) => `import p${index} from ${JSON.stringify(pkg.plugin)};`)\n .join(\"\\n\");\n const list = packages.map((_, index) => `p${index}`).join(\", \");\n\n return `${imports}\\nexport default [${list}];\\n`;\n },\n };\n}\n\nexport function latticeConfig(options: LatticeViteOptions = {}): ConfigWithTest {\n const { appRoot, root } = resolveRoots(options);\n\n return {\n resolve: {\n // A react alias would break SSR: Vite only externalizes bare specifiers,\n // so an absolute path inlines react's CJS into the SSR module runner.\n // `dedupe` alone keeps the app on a single React copy, symlinks included.\n ...(options.source\n ? {\n alias: {\n \"@lattice-php/lattice/css\": path.resolve(root, \"../ui/resources/css/lattice.css\"),\n \"@lattice-php/lattice\": path.resolve(root, \"resources/js\"),\n \"@lattice-php/core\": path.resolve(root, \"../core/resources/js\"),\n \"@lattice-php/form\": path.resolve(root, \"../form/resources/js\"),\n \"@lattice-php/table\": path.resolve(root, \"../table/resources/js\"),\n \"@lattice-php/ui/css\": path.resolve(root, \"../ui/resources/css/lattice.css\"),\n \"@lattice-php/ui\": path.resolve(root, \"../ui/resources/js\"),\n },\n }\n : {}),\n dedupe: [\"@inertiajs/react\", \"react\", \"react-dom\"],\n },\n server: options.source\n ? {\n fs: {\n allow: [searchForWorkspaceRoot(appRoot), root],\n },\n }\n : undefined,\n test: {\n server: {\n deps: {\n inline: [\n \"@lattice-php/lattice\",\n \"@lattice-php/core\",\n \"@lattice-php/form\",\n \"@lattice-php/table\",\n \"@lattice-php/ui\",\n /[/\\\\]lattice[/\\\\]dist[/\\\\]/,\n /[/\\\\]lattice[/\\\\]node_modules[/\\\\]@radix-ui[/\\\\]/,\n /[/\\\\]lattice[/\\\\]node_modules[/\\\\]@tiptap[/\\\\]/,\n /[/\\\\]lattice[/\\\\]node_modules[/\\\\]react-i18next[/\\\\]/,\n ],\n },\n },\n },\n };\n}\n\nfunction corePlugin(options: LatticeViteOptions): Plugin {\n return {\n name: \"lattice\",\n config() {\n return latticeConfig(options);\n },\n };\n}\n\nconst OPTIONAL_PEER_STUB_PREFIX = \"\\0lattice-optional-peer/\";\n\n/**\n * Real-time listeners statically import their optional Echo peers. A consumer\n * that never uses real-time should still build, so stub a missing peer with\n * hooks that throw — the `RealtimeListeners` error boundary then degrades\n * gracefully and warns to install the peer, exactly as when it is absent.\n */\nconst OPTIONAL_PEER_STUBS: Record<string, string> = {\n \"@laravel/echo-react\": [\n \"const missing = () => {\",\n \" throw new Error(\",\n ' \"[lattice] Real-time listeners require @laravel/echo-react. Install it and call configureEcho().\",',\n \" );\",\n \"};\",\n \"export const useEcho = missing;\",\n \"export const useEchoPublic = missing;\",\n \"export const useEchoPresence = missing;\",\n \"export const useEchoNotification = missing;\",\n ].join(\"\\n\"),\n};\n\nfunction optionalPeersPlugin(): Plugin {\n return {\n name: \"lattice:optional-peers\",\n enforce: \"pre\",\n async resolveId(id) {\n if (!Object.prototype.hasOwnProperty.call(OPTIONAL_PEER_STUBS, id)) {\n return null;\n }\n\n const installed = await this.resolve(id, undefined, { skipSelf: true });\n\n return installed ? null : `${OPTIONAL_PEER_STUB_PREFIX}${id}`;\n },\n load(id) {\n if (!id.startsWith(OPTIONAL_PEER_STUB_PREFIX)) {\n return null;\n }\n\n return OPTIONAL_PEER_STUBS[id.slice(OPTIONAL_PEER_STUB_PREFIX.length)] ?? null;\n },\n };\n}\n\n/**\n * Refreshes `node.props` typings from the app's own `php artisan\n * lattice:typescript` whenever the dev server starts — installing or updating\n * a component package would otherwise leave its generated types stale until\n * someone remembers to run the command by hand. Dev-server only: a production\n * build machine may not have PHP installed, and the generated file is a dev\n * ergonomics artifact, not a build input.\n *\n * Module-private like its siblings `optionalPeersPlugin`/`corePlugin` — the\n * `refreshTypeScriptTypes` DI seam it defers to lives in\n * `./vite-typescript-refresh`, which isn't part of the published `vite`\n * subpath either (see that module for why).\n */\nfunction typescriptPlugin(options: LatticeViteOptions): Plugin {\n return {\n name: \"lattice:typescript\",\n apply: \"serve\",\n configureServer(server) {\n const typescript = options.typescript ?? true;\n\n if (typescript === false) {\n return;\n }\n\n const { appRoot } = resolveRoots(options);\n\n refreshTypeScriptTypes(appRoot, server.config.logger);\n },\n };\n}\n\nexport function resolveIconOptions(options: LatticeViteOptions): SvgSpriteOptions | null {\n const icons = options.icons ?? true;\n\n if (icons === false) {\n return null;\n }\n\n const { root } = resolveRoots(options);\n const iconOptions = icons === true ? {} : icons;\n const { dirs = [], dts, ...spriteOptions } = iconOptions;\n const defaultTypes = {\n file: \"resources/js/types/sprite-icons.ts\",\n augmentModule: \"@lattice-php/ui\",\n augmentInterface: \"KnownIcons\",\n };\n\n return {\n ...spriteOptions,\n iconDirs: [path.resolve(root, \"../ui/resources/icons\"), ...dirs],\n ...(dts === false ? {} : { dts: { ...defaultTypes, ...dts } }),\n };\n}\n\nfunction resolveRoots(options: LatticeViteOptions): Roots {\n const appRoot = options.appRoot ?? process.cwd();\n const root = options.root ?? path.resolve(appRoot, \"vendor/lattice-php/lattice\");\n\n return { appRoot, root };\n}\n"],"mappings":";;;;;;AAuCA,SAAgB,QAAQ,UAA8B,CAAC,GAAmB;CACxE,MAAM,EAAE,YAAY,aAAa,OAAO;CACxC,MAAM,UAA0B;EAC9B,WAAW,OAAO;EAClB,oBAAoB;EACpB,wBAAwB,0BAA0B,OAAO,CAAC;EAC1D,iBAAiB,OAAO;CAC1B;CACA,MAAM,cAAc,mBAAmB,OAAO;CAE9C,IAAI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BAAkB;CACpB;CAEA,OAAO;EACL,GAAG;EACH,UAAU,CAAC,KAAK,QAAQ,MAAM,uBAAuB,GAAG,GAAG,IAAI;EAC/D,GAAI,QAAQ,QAAQ,CAAC,IAAI,EAAE,KAAK;GAAE,GAAG;GAAc,GAAG;EAAI,EAAE;CAC9D;AACF;AAEA,SAAS,aAAa,SAAoC;CACxD,MAAM,UAAU,QAAQ,WAAW,QAAQ,IAAI;CAG/C,OAAO;EAAE;EAAS,MAFL,QAAQ,QAAQ,KAAK,QAAQ,SAAS,4BAA4B;CAExD;AACzB"}
1
+ {"version":3,"file":"vite.js","names":[],"sources":["../resources/js/vite.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { svgSprite } from \"@lattice-php/vite-svg-sprite\";\nimport type { IconTypesOptions, SvgSpriteOptions } from \"@lattice-php/vite-svg-sprite\";\nimport { searchForWorkspaceRoot } from \"vite\";\nimport type { Plugin, PluginOption, UserConfig } from \"vite\";\nimport { refreshTypeScriptTypes } from \"./vite-typescript-refresh.ts\";\n\ntype InlineDependency = string | RegExp;\n\ntype ConfigWithTest = UserConfig & {\n test?: {\n server?: {\n deps?: {\n inline?: InlineDependency[];\n };\n };\n };\n};\n\nexport type LatticeViteIconsOptions = Omit<SvgSpriteOptions, \"dts\" | \"iconDirs\"> & {\n dirs?: string[];\n dts?: Partial<IconTypesOptions> | false;\n};\n\nexport type LatticeViteOptions = {\n appRoot?: string;\n icons?: boolean | LatticeViteIconsOptions;\n root?: string;\n source?: boolean;\n /** Refresh generated TypeScript types via the dev server. Defaults to `true`. */\n typescript?: boolean;\n};\n\ntype Roots = {\n appRoot: string;\n root: string;\n};\n\nexport function lattice(options: LatticeViteOptions = {}): PluginOption[] {\n const { appRoot } = resolveRoots(options);\n const plugins: PluginOption[] = [\n corePlugin(options),\n optionalPeersPlugin(),\n componentPackagesPlugin(discoverComponentPackages(appRoot)),\n typescriptPlugin(options),\n ];\n const iconOptions = resolveIconOptions(options);\n\n if (iconOptions) {\n plugins.push(svgSprite(iconOptions));\n }\n\n return plugins;\n}\n\n/** A Composer package that contributes a Lattice component plugin. */\nexport type LatticeComponentPackage = {\n name: string;\n /** Absolute path to the package's installed directory. */\n dir: string;\n /** Absolute path to the package's JS plugin entry. */\n plugin: string;\n};\n\ntype InstalledPackage = {\n name: string;\n \"install-path\"?: string;\n extra?: { lattice?: { plugin?: string } };\n};\n\ntype RootPackageJson = {\n name?: string;\n extra?: { lattice?: { plugin?: string } };\n};\n\n/**\n * Resolve every Composer package that declares `extra.lattice.plugin` into an\n * absolute plugin-entry path. `installPathsRelativeTo` is `vendor/composer` (the\n * dir `installed.json` records its `install-path`s against).\n */\nexport function collectComponentPackages(\n installed: { packages?: InstalledPackage[] } | InstalledPackage[],\n installPathsRelativeTo: string,\n): LatticeComponentPackage[] {\n const packages = Array.isArray(installed) ? installed : (installed.packages ?? []);\n\n return packages.flatMap((pkg) => {\n const entry = pkg.extra?.lattice?.plugin;\n\n if (typeof entry !== \"string\") {\n return [];\n }\n\n const dir = path.resolve(installPathsRelativeTo, pkg[\"install-path\"] ?? `../${pkg.name}`);\n\n return [{ name: pkg.name, dir, plugin: path.resolve(dir, entry) }];\n });\n}\n\n/**\n * Resolve the composer ROOT project's own `extra.lattice.plugin` — Composer\n * never lists the root package in `installed.json`, so a component package\n * declaring the plugin entry in its own composer.json would otherwise be\n * invisible to its own dev server (e.g. inside a testbench workbench, where\n * the package itself is the app root).\n */\nexport function collectRootComponentPackage(\n composerJson: RootPackageJson,\n appRoot: string,\n): LatticeComponentPackage[] {\n const entry = composerJson.extra?.lattice?.plugin;\n\n if (typeof entry !== \"string\" || typeof composerJson.name !== \"string\") {\n return [];\n }\n\n return [{ name: composerJson.name, dir: appRoot, plugin: path.resolve(appRoot, entry) }];\n}\n\n/**\n * Read `<appRoot>/vendor/composer/installed.json` and `<appRoot>/composer.json`\n * and collect every component package they contribute.\n */\nexport function discoverComponentPackages(appRoot: string): LatticeComponentPackage[] {\n const composerDir = path.resolve(appRoot, \"vendor/composer\");\n\n let installed: LatticeComponentPackage[] = [];\n\n try {\n const raw = readFileSync(path.join(composerDir, \"installed.json\"), \"utf8\");\n installed = collectComponentPackages(JSON.parse(raw), composerDir);\n } catch {\n installed = [];\n }\n\n let root: LatticeComponentPackage[] = [];\n\n try {\n const raw = readFileSync(path.join(appRoot, \"composer.json\"), \"utf8\");\n root = collectRootComponentPackage(JSON.parse(raw), appRoot);\n } catch {\n root = [];\n }\n\n return [...installed, ...root];\n}\n\nconst VIRTUAL_PLUGINS_ID = \"virtual:lattice/plugins\";\nconst RESOLVED_VIRTUAL_PLUGINS_ID = `\\0${VIRTUAL_PLUGINS_ID}`;\n\n/**\n * Exposes the discovered component packages as `virtual:lattice/plugins` — a\n * module whose default export is the array of their plugin objects,\n * ready for `extendRegistry(registry, ...plugins)`. Also grants Vite filesystem\n * access to each package dir so its source compiles from `vendor/` (or a symlink).\n */\nexport function componentPackagesPlugin(packages: LatticeComponentPackage[]): Plugin {\n return {\n name: \"lattice:component-packages\",\n config(config) {\n if (packages.length === 0) {\n return {};\n }\n\n const workspaceRoot = searchForWorkspaceRoot(config.root ?? process.cwd());\n\n return { server: { fs: { allow: [workspaceRoot, ...packages.map((pkg) => pkg.dir)] } } };\n },\n resolveId(id) {\n return id === VIRTUAL_PLUGINS_ID ? RESOLVED_VIRTUAL_PLUGINS_ID : null;\n },\n load(id) {\n if (id !== RESOLVED_VIRTUAL_PLUGINS_ID) {\n return null;\n }\n\n const imports = packages\n .map((pkg, index) => `import p${index} from ${JSON.stringify(pkg.plugin)};`)\n .join(\"\\n\");\n const list = packages.map((_, index) => `p${index}`).join(\", \");\n\n return `${imports}\\nexport default [${list}];\\n`;\n },\n };\n}\n\nexport function latticeConfig(options: LatticeViteOptions = {}): ConfigWithTest {\n const { appRoot, root } = resolveRoots(options);\n\n return {\n resolve: {\n // A react alias would break SSR: Vite only externalizes bare specifiers,\n // so an absolute path inlines react's CJS into the SSR module runner.\n // `dedupe` alone keeps the app on a single React copy, symlinks included.\n ...(options.source\n ? {\n alias: {\n \"@lattice-php/lattice/css\": path.resolve(root, \"../ui/resources/css/lattice.css\"),\n \"@lattice-php/lattice\": path.resolve(root, \"resources/js\"),\n \"@lattice-php/action\": path.resolve(root, \"../action/resources/js\"),\n \"@lattice-php/core\": path.resolve(root, \"../core/resources/js\"),\n \"@lattice-php/form\": path.resolve(root, \"../form/resources/js\"),\n \"@lattice-php/table\": path.resolve(root, \"../table/resources/js\"),\n \"@lattice-php/ui/css\": path.resolve(root, \"../ui/resources/css/lattice.css\"),\n \"@lattice-php/ui\": path.resolve(root, \"../ui/resources/js\"),\n },\n }\n : {}),\n dedupe: [\"@inertiajs/react\", \"react\", \"react-dom\"],\n },\n server: options.source\n ? {\n fs: {\n allow: [searchForWorkspaceRoot(appRoot), root],\n },\n }\n : undefined,\n test: {\n server: {\n deps: {\n inline: [\n \"@lattice-php/lattice\",\n \"@lattice-php/action\",\n \"@lattice-php/core\",\n \"@lattice-php/form\",\n \"@lattice-php/table\",\n \"@lattice-php/ui\",\n /[/\\\\]lattice[/\\\\]dist[/\\\\]/,\n /[/\\\\]lattice[/\\\\]node_modules[/\\\\]@radix-ui[/\\\\]/,\n /[/\\\\]lattice[/\\\\]node_modules[/\\\\]@tiptap[/\\\\]/,\n /[/\\\\]lattice[/\\\\]node_modules[/\\\\]react-i18next[/\\\\]/,\n ],\n },\n },\n },\n };\n}\n\nfunction corePlugin(options: LatticeViteOptions): Plugin {\n return {\n name: \"lattice\",\n config() {\n return latticeConfig(options);\n },\n };\n}\n\nconst OPTIONAL_PEER_STUB_PREFIX = \"\\0lattice-optional-peer/\";\n\n/**\n * Real-time listeners statically import their optional Echo peers. A consumer\n * that never uses real-time should still build, so stub a missing peer with\n * hooks that throw — the `RealtimeListeners` error boundary then degrades\n * gracefully and warns to install the peer, exactly as when it is absent.\n */\nconst OPTIONAL_PEER_STUBS: Record<string, string> = {\n \"@laravel/echo-react\": [\n \"const missing = () => {\",\n \" throw new Error(\",\n ' \"[lattice] Real-time listeners require @laravel/echo-react. Install it and call configureEcho().\",',\n \" );\",\n \"};\",\n \"export const useEcho = missing;\",\n \"export const useEchoPublic = missing;\",\n \"export const useEchoPresence = missing;\",\n \"export const useEchoNotification = missing;\",\n ].join(\"\\n\"),\n};\n\nfunction optionalPeersPlugin(): Plugin {\n return {\n name: \"lattice:optional-peers\",\n enforce: \"pre\",\n async resolveId(id) {\n if (!Object.prototype.hasOwnProperty.call(OPTIONAL_PEER_STUBS, id)) {\n return null;\n }\n\n const installed = await this.resolve(id, undefined, { skipSelf: true });\n\n return installed ? null : `${OPTIONAL_PEER_STUB_PREFIX}${id}`;\n },\n load(id) {\n if (!id.startsWith(OPTIONAL_PEER_STUB_PREFIX)) {\n return null;\n }\n\n return OPTIONAL_PEER_STUBS[id.slice(OPTIONAL_PEER_STUB_PREFIX.length)] ?? null;\n },\n };\n}\n\n/**\n * Refreshes `node.props` typings from the app's own `php artisan\n * lattice:typescript` whenever the dev server starts — installing or updating\n * a component package would otherwise leave its generated types stale until\n * someone remembers to run the command by hand. Dev-server only: a production\n * build machine may not have PHP installed, and the generated file is a dev\n * ergonomics artifact, not a build input.\n *\n * Module-private like its siblings `optionalPeersPlugin`/`corePlugin` — the\n * `refreshTypeScriptTypes` DI seam it defers to lives in\n * `./vite-typescript-refresh`, which isn't part of the published `vite`\n * subpath either (see that module for why).\n */\nfunction typescriptPlugin(options: LatticeViteOptions): Plugin {\n return {\n name: \"lattice:typescript\",\n apply: \"serve\",\n configureServer(server) {\n const typescript = options.typescript ?? true;\n\n if (typescript === false) {\n return;\n }\n\n const { appRoot } = resolveRoots(options);\n\n refreshTypeScriptTypes(appRoot, server.config.logger);\n },\n };\n}\n\nexport function resolveIconOptions(options: LatticeViteOptions): SvgSpriteOptions | null {\n const icons = options.icons ?? true;\n\n if (icons === false) {\n return null;\n }\n\n const { root } = resolveRoots(options);\n const iconOptions = icons === true ? {} : icons;\n const { dirs = [], dts, ...spriteOptions } = iconOptions;\n const defaultTypes = {\n file: \"resources/js/types/sprite-icons.ts\",\n augmentModule: \"@lattice-php/ui\",\n augmentInterface: \"KnownIcons\",\n };\n\n return {\n ...spriteOptions,\n iconDirs: [path.resolve(root, \"../ui/resources/icons\"), ...dirs],\n ...(dts === false ? {} : { dts: { ...defaultTypes, ...dts } }),\n };\n}\n\nfunction resolveRoots(options: LatticeViteOptions): Roots {\n const appRoot = options.appRoot ?? process.cwd();\n const root = options.root ?? path.resolve(appRoot, \"vendor/lattice-php/lattice\");\n\n return { appRoot, root };\n}\n"],"mappings":";;;;;;AAuCA,SAAgB,QAAQ,UAA8B,CAAC,GAAmB;CACxE,MAAM,EAAE,YAAY,aAAa,OAAO;CACxC,MAAM,UAA0B;EAC9B,WAAW,OAAO;EAClB,oBAAoB;EACpB,wBAAwB,0BAA0B,OAAO,CAAC;EAC1D,iBAAiB,OAAO;CAC1B;CACA,MAAM,cAAc,mBAAmB,OAAO;CAE9C,IAAI,aACF,QAAQ,KAAK,UAAU,WAAW,CAAC;CAGrC,OAAO;AACT;;;;;;AA2BA,SAAgB,yBACd,WACA,wBAC2B;CAG3B,QAFiB,MAAM,QAAQ,SAAS,IAAI,YAAa,UAAU,YAAY,CAAC,EAAA,CAEhE,SAAS,QAAQ;EAC/B,MAAM,QAAQ,IAAI,OAAO,SAAS;EAElC,IAAI,OAAO,UAAU,UACnB,OAAO,CAAC;EAGV,MAAM,MAAM,KAAK,QAAQ,wBAAwB,IAAI,mBAAmB,MAAM,IAAI,MAAM;EAExF,OAAO,CAAC;GAAE,MAAM,IAAI;GAAM;GAAK,QAAQ,KAAK,QAAQ,KAAK,KAAK;EAAE,CAAC;CACnE,CAAC;AACH;;;;;;;;AASA,SAAgB,4BACd,cACA,SAC2B;CAC3B,MAAM,QAAQ,aAAa,OAAO,SAAS;CAE3C,IAAI,OAAO,UAAU,YAAY,OAAO,aAAa,SAAS,UAC5D,OAAO,CAAC;CAGV,OAAO,CAAC;EAAE,MAAM,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