@keak/sdk 1.0.1
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 +131 -0
- package/dist/Conversion.d.ts +13 -0
- package/dist/Conversion.d.ts.map +1 -0
- package/dist/KeakToolbarShadow.d.ts +21 -0
- package/dist/KeakToolbarShadow.d.ts.map +1 -0
- package/dist/components/ui/card.d.ts +9 -0
- package/dist/components/ui/card.d.ts.map +1 -0
- package/dist/components/ui/html-preview.d.ts +9 -0
- package/dist/components/ui/html-preview.d.ts.map +1 -0
- package/dist/components/ui/simple-tabs.d.ts +26 -0
- package/dist/components/ui/simple-tabs.d.ts.map +1 -0
- package/dist/components/ui/spinner.d.ts +6 -0
- package/dist/components/ui/spinner.d.ts.map +1 -0
- package/dist/components/ui/tabs.d.ts +13 -0
- package/dist/components/ui/tabs.d.ts.map +1 -0
- package/dist/components/ui/textarea.d.ts +6 -0
- package/dist/components/ui/textarea.d.ts.map +1 -0
- package/dist/index.cjs.js +17407 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +101 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17395 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime/sourceInjector.d.ts +2 -0
- package/dist/runtime/sourceInjector.d.ts.map +1 -0
- package/dist/scripts/sourcePathInjection.d.ts +11 -0
- package/dist/scripts/sourcePathInjection.d.ts.map +1 -0
- package/dist/services/index.d.ts +7 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/telemetry/index.d.ts +20 -0
- package/dist/services/telemetry/index.d.ts.map +1 -0
- package/dist/services/telemetry/telemetryService.d.ts +66 -0
- package/dist/services/telemetry/telemetryService.d.ts.map +1 -0
- package/dist/services/telemetry/types.d.ts +64 -0
- package/dist/services/telemetry/types.d.ts.map +1 -0
- package/dist/toolbar/AIPromptPanel.d.ts +9 -0
- package/dist/toolbar/AIPromptPanel.d.ts.map +1 -0
- package/dist/toolbar/ElementSelector.d.ts +8 -0
- package/dist/toolbar/ElementSelector.d.ts.map +1 -0
- package/dist/toolbar/ExperimentPanel.d.ts +9 -0
- package/dist/toolbar/ExperimentPanel.d.ts.map +1 -0
- package/dist/toolbar/KeakToolbar.d.ts +10 -0
- package/dist/toolbar/KeakToolbar.d.ts.map +1 -0
- package/dist/toolbar/MetricsPanel.d.ts +7 -0
- package/dist/toolbar/MetricsPanel.d.ts.map +1 -0
- package/dist/toolbar/PageScanPanel.d.ts +15 -0
- package/dist/toolbar/PageScanPanel.d.ts.map +1 -0
- package/dist/toolbar/components/PrimaryButton.d.ts +12 -0
- package/dist/toolbar/components/PrimaryButton.d.ts.map +1 -0
- package/dist/toolbar/components/WarningButton.d.ts +12 -0
- package/dist/toolbar/components/WarningButton.d.ts.map +1 -0
- package/dist/toolbar/components/icons/index.d.ts +13 -0
- package/dist/toolbar/components/icons/index.d.ts.map +1 -0
- package/dist/toolbar/components/ui/Badge.d.ts +10 -0
- package/dist/toolbar/components/ui/Badge.d.ts.map +1 -0
- package/dist/toolbar/components/ui/Button.d.ts +12 -0
- package/dist/toolbar/components/ui/Button.d.ts.map +1 -0
- package/dist/toolbar/components/ui/Progress.d.ts +5 -0
- package/dist/toolbar/components/ui/Progress.d.ts.map +1 -0
- package/dist/toolbar/components/ui/Tabs.d.ts +44 -0
- package/dist/toolbar/components/ui/Tabs.d.ts.map +1 -0
- package/dist/toolbar/components/ui/dropdown-menu.d.ts +28 -0
- package/dist/toolbar/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/toolbar/lib/utils.d.ts +3 -0
- package/dist/toolbar/lib/utils.d.ts.map +1 -0
- package/dist/toolbar/utils/fiberSource.d.ts +64 -0
- package/dist/toolbar/utils/fiberSource.d.ts.map +1 -0
- package/dist/toolbar/utils/keakCodeClient.d.ts +104 -0
- package/dist/toolbar/utils/keakCodeClient.d.ts.map +1 -0
- package/dist/toolbar.css +1 -0
- package/dist/toolbar.js +1257 -0
- package/dist/toolbar.js.map +1 -0
- package/dist/utils/generateElementId.d.ts +44 -0
- package/dist/utils/generateElementId.d.ts.map +1 -0
- package/dist/utils/injectDataId.d.ts +33 -0
- package/dist/utils/injectDataId.d.ts.map +1 -0
- package/package.json +152 -0
- package/src/cli/ai-helper.js +206 -0
- package/src/cli/code-transformer.js +354 -0
- package/src/cli/conversion-detector.js +716 -0
- package/src/cli/framework-config.js +477 -0
- package/src/cli/install.js +618 -0
- package/src/cli/keak-setup.js +43 -0
- package/src/cli/revert-conversions.js +264 -0
- package/src/cli/safe-transformer.js +456 -0
- package/src/cli/simple-transformer.js +339 -0
- package/src/plugins/README.md +131 -0
- package/src/plugins/babel-source-inject.cjs +170 -0
- package/src/plugins/next.cjs +145 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keak Next.js Plugin
|
|
3
|
+
*
|
|
4
|
+
* Automatically injects source location attributes into JSX elements
|
|
5
|
+
* for use with Keak IDE element selection.
|
|
6
|
+
*
|
|
7
|
+
* Usage in next.config.js:
|
|
8
|
+
*
|
|
9
|
+
* const { withKeak } = require('keak-sdk/plugins/next');
|
|
10
|
+
*
|
|
11
|
+
* module.exports = withKeak({
|
|
12
|
+
* // your existing Next.js config
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* Or for ESM (next.config.mjs):
|
|
16
|
+
*
|
|
17
|
+
* import { withKeak } from 'keak-sdk/plugins/next';
|
|
18
|
+
* export default withKeak({ ... });
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const path = require('path');
|
|
22
|
+
|
|
23
|
+
function withKeak(nextConfig = {}) {
|
|
24
|
+
console.log('[Keak] withKeak() called - plugin loaded successfully');
|
|
25
|
+
return {
|
|
26
|
+
...nextConfig,
|
|
27
|
+
webpack(config, options) {
|
|
28
|
+
console.log('[Keak] webpack() called with options:', { dev: options.dev, isServer: options.isServer });
|
|
29
|
+
const { dev, isServer } = options;
|
|
30
|
+
|
|
31
|
+
// Only inject in development mode and client-side
|
|
32
|
+
if (dev && !isServer) {
|
|
33
|
+
console.log('[Keak] Configuring Babel loader for source injection...');
|
|
34
|
+
|
|
35
|
+
// Helper function to resolve modules from the project's node_modules
|
|
36
|
+
const resolveFromProject = (moduleName) => {
|
|
37
|
+
try {
|
|
38
|
+
// Try to resolve from the project's context (where next.config.js is)
|
|
39
|
+
return require.resolve(moduleName, {
|
|
40
|
+
paths: [process.cwd()]
|
|
41
|
+
});
|
|
42
|
+
} catch (e) {
|
|
43
|
+
// Fallback to resolving from keak-sdk's context
|
|
44
|
+
console.warn(`[Keak] Could not resolve ${moduleName} from project, falling back to keak-sdk`);
|
|
45
|
+
return require.resolve(moduleName);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Try to find and modify existing babel-loader configurations
|
|
50
|
+
let modifiedExistingLoader = false;
|
|
51
|
+
|
|
52
|
+
config.module.rules.forEach(rule => {
|
|
53
|
+
// Handle rules with use array
|
|
54
|
+
if (rule.use && Array.isArray(rule.use)) {
|
|
55
|
+
rule.use.forEach(loader => {
|
|
56
|
+
if (typeof loader === 'object' && loader.loader && loader.loader.includes('babel-loader')) {
|
|
57
|
+
// Found babel-loader, add our plugin if it's not already there
|
|
58
|
+
if (!loader.options) loader.options = {};
|
|
59
|
+
if (!loader.options.plugins) loader.options.plugins = [];
|
|
60
|
+
|
|
61
|
+
// Check if our plugin is already in the list
|
|
62
|
+
const hasKeakPlugin = loader.options.plugins.some(plugin =>
|
|
63
|
+
(Array.isArray(plugin) && plugin[0] && plugin[0].includes('babel-source-inject')) ||
|
|
64
|
+
(typeof plugin === 'string' && plugin.includes('babel-source-inject'))
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
if (!hasKeakPlugin) {
|
|
68
|
+
loader.options.plugins.push([
|
|
69
|
+
require.resolve('./babel-source-inject.cjs'),
|
|
70
|
+
{ includeElementIndex: true }
|
|
71
|
+
]);
|
|
72
|
+
console.log('[Keak] Added source injection plugin to existing babel-loader');
|
|
73
|
+
modifiedExistingLoader = true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Handle rules with use object
|
|
80
|
+
if (rule.use && typeof rule.use === 'object' && !Array.isArray(rule.use)) {
|
|
81
|
+
const loader = rule.use;
|
|
82
|
+
if (loader.loader && loader.loader.includes('babel-loader')) {
|
|
83
|
+
if (!loader.options) loader.options = {};
|
|
84
|
+
if (!loader.options.plugins) loader.options.plugins = [];
|
|
85
|
+
|
|
86
|
+
const hasKeakPlugin = loader.options.plugins.some(plugin =>
|
|
87
|
+
(Array.isArray(plugin) && plugin[0] && plugin[0].includes('babel-source-inject')) ||
|
|
88
|
+
(typeof plugin === 'string' && plugin.includes('babel-source-inject'))
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
if (!hasKeakPlugin) {
|
|
92
|
+
loader.options.plugins.push([
|
|
93
|
+
require.resolve('./babel-source-inject.cjs'),
|
|
94
|
+
{ includeElementIndex: true }
|
|
95
|
+
]);
|
|
96
|
+
console.log('[Keak] Added source injection plugin to existing babel-loader (object form)');
|
|
97
|
+
modifiedExistingLoader = true;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// If no existing babel-loader was modified, add a new rule
|
|
104
|
+
if (!modifiedExistingLoader) {
|
|
105
|
+
console.log('[Keak] No existing babel-loader found, adding new Babel loader with source injection plugin');
|
|
106
|
+
// PREPEND the rule so it matches before Next.js's built-in rules
|
|
107
|
+
config.module.rules.unshift({
|
|
108
|
+
test: /\.(jsx|tsx)$/,
|
|
109
|
+
exclude: /node_modules/,
|
|
110
|
+
use: {
|
|
111
|
+
loader: resolveFromProject('babel-loader'),
|
|
112
|
+
options: {
|
|
113
|
+
presets: [
|
|
114
|
+
[resolveFromProject('@babel/preset-react'), {
|
|
115
|
+
runtime: 'automatic'
|
|
116
|
+
}],
|
|
117
|
+
resolveFromProject('@babel/preset-typescript')
|
|
118
|
+
],
|
|
119
|
+
plugins: [
|
|
120
|
+
[
|
|
121
|
+
require.resolve('./babel-source-inject.cjs'),
|
|
122
|
+
{
|
|
123
|
+
includeElementIndex: true
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
],
|
|
127
|
+
cacheDirectory: true
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Call the original webpack config function if it exists
|
|
135
|
+
if (typeof nextConfig.webpack === 'function') {
|
|
136
|
+
return nextConfig.webpack(config, options);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return config;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
module.exports = { withKeak };
|
|
145
|
+
|