@nimbalyst/extension-sdk 0.1.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 (57) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +151 -0
  3. package/dist/MaterialSymbol.d.ts +2 -0
  4. package/dist/MaterialSymbol.d.ts.map +1 -0
  5. package/dist/MaterialSymbol.js +1 -0
  6. package/dist/clipboard.d.ts +14 -0
  7. package/dist/clipboard.d.ts.map +1 -0
  8. package/dist/clipboard.js +27 -0
  9. package/dist/createReadOnlyHost.d.ts +45 -0
  10. package/dist/createReadOnlyHost.d.ts.map +1 -0
  11. package/dist/createReadOnlyHost.js +81 -0
  12. package/dist/documentPath.d.ts +6 -0
  13. package/dist/documentPath.d.ts.map +1 -0
  14. package/dist/documentPath.js +4 -0
  15. package/dist/externals.d.ts +23 -0
  16. package/dist/externals.d.ts.map +1 -0
  17. package/dist/externals.js +42 -0
  18. package/dist/externalsPlugin.d.ts +39 -0
  19. package/dist/externalsPlugin.d.ts.map +1 -0
  20. package/dist/externalsPlugin.js +251 -0
  21. package/dist/index.d.ts +33 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +39 -0
  24. package/dist/tailwind.d.ts +112 -0
  25. package/dist/tailwind.d.ts.map +1 -0
  26. package/dist/tailwind.js +129 -0
  27. package/dist/testing.d.ts +122 -0
  28. package/dist/testing.d.ts.map +1 -0
  29. package/dist/testing.js +199 -0
  30. package/dist/types/editor.d.ts +385 -0
  31. package/dist/types/editor.d.ts.map +1 -0
  32. package/dist/types/editor.js +15 -0
  33. package/dist/types/editors.d.ts +56 -0
  34. package/dist/types/editors.d.ts.map +1 -0
  35. package/dist/types/editors.js +19 -0
  36. package/dist/types/extension.d.ts +744 -0
  37. package/dist/types/extension.d.ts.map +1 -0
  38. package/dist/types/extension.js +4 -0
  39. package/dist/types/index.d.ts +9 -0
  40. package/dist/types/index.d.ts.map +1 -0
  41. package/dist/types/index.js +8 -0
  42. package/dist/types/panel.d.ts +575 -0
  43. package/dist/types/panel.d.ts.map +1 -0
  44. package/dist/types/panel.js +14 -0
  45. package/dist/types/theme.d.ts +148 -0
  46. package/dist/types/theme.d.ts.map +1 -0
  47. package/dist/types/theme.js +7 -0
  48. package/dist/useEditorLifecycle.d.ts +166 -0
  49. package/dist/useEditorLifecycle.d.ts.map +1 -0
  50. package/dist/useEditorLifecycle.js +327 -0
  51. package/dist/validate.d.ts +31 -0
  52. package/dist/validate.d.ts.map +1 -0
  53. package/dist/validate.js +128 -0
  54. package/dist/vite.d.ts +92 -0
  55. package/dist/vite.d.ts.map +1 -0
  56. package/dist/vite.js +179 -0
  57. package/package.json +91 -0
