@reframejs/unframer 4.2.0-reframe.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 (111) hide show
  1. package/README.md +389 -0
  2. package/bin.js +5 -0
  3. package/dist/babel-jsx.d.ts +24 -0
  4. package/dist/babel-jsx.js +299 -0
  5. package/dist/babel-plugin-imports.d.ts +15 -0
  6. package/dist/babel-plugin-imports.js +211 -0
  7. package/dist/babel-typedoc.d.ts +39 -0
  8. package/dist/babel-typedoc.js +76 -0
  9. package/dist/bin.d.ts +2 -0
  10. package/dist/bin.js +3 -0
  11. package/dist/cli.d.ts +59 -0
  12. package/dist/cli.js +821 -0
  13. package/dist/compat.d.ts +2 -0
  14. package/dist/compat.js +23 -0
  15. package/dist/config.d.ts +18 -0
  16. package/dist/config.js +27 -0
  17. package/dist/css-core.d.ts +50 -0
  18. package/dist/css-core.js +231 -0
  19. package/dist/css.d.ts +15 -0
  20. package/dist/css.js +36 -0
  21. package/dist/esbuild.d.ts +31 -0
  22. package/dist/esbuild.js +317 -0
  23. package/dist/exporter.d.ts +96 -0
  24. package/dist/exporter.js +1151 -0
  25. package/dist/flat-cache-interceptor.d.ts +24 -0
  26. package/dist/flat-cache-interceptor.js +87 -0
  27. package/dist/framer-chunks/chunk-IKQSD2QC.js +10 -0
  28. package/dist/framer-chunks/fontshare-PZLWRK4B-MHMZIGTX.js +7 -0
  29. package/dist/framer-chunks/fontshare-SXU5BGFE-OWTMMPGS.js +7 -0
  30. package/dist/framer-chunks/fontshare-TIA7QUPT-PUDLUTQ7.js +7 -0
  31. package/dist/framer-chunks/framer-font-RD2SUPQH-Q4MS7WS6.js +7 -0
  32. package/dist/framer-chunks/google-EGNT223R-P4DUHBW2.js +7 -0
  33. package/dist/framer-chunks/google-H6SFY4F5-5JSJCGDR.js +7 -0
  34. package/dist/framer-chunks/google-YSYBFRE6-L7YAHH7V.js +7 -0
  35. package/dist/framer-client.server.d.ts +4 -0
  36. package/dist/framer-client.server.js +45 -0
  37. package/dist/framer-package-versions.d.ts +781 -0
  38. package/dist/framer-package-versions.js +782 -0
  39. package/dist/framer-types.d.ts +30 -0
  40. package/dist/framer-types.js +35 -0
  41. package/dist/framer.d.ts +4990 -0
  42. package/dist/framer.js +64296 -0
  43. package/dist/index.d.ts +10 -0
  44. package/dist/index.js +13 -0
  45. package/dist/package-manager.d.ts +10 -0
  46. package/dist/package-manager.js +138 -0
  47. package/dist/plugin-mcp-dist/lib/client-websocket.d.ts +5 -0
  48. package/dist/plugin-mcp-dist/lib/client-websocket.js +103 -0
  49. package/dist/plugin-mcp-dist/lib/cms.d.ts +10 -0
  50. package/dist/plugin-mcp-dist/lib/cms.js +58 -0
  51. package/dist/plugin-mcp-dist/lib/errors.d.ts +5 -0
  52. package/dist/plugin-mcp-dist/lib/errors.js +48 -0
  53. package/dist/plugin-mcp-dist/lib/framer-client.d.ts +2 -0
  54. package/dist/plugin-mcp-dist/lib/framer-client.js +4 -0
  55. package/dist/plugin-mcp-dist/lib/framer-client.server.d.ts +3 -0
  56. package/dist/plugin-mcp-dist/lib/framer-client.server.js +46 -0
  57. package/dist/plugin-mcp-dist/lib/framer.d.ts +30 -0
  58. package/dist/plugin-mcp-dist/lib/framer.js +1084 -0
  59. package/dist/plugin-mcp-dist/lib/hooks.d.ts +6 -0
  60. package/dist/plugin-mcp-dist/lib/hooks.js +46 -0
  61. package/dist/plugin-mcp-dist/lib/mcp-client.d.ts +142 -0
  62. package/dist/plugin-mcp-dist/lib/mcp-client.js +40 -0
  63. package/dist/plugin-mcp-dist/lib/mcp-handlers.d.ts +385 -0
  64. package/dist/plugin-mcp-dist/lib/mcp-handlers.js +1924 -0
  65. package/dist/plugin-mcp-dist/lib/mcp-tools.d.ts +5 -0
  66. package/dist/plugin-mcp-dist/lib/mcp-tools.js +5 -0
  67. package/dist/plugin-mcp-dist/lib/mcp-websocket.d.ts +10 -0
  68. package/dist/plugin-mcp-dist/lib/mcp-websocket.js +88 -0
  69. package/dist/plugin-mcp-dist/lib/plugin-websocket.d.ts +5 -0
  70. package/dist/plugin-mcp-dist/lib/plugin-websocket.js +170 -0
  71. package/dist/plugin-mcp-dist/lib/react-export.d.ts +51 -0
  72. package/dist/plugin-mcp-dist/lib/react-export.js +358 -0
  73. package/dist/plugin-mcp-dist/lib/schema.d.ts +276 -0
  74. package/dist/plugin-mcp-dist/lib/schema.js +907 -0
  75. package/dist/plugin-mcp-dist/lib/store.d.ts +2 -0
  76. package/dist/plugin-mcp-dist/lib/store.js +10 -0
  77. package/dist/plugin-mcp-dist/lib/tree-utils.d.ts +6 -0
  78. package/dist/plugin-mcp-dist/lib/tree-utils.js +141 -0
  79. package/dist/plugin-mcp-dist/lib/tunnel.d.ts +46 -0
  80. package/dist/plugin-mcp-dist/lib/tunnel.js +117 -0
  81. package/dist/plugin-mcp-dist/lib/types.d.ts +110 -0
  82. package/dist/plugin-mcp-dist/lib/types.js +188 -0
  83. package/dist/plugin-mcp-dist/lib/upstream-socket.d.ts +13 -0
  84. package/dist/plugin-mcp-dist/lib/upstream-socket.js +56 -0
  85. package/dist/plugin-mcp-dist/lib/utils.d.ts +13 -0
  86. package/dist/plugin-mcp-dist/lib/utils.js +57 -0
  87. package/dist/plugin-mcp-dist/lib/websocket-server.d.ts +10 -0
  88. package/dist/plugin-mcp-dist/lib/websocket-server.js +88 -0
  89. package/dist/plugin-mcp-dist/lib/xml.d.ts +10 -0
  90. package/dist/plugin-mcp-dist/lib/xml.js +395 -0
  91. package/dist/react.d.ts +76 -0
  92. package/dist/react.js +280 -0
  93. package/dist/renamer.d.ts +11 -0
  94. package/dist/renamer.js +139 -0
  95. package/dist/sentry.d.ts +2 -0
  96. package/dist/sentry.js +5 -0
  97. package/dist/stackblitz.d.ts +9 -0
  98. package/dist/stackblitz.js +179 -0
  99. package/dist/styles/framer.css +920 -0
  100. package/dist/styles/reset.css +37 -0
  101. package/dist/typescript.d.ts +24 -0
  102. package/dist/typescript.js +197 -0
  103. package/dist/undici-dispatcher.d.ts +2 -0
  104. package/dist/undici-dispatcher.js +10 -0
  105. package/dist/unframer-loader.d.ts +2 -0
  106. package/dist/unframer-loader.js +12 -0
  107. package/dist/utils.d.ts +20 -0
  108. package/dist/utils.js +81 -0
  109. package/dist/version.d.ts +2 -0
  110. package/dist/version.js +2 -0
  111. package/package.json +131 -0
