mitway-tagger 1.3.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.
- package/README.md +256 -0
- package/dist/index.cjs +909 -0
- package/dist/index.d.cts +204 -0
- package/dist/index.d.ts +204 -0
- package/dist/index.js +865 -0
- package/package.json +47 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* JSX Source Tracking Plugin
|
|
5
|
+
*
|
|
6
|
+
* Intercepts react/jsx-dev-runtime to inject source location metadata
|
|
7
|
+
* into React components. This allows mapping rendered DOM elements
|
|
8
|
+
* back to their source code locations.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
interface JsxSourceOptions {
|
|
12
|
+
extensions: string[];
|
|
13
|
+
exclude: string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates the JSX source tracking plugin
|
|
17
|
+
*/
|
|
18
|
+
declare function createJsxSourcePlugin(options: JsxSourceOptions): Plugin;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Virtual Overrides Plugin
|
|
22
|
+
*
|
|
23
|
+
* Allows temporary file modifications without writing to disk.
|
|
24
|
+
* Uses Vite's HMR system to update modules in real-time.
|
|
25
|
+
*
|
|
26
|
+
* Communication is done via WebSocket events:
|
|
27
|
+
* - mitway:override - Set a virtual override for a file
|
|
28
|
+
* - mitway:clear-override - Clear a specific override
|
|
29
|
+
* - mitway:clear-all-overrides - Clear all overrides
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Creates the virtual overrides plugin
|
|
34
|
+
*/
|
|
35
|
+
declare function createVirtualOverridesPlugin(): Plugin;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Visual Editor Plugin
|
|
39
|
+
*
|
|
40
|
+
* Injects a script into the HTML that enables:
|
|
41
|
+
* - Element selection with visual overlays
|
|
42
|
+
* - Style preview in real-time
|
|
43
|
+
* - Communication with parent window via postMessage
|
|
44
|
+
* - Reading source info from jsxSource plugin
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Creates the visual editor plugin
|
|
49
|
+
*/
|
|
50
|
+
declare function createVisualEditorPlugin(): Plugin;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Iframe Navigation Plugin
|
|
54
|
+
*
|
|
55
|
+
* Notifies the parent window (mITway-App) when navigation occurs in the iframe.
|
|
56
|
+
* Also listens for navigation commands from the parent.
|
|
57
|
+
*
|
|
58
|
+
* Features:
|
|
59
|
+
* - Intercepts history.pushState and history.replaceState
|
|
60
|
+
* - Listens for popstate events
|
|
61
|
+
* - Sends IFRAME_NAVIGATION messages to parent
|
|
62
|
+
* - Receives NAVIGATE_TO commands from parent
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Creates the iframe navigation plugin
|
|
67
|
+
*/
|
|
68
|
+
declare function createIframeNavigationPlugin(): Plugin;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Theme Bridge Plugin
|
|
72
|
+
*
|
|
73
|
+
* Enables real-time theme preview from mITway-App via postMessage.
|
|
74
|
+
* Allows the parent window to preview, apply, and restore themes.
|
|
75
|
+
*
|
|
76
|
+
* Features:
|
|
77
|
+
* - Captures original CSS variable values
|
|
78
|
+
* - Applies theme colors with proper HSL wrapping
|
|
79
|
+
* - Supports both base (--background) and color- prefixed (--color-background) variables
|
|
80
|
+
* - Handles radius variables separately (no HSL wrapper)
|
|
81
|
+
* - Notifies parent when theme bridge is ready
|
|
82
|
+
*
|
|
83
|
+
* Message types:
|
|
84
|
+
* - PREVIEW_THEME: Preview theme without persisting
|
|
85
|
+
* - RESTORE_THEME: Restore original CSS variables
|
|
86
|
+
* - APPLY_THEME: Apply and persist theme
|
|
87
|
+
* - THEME_BRIDGE_READY: Sent when bridge initializes
|
|
88
|
+
* - THEME_APPLIED: Sent after theme is applied
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Creates the theme bridge plugin
|
|
93
|
+
*/
|
|
94
|
+
declare function createThemeBridgePlugin(): Plugin;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* mITway Tagger - Vite plugin suite for mITway integration
|
|
98
|
+
*
|
|
99
|
+
* This plugin provides five main features:
|
|
100
|
+
* 1. JSX Source Tracking - Injects source location metadata into React components
|
|
101
|
+
* 2. Virtual Overrides - Allows temporary file modifications with HMR support
|
|
102
|
+
* 3. Visual Editor - Enables element selection and live style preview via postMessage
|
|
103
|
+
* 4. Iframe Navigation - Notifies parent window of navigation changes
|
|
104
|
+
* 5. Theme Bridge - Enables real-time theme preview from mITway-App
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
interface mITwayTaggerOptions {
|
|
108
|
+
/**
|
|
109
|
+
* Enable JSX source tracking
|
|
110
|
+
* @default true
|
|
111
|
+
*/
|
|
112
|
+
jsxSource?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Enable virtual file overrides with HMR
|
|
115
|
+
* @default true
|
|
116
|
+
*/
|
|
117
|
+
virtualOverrides?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Enable visual editor for element selection and style preview
|
|
120
|
+
* @default true
|
|
121
|
+
*/
|
|
122
|
+
visualEditor?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Enable iframe navigation notifications to parent window
|
|
125
|
+
* @default true
|
|
126
|
+
*/
|
|
127
|
+
iframeNavigation?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Enable theme bridge for real-time theme preview
|
|
130
|
+
* @default true
|
|
131
|
+
*/
|
|
132
|
+
themeBridge?: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* File extensions to process for JSX source tracking
|
|
135
|
+
* @default ['.jsx', '.tsx']
|
|
136
|
+
*/
|
|
137
|
+
extensions?: string[];
|
|
138
|
+
/**
|
|
139
|
+
* Directories to exclude from processing
|
|
140
|
+
* @default ['node_modules', '.git']
|
|
141
|
+
*/
|
|
142
|
+
exclude?: string[];
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Creates the mITway Tagger Vite plugin suite
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* // Enable all features (default)
|
|
149
|
+
* mitwayTagger()
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* // Disable specific features
|
|
153
|
+
* mitwayTagger({ jsxSource: false, virtualOverrides: false })
|
|
154
|
+
*/
|
|
155
|
+
declare function mitwayTagger(options?: mITwayTaggerOptions): Plugin[];
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Server configuration interface for mITway iframe integration
|
|
159
|
+
*/
|
|
160
|
+
interface mITwayServerConfig {
|
|
161
|
+
host: string;
|
|
162
|
+
port: number;
|
|
163
|
+
cors: {
|
|
164
|
+
origin: (string | RegExp)[];
|
|
165
|
+
methods: string[];
|
|
166
|
+
allowedHeaders: string[];
|
|
167
|
+
credentials: boolean;
|
|
168
|
+
};
|
|
169
|
+
headers: Record<string, string>;
|
|
170
|
+
allowedHosts: string[];
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Pre-configured server settings for mITway iframe integration.
|
|
174
|
+
* Includes host, port, CORS, CSP headers, and allowed hosts.
|
|
175
|
+
* Use directly with Vite's server and preview options.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* // vite.config.ts
|
|
179
|
+
* import { mitwayTagger, mitwayServerConfig } from 'mitway-tagger';
|
|
180
|
+
*
|
|
181
|
+
* export default defineConfig({
|
|
182
|
+
* plugins: [react(), ...mitwayTagger()],
|
|
183
|
+
* server: mitwayServerConfig,
|
|
184
|
+
* preview: mitwayServerConfig,
|
|
185
|
+
* });
|
|
186
|
+
*/
|
|
187
|
+
declare const mitwayServerConfig: mITwayServerConfig;
|
|
188
|
+
/**
|
|
189
|
+
* Creates a customized server config by merging with additional origins.
|
|
190
|
+
* Useful when you need to add custom domains to the CORS and CSP settings.
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* const config = createmITwayServerConfig({
|
|
194
|
+
* additionalOrigins: ['https://my-custom-domain.com'],
|
|
195
|
+
* additionalHosts: ['.my-custom-domain.com'],
|
|
196
|
+
* });
|
|
197
|
+
*/
|
|
198
|
+
declare function createmITwayServerConfig(options?: {
|
|
199
|
+
additionalOrigins?: (string | RegExp)[];
|
|
200
|
+
additionalHosts?: string[];
|
|
201
|
+
port?: number;
|
|
202
|
+
}): mITwayServerConfig;
|
|
203
|
+
|
|
204
|
+
export { createIframeNavigationPlugin, createJsxSourcePlugin, createThemeBridgePlugin, createVirtualOverridesPlugin, createVisualEditorPlugin, createmITwayServerConfig, mitwayTagger as default, type mITwayServerConfig, type mITwayTaggerOptions, mitwayServerConfig, mitwayTagger };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* JSX Source Tracking Plugin
|
|
5
|
+
*
|
|
6
|
+
* Intercepts react/jsx-dev-runtime to inject source location metadata
|
|
7
|
+
* into React components. This allows mapping rendered DOM elements
|
|
8
|
+
* back to their source code locations.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
interface JsxSourceOptions {
|
|
12
|
+
extensions: string[];
|
|
13
|
+
exclude: string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates the JSX source tracking plugin
|
|
17
|
+
*/
|
|
18
|
+
declare function createJsxSourcePlugin(options: JsxSourceOptions): Plugin;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Virtual Overrides Plugin
|
|
22
|
+
*
|
|
23
|
+
* Allows temporary file modifications without writing to disk.
|
|
24
|
+
* Uses Vite's HMR system to update modules in real-time.
|
|
25
|
+
*
|
|
26
|
+
* Communication is done via WebSocket events:
|
|
27
|
+
* - mitway:override - Set a virtual override for a file
|
|
28
|
+
* - mitway:clear-override - Clear a specific override
|
|
29
|
+
* - mitway:clear-all-overrides - Clear all overrides
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Creates the virtual overrides plugin
|
|
34
|
+
*/
|
|
35
|
+
declare function createVirtualOverridesPlugin(): Plugin;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Visual Editor Plugin
|
|
39
|
+
*
|
|
40
|
+
* Injects a script into the HTML that enables:
|
|
41
|
+
* - Element selection with visual overlays
|
|
42
|
+
* - Style preview in real-time
|
|
43
|
+
* - Communication with parent window via postMessage
|
|
44
|
+
* - Reading source info from jsxSource plugin
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Creates the visual editor plugin
|
|
49
|
+
*/
|
|
50
|
+
declare function createVisualEditorPlugin(): Plugin;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Iframe Navigation Plugin
|
|
54
|
+
*
|
|
55
|
+
* Notifies the parent window (mITway-App) when navigation occurs in the iframe.
|
|
56
|
+
* Also listens for navigation commands from the parent.
|
|
57
|
+
*
|
|
58
|
+
* Features:
|
|
59
|
+
* - Intercepts history.pushState and history.replaceState
|
|
60
|
+
* - Listens for popstate events
|
|
61
|
+
* - Sends IFRAME_NAVIGATION messages to parent
|
|
62
|
+
* - Receives NAVIGATE_TO commands from parent
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Creates the iframe navigation plugin
|
|
67
|
+
*/
|
|
68
|
+
declare function createIframeNavigationPlugin(): Plugin;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Theme Bridge Plugin
|
|
72
|
+
*
|
|
73
|
+
* Enables real-time theme preview from mITway-App via postMessage.
|
|
74
|
+
* Allows the parent window to preview, apply, and restore themes.
|
|
75
|
+
*
|
|
76
|
+
* Features:
|
|
77
|
+
* - Captures original CSS variable values
|
|
78
|
+
* - Applies theme colors with proper HSL wrapping
|
|
79
|
+
* - Supports both base (--background) and color- prefixed (--color-background) variables
|
|
80
|
+
* - Handles radius variables separately (no HSL wrapper)
|
|
81
|
+
* - Notifies parent when theme bridge is ready
|
|
82
|
+
*
|
|
83
|
+
* Message types:
|
|
84
|
+
* - PREVIEW_THEME: Preview theme without persisting
|
|
85
|
+
* - RESTORE_THEME: Restore original CSS variables
|
|
86
|
+
* - APPLY_THEME: Apply and persist theme
|
|
87
|
+
* - THEME_BRIDGE_READY: Sent when bridge initializes
|
|
88
|
+
* - THEME_APPLIED: Sent after theme is applied
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Creates the theme bridge plugin
|
|
93
|
+
*/
|
|
94
|
+
declare function createThemeBridgePlugin(): Plugin;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* mITway Tagger - Vite plugin suite for mITway integration
|
|
98
|
+
*
|
|
99
|
+
* This plugin provides five main features:
|
|
100
|
+
* 1. JSX Source Tracking - Injects source location metadata into React components
|
|
101
|
+
* 2. Virtual Overrides - Allows temporary file modifications with HMR support
|
|
102
|
+
* 3. Visual Editor - Enables element selection and live style preview via postMessage
|
|
103
|
+
* 4. Iframe Navigation - Notifies parent window of navigation changes
|
|
104
|
+
* 5. Theme Bridge - Enables real-time theme preview from mITway-App
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
interface mITwayTaggerOptions {
|
|
108
|
+
/**
|
|
109
|
+
* Enable JSX source tracking
|
|
110
|
+
* @default true
|
|
111
|
+
*/
|
|
112
|
+
jsxSource?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Enable virtual file overrides with HMR
|
|
115
|
+
* @default true
|
|
116
|
+
*/
|
|
117
|
+
virtualOverrides?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Enable visual editor for element selection and style preview
|
|
120
|
+
* @default true
|
|
121
|
+
*/
|
|
122
|
+
visualEditor?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Enable iframe navigation notifications to parent window
|
|
125
|
+
* @default true
|
|
126
|
+
*/
|
|
127
|
+
iframeNavigation?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Enable theme bridge for real-time theme preview
|
|
130
|
+
* @default true
|
|
131
|
+
*/
|
|
132
|
+
themeBridge?: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* File extensions to process for JSX source tracking
|
|
135
|
+
* @default ['.jsx', '.tsx']
|
|
136
|
+
*/
|
|
137
|
+
extensions?: string[];
|
|
138
|
+
/**
|
|
139
|
+
* Directories to exclude from processing
|
|
140
|
+
* @default ['node_modules', '.git']
|
|
141
|
+
*/
|
|
142
|
+
exclude?: string[];
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Creates the mITway Tagger Vite plugin suite
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* // Enable all features (default)
|
|
149
|
+
* mitwayTagger()
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* // Disable specific features
|
|
153
|
+
* mitwayTagger({ jsxSource: false, virtualOverrides: false })
|
|
154
|
+
*/
|
|
155
|
+
declare function mitwayTagger(options?: mITwayTaggerOptions): Plugin[];
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Server configuration interface for mITway iframe integration
|
|
159
|
+
*/
|
|
160
|
+
interface mITwayServerConfig {
|
|
161
|
+
host: string;
|
|
162
|
+
port: number;
|
|
163
|
+
cors: {
|
|
164
|
+
origin: (string | RegExp)[];
|
|
165
|
+
methods: string[];
|
|
166
|
+
allowedHeaders: string[];
|
|
167
|
+
credentials: boolean;
|
|
168
|
+
};
|
|
169
|
+
headers: Record<string, string>;
|
|
170
|
+
allowedHosts: string[];
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Pre-configured server settings for mITway iframe integration.
|
|
174
|
+
* Includes host, port, CORS, CSP headers, and allowed hosts.
|
|
175
|
+
* Use directly with Vite's server and preview options.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* // vite.config.ts
|
|
179
|
+
* import { mitwayTagger, mitwayServerConfig } from 'mitway-tagger';
|
|
180
|
+
*
|
|
181
|
+
* export default defineConfig({
|
|
182
|
+
* plugins: [react(), ...mitwayTagger()],
|
|
183
|
+
* server: mitwayServerConfig,
|
|
184
|
+
* preview: mitwayServerConfig,
|
|
185
|
+
* });
|
|
186
|
+
*/
|
|
187
|
+
declare const mitwayServerConfig: mITwayServerConfig;
|
|
188
|
+
/**
|
|
189
|
+
* Creates a customized server config by merging with additional origins.
|
|
190
|
+
* Useful when you need to add custom domains to the CORS and CSP settings.
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* const config = createmITwayServerConfig({
|
|
194
|
+
* additionalOrigins: ['https://my-custom-domain.com'],
|
|
195
|
+
* additionalHosts: ['.my-custom-domain.com'],
|
|
196
|
+
* });
|
|
197
|
+
*/
|
|
198
|
+
declare function createmITwayServerConfig(options?: {
|
|
199
|
+
additionalOrigins?: (string | RegExp)[];
|
|
200
|
+
additionalHosts?: string[];
|
|
201
|
+
port?: number;
|
|
202
|
+
}): mITwayServerConfig;
|
|
203
|
+
|
|
204
|
+
export { createIframeNavigationPlugin, createJsxSourcePlugin, createThemeBridgePlugin, createVirtualOverridesPlugin, createVisualEditorPlugin, createmITwayServerConfig, mitwayTagger as default, type mITwayServerConfig, type mITwayTaggerOptions, mitwayServerConfig, mitwayTagger };
|