@@ -0,0 +1,251 @@
1
+ /**
2
+ * Vite/Rollup plugin that transforms external imports to window.__nimbalyst_extensions references.
3
+ *
4
+ * This plugin runs at BUILD TIME, transforming imports BEFORE minification.
5
+ * This is more robust than runtime regex transformation because:
6
+ * 1. Source code has predictable import syntax
7
+ * 2. Minification happens AFTER transformation
8
+ * 3. Build errors are caught early
9
+ *
10
+ * HOW IT WORKS:
11
+ * Instead of marking modules as "external" (which keeps bare import statements that
12
+ * blob URLs can't resolve), we resolve imports to virtual modules that access
13
+ * window.__nimbalyst_extensions at runtime.
14
+ *
15
+ * Example:
16
+ * import React, { useState } from 'react'
17
+ * ->
18
+ * // Generated virtual module gets bundled inline:
19
+ * const __mod = window.__nimbalyst_extensions["react"];
20
+ * export default __mod;
21
+ * export const useState = __mod.useState;
22
+ * // etc.
23
+ *
24
+ * The extension's code then imports from this virtual module, which after bundling
25
+ * becomes direct property accesses on window.__nimbalyst_extensions.
26
+ */
27
+ /**
28
+ * Map of external module names to their window.__nimbalyst_extensions keys.
29
+ */
30
+ const EXTERNALS_MAP = {
31
+ // React
32
+ react: 'react',
33
+ 'react-dom': 'react-dom',
34
+ 'react-dom/client': 'react-dom/client',
35
+ 'react/jsx-runtime': 'react/jsx-runtime',
36
+ 'react/jsx-dev-runtime': 'react/jsx-dev-runtime',
37
+ // Lexical
38
+ lexical: 'lexical',
39
+ '@lexical/react/LexicalComposerContext': '@lexical/react/LexicalComposerContext',
40
+ '@lexical/react/useLexicalEditable': '@lexical/react/useLexicalEditable',
41
+ '@lexical/react/useLexicalNodeSelection': '@lexical/react/useLexicalNodeSelection',
42
+ '@lexical/utils': '@lexical/utils',
43
+ '@lexical/markdown': '@lexical/markdown',
44
+ // Nimbalyst runtime
45
+ '@nimbalyst/editor-context': '@nimbalyst/editor-context',
46
+ '@nimbalyst/runtime/ui/icons/MaterialSymbol': '@nimbalyst/runtime/ui/icons/MaterialSymbol',
47
+ '@nimbalyst/screenshot-service': '@nimbalyst/screenshot-service',
48
+ '@nimbalyst/datamodel-platform-service': '@nimbalyst/datamodel-platform-service',
49
+ // Shared libraries
50
+ 'pdfjs-dist': 'pdfjs-dist',
51
+ virtua: 'virtua',
52
+ };
53
+ /**
54
+ * Check if a module ID matches any external pattern.
55
+ * Returns the key to use in window.__nimbalyst_extensions or null if not external.
56
+ */
57
+ function getExternalKey(id) {
58
+ // Direct match
59
+ if (EXTERNALS_MAP[id]) {
60
+ return EXTERNALS_MAP[id];
61
+ }
62
+ // Pattern match for @lexical/* and @nimbalyst/runtime/*
63
+ if (id.startsWith('@lexical/')) {
64
+ return id;
65
+ }
66
+ if (id.startsWith('@nimbalyst/runtime')) {
67
+ return id;
68
+ }
69
+ return null;
70
+ }
71
+ /**
72
+ * Creates a Vite plugin that transforms external imports at build time.
73
+ *
74
+ * This approach uses renderChunk to transform the final output after bundling
75
+ * but captures the original import information during the transform phase.
76
+ *
77
+ * The key insight: we DON'T mark these as external. Instead, we let Rollup
78
+ * try to resolve them, fail, and then our resolveId catches them and returns
79
+ * a virtual module. The virtual module's code accesses window.__nimbalyst_extensions.
80
+ */
81
+ export function nimbalystExternalsPlugin() {
82
+ const virtualModulePrefix = '\0nimbalyst-external:';
83
+ return {
84
+ name: 'nimbalyst-externals',
85
+ enforce: 'pre',
86
+ resolveId(source, _importer, _options) {
87
+ const externalKey = getExternalKey(source);
88
+ if (externalKey) {
89
+ return virtualModulePrefix + externalKey;
90
+ }
91
+ return null;
92
+ },
93
+ load(id) {
94
+ if (!id.startsWith(virtualModulePrefix)) {
95
+ return null;
96
+ }
97
+ const externalKey = id.slice(virtualModulePrefix.length);
98
+ // Generate a simple module that re-exports from window.__nimbalyst_extensions.
99
+ // We use a Proxy to handle ANY property access, making this future-proof.
100
+ // The Proxy ensures that any named import will work without us having to
101
+ // enumerate all possible exports.
102
+ return `
103
+ // Virtual module for: ${externalKey}
104
+ // This gets the module from the host at runtime
105
+ const __nimbalyst_mod__ = window.__nimbalyst_extensions?.["${externalKey}"];
106
+
107
+ if (!__nimbalyst_mod__) {
108
+ console.error('[Extension] Missing host dependency: ${externalKey}');
109
+ }
110
+
111
+ // Default export for: import X from '${externalKey}'
112
+ export default __nimbalyst_mod__;
113
+
114
+ // Create a proxy that allows any named export
115
+ // This handles: import { anything } from '${externalKey}'
116
+ const __proxy__ = new Proxy(__nimbalyst_mod__ || {}, {
117
+ get(target, prop) {
118
+ if (prop in target) {
119
+ return target[prop];
120
+ }
121
+ // For properties that don't exist, return undefined
122
+ // This prevents errors for optional exports
123
+ return undefined;
124
+ }
125
+ });
126
+
127
+ // Re-export common properties explicitly for tree-shaking
128
+ // These are the most commonly used exports from each package type
129
+ ${generateCommonExports(externalKey)}
130
+ `;
131
+ },
132
+ };
133
+ }
134
+ /**
135
+ * Generate explicit named exports for common properties.
136
+ * This helps with tree-shaking while the Proxy handles edge cases.
137
+ */
138
+ function generateCommonExports(externalKey) {
139
+ // Determine which exports to generate based on the module
140
+ let exports = [];
141
+ if (externalKey === 'react') {
142
+ exports = [
143
+ 'useState', 'useEffect', 'useCallback', 'useMemo', 'useRef', 'useContext',
144
+ 'useReducer', 'useLayoutEffect', 'useImperativeHandle', 'useDebugValue',
145
+ 'useDeferredValue', 'useTransition', 'useId', 'useSyncExternalStore',
146
+ 'createElement', 'createContext', 'createRef', 'forwardRef', 'lazy', 'memo',
147
+ 'startTransition', 'Children', 'Component', 'Fragment', 'Profiler',
148
+ 'PureComponent', 'StrictMode', 'Suspense', 'cloneElement', 'isValidElement',
149
+ 'version', 'useInsertionEffect', 'cache', 'use', 'act',
150
+ ];
151
+ }
152
+ else if (externalKey === 'react-dom' || externalKey === 'react-dom/client') {
153
+ exports = [
154
+ 'createRoot', 'hydrateRoot', 'render', 'hydrate', 'createPortal', 'flushSync',
155
+ 'unmountComponentAtNode', 'findDOMNode', 'unstable_batchedUpdates',
156
+ ];
157
+ }
158
+ else if (externalKey === 'react/jsx-runtime' || externalKey === 'react/jsx-dev-runtime') {
159
+ exports = ['jsx', 'jsxs', 'jsxDEV', 'Fragment'];
160
+ }
161
+ else if (externalKey === 'lexical') {
162
+ exports = [
163
+ // Selection and state
164
+ '$getRoot', '$getSelection', '$setSelection', '$insertNodes', '$getNodeByKey',
165
+ '$createParagraphNode', '$createTextNode', '$createRangeSelection',
166
+ '$getNearestNodeFromDOMNode', '$nodesOfType',
167
+ // Type guards
168
+ '$isRangeSelection', '$isNodeSelection', '$isTextNode', '$isParagraphNode',
169
+ '$isElementNode', '$isRootNode', '$isDecoratorNode', '$isLineBreakNode',
170
+ '$isRootOrShadowRoot',
171
+ // Node operations
172
+ '$splitNode', '$copyNode', '$generateHtmlFromNodes', '$generateNodesFromDOM',
173
+ '$applyNodeReplacement',
174
+ // Command priorities
175
+ 'COMMAND_PRIORITY_LOW', 'COMMAND_PRIORITY_NORMAL', 'COMMAND_PRIORITY_HIGH',
176
+ 'COMMAND_PRIORITY_EDITOR', 'COMMAND_PRIORITY_CRITICAL',
177
+ // Commands
178
+ 'createCommand', 'SELECTION_CHANGE_COMMAND', 'KEY_ENTER_COMMAND',
179
+ 'KEY_BACKSPACE_COMMAND', 'KEY_DELETE_COMMAND', 'KEY_TAB_COMMAND',
180
+ 'KEY_ESCAPE_COMMAND', 'INSERT_PARAGRAPH_COMMAND', 'INSERT_LINE_BREAK_COMMAND',
181
+ 'PASTE_COMMAND', 'COPY_COMMAND', 'CUT_COMMAND', 'CLICK_COMMAND',
182
+ 'FORMAT_TEXT_COMMAND', 'FORMAT_ELEMENT_COMMAND', 'UNDO_COMMAND', 'REDO_COMMAND',
183
+ // Editor and nodes
184
+ 'createEditor', 'LineBreakNode', 'ParagraphNode', 'TextNode',
185
+ 'ElementNode', 'DecoratorNode', 'LexicalNode', 'RootNode',
186
+ // Serialization
187
+ 'SerializedLexicalNode', 'SerializedEditor', 'EditorState',
188
+ 'DOMConversionMap', 'DOMConversionOutput', 'DOMExportOutput',
189
+ 'LexicalEditor', 'EditorConfig', 'NodeKey', 'Spread',
190
+ ];
191
+ }
192
+ else if (externalKey === '@lexical/react/LexicalComposerContext') {
193
+ exports = ['useLexicalComposerContext', 'LexicalComposerContext', 'createLexicalComposerContext'];
194
+ }
195
+ else if (externalKey === '@lexical/react/useLexicalEditable') {
196
+ exports = ['useLexicalEditable', 'default'];
197
+ }
198
+ else if (externalKey === '@lexical/react/useLexicalNodeSelection') {
199
+ exports = ['useLexicalNodeSelection', 'default'];
200
+ }
201
+ else if (externalKey === '@lexical/utils') {
202
+ exports = [
203
+ 'mergeRegister', '$findMatchingParent', '$getNearestNodeOfType',
204
+ '$getNearestBlockElementAncestorOrThrow', '$insertNodeToNearestRoot',
205
+ 'addClassNamesToElement', 'removeClassNamesFromElement',
206
+ 'isMimeType', 'mediaFileReader', '$restoreEditorState',
207
+ 'positionNodeOnRange', '$wrapNodeInElement', 'calculateZoomLevel',
208
+ ];
209
+ }
210
+ else if (externalKey === '@lexical/markdown') {
211
+ exports = [
212
+ '$convertFromMarkdownString', '$convertToMarkdownString',
213
+ 'TRANSFORMERS', 'registerMarkdownShortcuts',
214
+ 'ELEMENT_TRANSFORMERS', 'TEXT_FORMAT_TRANSFORMERS', 'TEXT_MATCH_TRANSFORMERS',
215
+ 'HEADING', 'QUOTE', 'CODE', 'UNORDERED_LIST', 'ORDERED_LIST',
216
+ 'CHECK_LIST', 'LINK', 'INLINE_CODE', 'BOLD_ITALIC_STAR', 'BOLD_ITALIC_UNDERSCORE',
217
+ 'BOLD_STAR', 'BOLD_UNDERSCORE', 'ITALIC_STAR', 'ITALIC_UNDERSCORE',
218
+ 'STRIKETHROUGH', 'HIGHLIGHT',
219
+ ];
220
+ }
221
+ else if (externalKey === '@nimbalyst/editor-context') {
222
+ exports = ['useDocumentPath'];
223
+ }
224
+ else if (externalKey === '@nimbalyst/runtime/ui/icons/MaterialSymbol') {
225
+ exports = ['MaterialSymbol'];
226
+ }
227
+ else if (externalKey === '@nimbalyst/screenshot-service') {
228
+ exports = ['screenshotService'];
229
+ }
230
+ else if (externalKey === '@nimbalyst/datamodel-platform-service') {
231
+ exports = ['DataModelPlatformServiceImpl', 'getInstance'];
232
+ }
233
+ else if (externalKey === 'pdfjs-dist') {
234
+ exports = ['getDocument', 'GlobalWorkerOptions', 'version'];
235
+ }
236
+ else if (externalKey === 'virtua') {
237
+ exports = ['VList', 'Virtualizer', 'WindowVirtualizer'];
238
+ }
239
+ if (exports.length === 0) {
240
+ return '// No common exports defined for this module';
241
+ }
242
+ // Generate export statements
243
+ const lines = exports.map(name => {
244
+ // Handle 'default' specially
245
+ if (name === 'default') {
246
+ return `// default export handled above`;
247
+ }
248
+ return `export const ${name} = __nimbalyst_mod__?.${name};`;
249
+ });
250
+ return lines.join('\n');
251
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Nimbalyst Extension SDK
3
+ *
4
+ * This package provides utilities for building Nimbalyst extensions:
5
+ * - Vite configuration helpers
6
+ * - TypeScript types
7
+ * - Build validation
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * // vite.config.ts
12
+ * import react from '@vitejs/plugin-react';
13
+ * import { createExtensionConfig } from '@nimbalyst/extension-sdk/vite';
14
+ *
15
+ * export default createExtensionConfig({
16
+ * entry: './src/index.tsx',
17
+ * plugins: [
18
+ * react({ jsxRuntime: 'automatic', jsxImportSource: 'react' }),
19
+ * ],
20
+ * });
21
+ * ```
22
+ *
23
+ * @packageDocumentation
24
+ */
25
+ export { REQUIRED_EXTERNALS, EXTERNAL_PATTERNS, ROLLUP_EXTERNALS, type RequiredExternal, } from './externals.js';
26
+ export * from './types/index.js';
27
+ export { useEditorLifecycle, type UseEditorLifecycleOptions, type UseEditorLifecycleResult, type DiffState, } from './useEditorLifecycle.js';
28
+ export { useDocumentPath, type DocumentPathContextValue, } from './documentPath.js';
29
+ export { MaterialSymbol } from './MaterialSymbol.js';
30
+ export { createReadOnlyHost, type ReadOnlyHost, type ReadOnlyHostOptions, } from './createReadOnlyHost.js';
31
+ export { copyToClipboard, readClipboard } from './clipboard.js';
32
+ export { validateExtensionBundle, printValidationResult, type ValidationResult, } from './validate.js';
33
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,gBAAgB,GACtB,MAAM,gBAAgB,CAAC;AAGxB,cAAc,kBAAkB,CAAC;AAGjC,OAAO,EACL,kBAAkB,EAClB,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,SAAS,GACf,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACL,eAAe,EACf,KAAK,wBAAwB,GAC9B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EACL,kBAAkB,EAClB,KAAK,YAAY,EACjB,KAAK,mBAAmB,GACzB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGhE,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,KAAK,gBAAgB,GACtB,MAAM,eAAe,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Nimbalyst Extension SDK
3
+ *
4
+ * This package provides utilities for building Nimbalyst extensions:
5
+ * - Vite configuration helpers
6
+ * - TypeScript types
7
+ * - Build validation
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * // vite.config.ts
12
+ * import react from '@vitejs/plugin-react';
13
+ * import { createExtensionConfig } from '@nimbalyst/extension-sdk/vite';
14
+ *
15
+ * export default createExtensionConfig({
16
+ * entry: './src/index.tsx',
17
+ * plugins: [
18
+ * react({ jsxRuntime: 'automatic', jsxImportSource: 'react' }),
19
+ * ],
20
+ * });
21
+ * ```
22
+ *
23
+ * @packageDocumentation
24
+ */
25
+ // Re-export externals
26
+ export { REQUIRED_EXTERNALS, EXTERNAL_PATTERNS, ROLLUP_EXTERNALS, } from './externals.js';
27
+ // Re-export types
28
+ export * from './types/index.js';
29
+ // Re-export hooks
30
+ export { useEditorLifecycle, } from './useEditorLifecycle.js';
31
+ // Re-export host-provided editor context and UI helpers for extensions.
32
+ export { useDocumentPath, } from './documentPath.js';
33
+ export { MaterialSymbol } from './MaterialSymbol.js';
34
+ // Re-export read-only host factory (for web viewers and testing)
35
+ export { createReadOnlyHost, } from './createReadOnlyHost.js';
36
+ // Re-export clipboard utilities
37
+ export { copyToClipboard, readClipboard } from './clipboard.js';
38
+ // Re-export validation
39
+ export { validateExtensionBundle, printValidationResult, } from './validate.js';
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Nimbalyst Tailwind CSS Preset for Extensions
3
+ *
4
+ * This preset provides the Nimbalyst theme colors and utilities for use in extensions.
5
+ * Extensions that use Tailwind CSS should extend this preset to ensure consistent
6
+ * theming with the host application.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * // tailwind.config.ts
11
+ * import { nimbalystPreset } from '@nimbalyst/extension-sdk/tailwind';
12
+ *
13
+ * export default {
14
+ * presets: [nimbalystPreset],
15
+ * content: ['./src/**\/*.{ts,tsx}'],
16
+ * };
17
+ * ```
18
+ */
19
+ import type { Config } from 'tailwindcss';
20
+ /**
21
+ * Nimbalyst theme color configuration for Tailwind CSS.
22
+ * These map to the --nim-* CSS variables defined by the host application.
23
+ */
24
+ export declare const nimbalystColors: {
25
+ nim: {
26
+ DEFAULT: string;
27
+ secondary: string;
28
+ tertiary: string;
29
+ hover: string;
30
+ selected: string;
31
+ active: string;
32
+ };
33
+ 'nim-text': {
34
+ DEFAULT: string;
35
+ muted: string;
36
+ faint: string;
37
+ disabled: string;
38
+ };
39
+ 'nim-border': {
40
+ DEFAULT: string;
41
+ focus: string;
42
+ };
43
+ 'nim-primary': {
44
+ DEFAULT: string;
45
+ hover: string;
46
+ };
47
+ 'nim-link': {
48
+ DEFAULT: string;
49
+ hover: string;
50
+ };
51
+ 'nim-success': string;
52
+ 'nim-warning': string;
53
+ 'nim-error': string;
54
+ 'nim-info': string;
55
+ };
56
+ /**
57
+ * Shorthand background color utilities for common patterns.
58
+ */
59
+ export declare const nimbalystBackgroundColors: {
60
+ nim: string;
61
+ 'nim-secondary': string;
62
+ 'nim-tertiary': string;
63
+ 'nim-hover': string;
64
+ 'nim-selected': string;
65
+ 'nim-active': string;
66
+ 'nim-primary': string;
67
+ 'nim-primary-hover': string;
68
+ };
69
+ /**
70
+ * Shorthand text color utilities for common patterns.
71
+ */
72
+ export declare const nimbalystTextColors: {
73
+ nim: string;
74
+ 'nim-muted': string;
75
+ 'nim-faint': string;
76
+ 'nim-disabled': string;
77
+ 'nim-link': string;
78
+ 'nim-link-hover': string;
79
+ 'nim-primary': string;
80
+ 'nim-success': string;
81
+ 'nim-warning': string;
82
+ 'nim-error': string;
83
+ 'nim-info': string;
84
+ };
85
+ /**
86
+ * Shorthand border color utilities.
87
+ */
88
+ export declare const nimbalystBorderColors: {
89
+ nim: string;
90
+ 'nim-focus': string;
91
+ 'nim-primary': string;
92
+ };
93
+ /**
94
+ * Nimbalyst Tailwind CSS preset.
95
+ *
96
+ * Use this preset in your extension's tailwind.config.ts to get access
97
+ * to the Nimbalyst theme colors and utilities.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * // tailwind.config.ts
102
+ * import { nimbalystPreset } from '@nimbalyst/extension-sdk/tailwind';
103
+ *
104
+ * export default {
105
+ * presets: [nimbalystPreset],
106
+ * content: ['./src/**\/*.{ts,tsx}'],
107
+ * };
108
+ * ```
109
+ */
110
+ export declare const nimbalystPreset: Config;
111
+ export default nimbalystPreset;
112
+ //# sourceMappingURL=tailwind.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailwind.d.ts","sourceRoot":"","sources":["../src/tailwind.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsC3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;CASrC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;CAY/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;CAIjC,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,eAAe,EAAE,MAY7B,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,129 @@
1
+ /**
2
+ * Nimbalyst Tailwind CSS Preset for Extensions
3
+ *
4
+ * This preset provides the Nimbalyst theme colors and utilities for use in extensions.
5
+ * Extensions that use Tailwind CSS should extend this preset to ensure consistent
6
+ * theming with the host application.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * // tailwind.config.ts
11
+ * import { nimbalystPreset } from '@nimbalyst/extension-sdk/tailwind';
12
+ *
13
+ * export default {
14
+ * presets: [nimbalystPreset],
15
+ * content: ['./src/**\/*.{ts,tsx}'],
16
+ * };
17
+ * ```
18
+ */
19
+ /**
20
+ * Nimbalyst theme color configuration for Tailwind CSS.
21
+ * These map to the --nim-* CSS variables defined by the host application.
22
+ */
23
+ export const nimbalystColors = {
24
+ // Nimbalyst theme colors - conventional naming that matches CSS/Tailwind mental models
25
+ nim: {
26
+ // Backgrounds (use: bg-nim, bg-nim-secondary, etc.)
27
+ DEFAULT: 'var(--nim-bg)',
28
+ secondary: 'var(--nim-bg-secondary)',
29
+ tertiary: 'var(--nim-bg-tertiary)',
30
+ hover: 'var(--nim-bg-hover)',
31
+ selected: 'var(--nim-bg-selected)',
32
+ active: 'var(--nim-bg-active)',
33
+ },
34
+ 'nim-text': {
35
+ // Text (use: text-nim-text, text-nim-text-muted, etc.)
36
+ DEFAULT: 'var(--nim-text)',
37
+ muted: 'var(--nim-text-muted)',
38
+ faint: 'var(--nim-text-faint)',
39
+ disabled: 'var(--nim-text-disabled)',
40
+ },
41
+ 'nim-border': {
42
+ // Borders (use: border-nim-border, border-nim-border-focus)
43
+ DEFAULT: 'var(--nim-border)',
44
+ focus: 'var(--nim-border-focus)',
45
+ },
46
+ 'nim-primary': {
47
+ // Primary action color (use: bg-nim-primary, text-nim-primary)
48
+ DEFAULT: 'var(--nim-primary)',
49
+ hover: 'var(--nim-primary-hover)',
50
+ },
51
+ 'nim-link': {
52
+ // Links (use: text-nim-link)
53
+ DEFAULT: 'var(--nim-link)',
54
+ hover: 'var(--nim-link-hover)',
55
+ },
56
+ // Status colors
57
+ 'nim-success': 'var(--nim-success)',
58
+ 'nim-warning': 'var(--nim-warning)',
59
+ 'nim-error': 'var(--nim-error)',
60
+ 'nim-info': 'var(--nim-info)',
61
+ };
62
+ /**
63
+ * Shorthand background color utilities for common patterns.
64
+ */
65
+ export const nimbalystBackgroundColors = {
66
+ nim: 'var(--nim-bg)',
67
+ 'nim-secondary': 'var(--nim-bg-secondary)',
68
+ 'nim-tertiary': 'var(--nim-bg-tertiary)',
69
+ 'nim-hover': 'var(--nim-bg-hover)',
70
+ 'nim-selected': 'var(--nim-bg-selected)',
71
+ 'nim-active': 'var(--nim-bg-active)',
72
+ 'nim-primary': 'var(--nim-primary)',
73
+ 'nim-primary-hover': 'var(--nim-primary-hover)',
74
+ };
75
+ /**
76
+ * Shorthand text color utilities for common patterns.
77
+ */
78
+ export const nimbalystTextColors = {
79
+ nim: 'var(--nim-text)',
80
+ 'nim-muted': 'var(--nim-text-muted)',
81
+ 'nim-faint': 'var(--nim-text-faint)',
82
+ 'nim-disabled': 'var(--nim-text-disabled)',
83
+ 'nim-link': 'var(--nim-link)',
84
+ 'nim-link-hover': 'var(--nim-link-hover)',
85
+ 'nim-primary': 'var(--nim-primary)',
86
+ 'nim-success': 'var(--nim-success)',
87
+ 'nim-warning': 'var(--nim-warning)',
88
+ 'nim-error': 'var(--nim-error)',
89
+ 'nim-info': 'var(--nim-info)',
90
+ };
91
+ /**
92
+ * Shorthand border color utilities.
93
+ */
94
+ export const nimbalystBorderColors = {
95
+ nim: 'var(--nim-border)',
96
+ 'nim-focus': 'var(--nim-border-focus)',
97
+ 'nim-primary': 'var(--nim-primary)',
98
+ };
99
+ /**
100
+ * Nimbalyst Tailwind CSS preset.
101
+ *
102
+ * Use this preset in your extension's tailwind.config.ts to get access
103
+ * to the Nimbalyst theme colors and utilities.
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * // tailwind.config.ts
108
+ * import { nimbalystPreset } from '@nimbalyst/extension-sdk/tailwind';
109
+ *
110
+ * export default {
111
+ * presets: [nimbalystPreset],
112
+ * content: ['./src/**\/*.{ts,tsx}'],
113
+ * };
114
+ * ```
115
+ */
116
+ export const nimbalystPreset = {
117
+ content: [],
118
+ darkMode: ['class', '[data-theme="dark"], [data-theme="crystal-dark"]'],
119
+ theme: {
120
+ extend: {
121
+ colors: nimbalystColors,
122
+ backgroundColor: nimbalystBackgroundColors,
123
+ textColor: nimbalystTextColors,
124
+ borderColor: nimbalystBorderColors,
125
+ },
126
+ },
127
+ plugins: [],
128
+ };
129
+ export default nimbalystPreset;