@@ -0,0 +1,5 @@
1
+ export declare function implementMcpTools({ server, websocketId }: {
2
+ server: any;
3
+ websocketId: any;
4
+ }): Promise<void>;
5
+ //# sourceMappingURL=mcp-tools.d.ts.map
@@ -0,0 +1,5 @@
1
+ export async function implementMcpTools({ server, websocketId, }) {
2
+ // Use your handler
3
+ }
4
+ //# sourceMappingURL=mcp-tools.js.map
5
+ //# sourceMappingURL=mcp-tools.js.map
@@ -0,0 +1,10 @@
1
+ export declare function createWebsocketHandling({ ws, defaultTimeout }: {
2
+ defaultTimeout?: number | undefined;
3
+ ws: any;
4
+ }): {
5
+ send: ({ idempotenceKey, payload, }: {
6
+ idempotenceKey: any;
7
+ payload: any;
8
+ }) => Promise<unknown>;
9
+ };
10
+ //# sourceMappingURL=mcp-websocket.d.ts.map
@@ -0,0 +1,88 @@
1
+ export function createWebsocketHandling({ ws, defaultTimeout = 1000 * 10, }) {
2
+ const pendingRequests = new Map();
3
+ const usedIdempotenceIds = new Set();
4
+ const send = async ({ idempotenceKey, payload, }) => {
5
+ if (!ws || ws.readyState !== WebSocket.OPEN) {
6
+ throw new Error('WebSocket instance not open, cannot send.');
7
+ }
8
+ const id = crypto.randomUUID();
9
+ const message = {
10
+ id,
11
+ payload,
12
+ };
13
+ return new Promise((resolve, reject) => {
14
+ // If idempotenceKey is specified and already used, return resolved promise immediately
15
+ if (idempotenceKey && usedIdempotenceIds.has(idempotenceKey)) {
16
+ console.log(`Idempotence ID ${idempotenceKey} already used, skipping docs payload set payload`);
17
+ return Promise.resolve(undefined);
18
+ }
19
+ const timeout = setTimeout(() => {
20
+ pendingRequests.delete(id);
21
+ reject(new Error(`Request ${id} timed out after ${defaultTimeout}ms`));
22
+ }, defaultTimeout);
23
+ pendingRequests.set(id, { resolve, reject, timeout });
24
+ ws.send(JSON.stringify(message));
25
+ if (idempotenceKey) {
26
+ usedIdempotenceIds.add(idempotenceKey);
27
+ }
28
+ });
29
+ };
30
+ function onMessage(event) {
31
+ let msg;
32
+ try {
33
+ // Handle both string and Blob data
34
+ if (typeof event.data === 'string') {
35
+ msg = JSON.parse(event.data);
36
+ }
37
+ else if (event.data instanceof Blob) {
38
+ // Skip binary data
39
+ return;
40
+ }
41
+ }
42
+ catch (err) {
43
+ // ignore parse errors
44
+ return;
45
+ }
46
+ if (!msg)
47
+ return;
48
+ const { id, payload, error } = msg;
49
+ if (!id)
50
+ return;
51
+ const pending = pendingRequests.get(id);
52
+ if (!pending)
53
+ return;
54
+ pendingRequests.delete(id);
55
+ clearTimeout(pending.timeout);
56
+ if (error) {
57
+ pending.reject(new Error(error));
58
+ }
59
+ else {
60
+ pending.resolve(payload?.output ?? null);
61
+ }
62
+ }
63
+ // Attach ws 'message' event handler
64
+ ws.addEventListener('message', onMessage);
65
+ const cleanup = async () => {
66
+ ws.removeEventListener('message', onMessage);
67
+ send({
68
+ payload: { type: 'close' },
69
+ });
70
+ // Clean up any pending requests
71
+ for (const [id, pending] of Array.from(pendingRequests)) {
72
+ clearTimeout(pending.timeout);
73
+ pending.reject(new Error('RPC client cleanup'));
74
+ }
75
+ pendingRequests.clear();
76
+ usedIdempotenceIds.clear();
77
+ ws.close();
78
+ };
79
+ // Register cleanup on ws close
80
+ ws.addEventListener('close', () => {
81
+ cleanup();
82
+ });
83
+ return {
84
+ send,
85
+ };
86
+ }
87
+ //# sourceMappingURL=mcp-websocket.js.map
88
+ //# sourceMappingURL=mcp-websocket.js.map
@@ -0,0 +1,5 @@
1
+ export declare function websocketClientHandling({ handle, websocketId }: {
2
+ handle: any;
3
+ websocketId: any;
4
+ }): Promise<undefined>;
5
+ //# sourceMappingURL=plugin-websocket.d.ts.map
@@ -0,0 +1,170 @@
1
+ import { useStore } from './store.js';
2
+ // Global variable to track the active cleanup function
3
+ let cleanupFunction = undefined;
4
+ // Global WebSocket instance to check connection state
5
+ let ws = undefined;
6
+ // Track reconnect timeout to cancel it if needed
7
+ let reconnectTimeout = undefined;
8
+ // Function for handling websocket connection based on session cookie
9
+ export async function websocketClientHandling({ handle, websocketId, }) {
10
+ if (typeof window === 'undefined')
11
+ return;
12
+ // Check if we're already connected or connecting using WebSocket state
13
+ if (ws?.readyState === WebSocket.CONNECTING ||
14
+ ws?.readyState === WebSocket.OPEN) {
15
+ console.log('Already connected or connecting (WebSocket state:', ws?.readyState, '), returning existing cleanup function');
16
+ return cleanupFunction;
17
+ }
18
+ const host = new URL(process.env.PUBLIC_URL).host;
19
+ console.log(`using ${host} for websocket url`);
20
+ const websocketUrl = `wss://${host}/_tunnel/upstream?id=${websocketId}`;
21
+ let pingInterval = null;
22
+ let reconnectInterval = 3000;
23
+ let shouldReconnect = true;
24
+ function connect() {
25
+ if (ws?.readyState === WebSocket.CONNECTING ||
26
+ ws?.readyState === WebSocket.OPEN) {
27
+ console.log('Already connected');
28
+ return;
29
+ }
30
+ // Clear any pending reconnect when starting a new connection
31
+ if (reconnectTimeout) {
32
+ clearTimeout(reconnectTimeout);
33
+ reconnectTimeout = undefined;
34
+ }
35
+ console.log('connecting over mcp websocket', websocketUrl);
36
+ ws = new WebSocket(websocketUrl);
37
+ ws.onopen = () => {
38
+ console.log('websocket client connected', websocketId);
39
+ reconnectInterval = 3000;
40
+ if (ws?.readyState === WebSocket.OPEN) {
41
+ ws.send(JSON.stringify({ type: 'ready' }));
42
+ }
43
+ useStore.setState({ isSocketOpen: true, error: undefined });
44
+ // Setup ping interval
45
+ if (pingInterval)
46
+ clearInterval(pingInterval);
47
+ pingInterval = setInterval(() => {
48
+ if (ws?.readyState === WebSocket.OPEN) {
49
+ ws.send(JSON.stringify({ type: 'ping' }));
50
+ }
51
+ }, 5 * 1000);
52
+ };
53
+ ws.onmessage = async (event) => {
54
+ let data;
55
+ try {
56
+ data = JSON.parse(event.data);
57
+ }
58
+ catch {
59
+ console.error(`websocket sent invalid json`, event.data);
60
+ return;
61
+ }
62
+ const { id, payload } = data || {};
63
+ if (!payload?.type) {
64
+ // console.error(`websocket sent invalid data`, event.data)
65
+ return;
66
+ }
67
+ if (payload.type === 'ready') {
68
+ console.log('received ready');
69
+ useStore.setState({ isConnected: true, error: undefined });
70
+ return;
71
+ }
72
+ if (payload.type === 'close') {
73
+ useStore.setState({ isConnected: false });
74
+ return;
75
+ }
76
+ console.log(`websocket message received`, payload);
77
+ try {
78
+ const output = await handle(payload);
79
+ console.log(`websocket message handled`, payload.type, output);
80
+ if (ws?.readyState === WebSocket.OPEN) {
81
+ ws.send(JSON.stringify({
82
+ id,
83
+ payload: {
84
+ input: payload.input,
85
+ type: payload.type,
86
+ output,
87
+ },
88
+ }));
89
+ }
90
+ }
91
+ catch (e) {
92
+ console.error(`websocket error`, e);
93
+ if (ws?.readyState === WebSocket.OPEN) {
94
+ ws.send(JSON.stringify({
95
+ id,
96
+ error: e instanceof Error ? e.message : String(e),
97
+ }));
98
+ }
99
+ }
100
+ };
101
+ ws.onerror = (error) => {
102
+ console.error('websocket error', error);
103
+ };
104
+ ws.onclose = (event) => {
105
+ console.log(`websocket client disconnected (${event.code}), reconnecting in ${reconnectInterval}ms`);
106
+ useStore.setState({
107
+ isConnected: false,
108
+ isSocketOpen: false,
109
+ error: undefined,
110
+ });
111
+ if (pingInterval) {
112
+ clearInterval(pingInterval);
113
+ pingInterval = null;
114
+ }
115
+ // Clear connection state
116
+ cleanupFunction = undefined;
117
+ ws = undefined;
118
+ if (event.code === 4009) {
119
+ const errorMessage = 'Another MCP plugin has connected. Please keep only one open. Then try reopening this plugin';
120
+ console.error(errorMessage);
121
+ useStore.setState({
122
+ isConnected: false,
123
+ isSocketOpen: false,
124
+ error: errorMessage,
125
+ });
126
+ // Prevent further reconnect attempts when this error occurs
127
+ shouldReconnect = false;
128
+ }
129
+ if (reconnectTimeout) {
130
+ clearTimeout(reconnectTimeout);
131
+ }
132
+ if (shouldReconnect) {
133
+ reconnectTimeout = setTimeout(() => {
134
+ reconnectTimeout = undefined;
135
+ // Only reconnect if WebSocket is not open or connecting
136
+ if (!ws ||
137
+ (ws.readyState !== WebSocket.OPEN &&
138
+ ws.readyState !== WebSocket.CONNECTING)) {
139
+ connect();
140
+ }
141
+ }, reconnectInterval);
142
+ // exponential backoff (max 30s)
143
+ reconnectInterval = Math.min(30000, reconnectInterval * 1.1);
144
+ }
145
+ };
146
+ }
147
+ // Start the connection
148
+ connect();
149
+ // Create and store the cleanup function
150
+ cleanupFunction = () => {
151
+ shouldReconnect = false;
152
+ if (reconnectTimeout) {
153
+ clearTimeout(reconnectTimeout);
154
+ reconnectTimeout = undefined;
155
+ }
156
+ if (pingInterval) {
157
+ clearInterval(pingInterval);
158
+ pingInterval = null;
159
+ }
160
+ if (ws?.readyState !== WebSocket.CLOSED) {
161
+ ws?.close();
162
+ }
163
+ cleanupFunction = undefined;
164
+ ws = undefined;
165
+ };
166
+ // Return the cleanup function
167
+ return cleanupFunction;
168
+ }
169
+ //# sourceMappingURL=plugin-websocket.js.map
170
+ //# sourceMappingURL=plugin-websocket.js.map
@@ -0,0 +1,51 @@
1
+ export declare function getInstancesWithOrderAndDepth({ allInstances, webPageIds, components, projectId }: {
2
+ allInstances: any;
3
+ components: any;
4
+ projectId: any;
5
+ webPageIds: any;
6
+ }): Promise<any[]>;
7
+ export declare function getComponentsWithBreakpoints({ selectedComponentIds, components, allInstances }: {
8
+ allInstances: any;
9
+ components: any;
10
+ selectedComponentIds: any;
11
+ }): Promise<any[]>;
12
+ export declare function processReactExportData({ selectedComponentIds }: {
13
+ selectedComponentIds: any;
14
+ }): Promise<{
15
+ projectId: string;
16
+ projectName: string;
17
+ fullFramerProjectId: string;
18
+ framerUserId: string;
19
+ websiteUrl: string | undefined;
20
+ pageBackgroundColor: string;
21
+ colorStyles: {
22
+ name: string;
23
+ id: string;
24
+ projectId: string;
25
+ lightColor: string;
26
+ darkColor: string;
27
+ }[];
28
+ components: {
29
+ name: any;
30
+ id: any;
31
+ url: any;
32
+ projectId: string;
33
+ componentIdentifier: any;
34
+ componentType: string;
35
+ }[];
36
+ breakpoints: any[];
37
+ pages: {
38
+ path: string;
39
+ webPageId: string;
40
+ projectId: string;
41
+ }[];
42
+ locales: {
43
+ id: any;
44
+ name: any;
45
+ slug: any;
46
+ code: any;
47
+ projectId: string;
48
+ }[];
49
+ componentInstances: any[] | never[];
50
+ }>;
51
+ //# sourceMappingURL=react-export.d.ts.map