unframer 2.25.4 → 2.26.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/dist/babel-jsx.d.ts +15 -0
- package/dist/babel-jsx.d.ts.map +1 -0
- package/dist/babel-jsx.js +223 -0
- package/dist/babel-jsx.js.map +1 -0
- package/dist/babel-plugin-imports.d.ts +0 -6
- package/dist/babel-plugin-imports.d.ts.map +1 -1
- package/dist/babel-plugin-imports.js +2 -135
- package/dist/babel-plugin-imports.js.map +1 -1
- package/dist/cli.d.ts +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +31 -6
- package/dist/cli.js.map +1 -1
- package/dist/css.js +13 -13
- package/dist/esbuild.d.ts.map +1 -1
- package/dist/esbuild.js +82 -66
- package/dist/esbuild.js.map +1 -1
- package/dist/example-code.test.js +39 -39
- package/dist/example-code.test.js.map +1 -1
- package/dist/exporter.d.ts.map +1 -1
- package/dist/exporter.js +137 -87
- package/dist/exporter.js.map +1 -1
- package/dist/flat-cache-interceptor.d.ts +27 -0
- package/dist/flat-cache-interceptor.d.ts.map +1 -0
- package/dist/flat-cache-interceptor.js +99 -0
- package/dist/flat-cache-interceptor.js.map +1 -0
- package/dist/framer.d.ts.map +1 -1
- package/dist/framer.js +895 -741
- package/dist/framer.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +15 -3
- package/dist/react.js.map +1 -1
- package/dist/sentry.d.ts +1 -1
- package/dist/sentry.d.ts.map +1 -1
- package/dist/sentry.js +2 -17
- package/dist/sentry.js.map +1 -1
- package/dist/undici-dispatcher.d.ts +2 -0
- package/dist/undici-dispatcher.d.ts.map +1 -0
- package/dist/undici-dispatcher.js +13 -0
- package/dist/undici-dispatcher.js.map +1 -0
- package/dist/utils.d.ts +3 -3
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +4 -10
- package/dist/utils.js.map +1 -1
- package/dist/utils.test.d.ts +2 -0
- package/dist/utils.test.d.ts.map +1 -0
- package/dist/utils.test.js +143 -0
- package/dist/utils.test.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/esm/babel-jsx.d.ts +15 -0
- package/esm/babel-jsx.d.ts.map +1 -0
- package/esm/babel-jsx.js +219 -0
- package/esm/babel-jsx.js.map +1 -0
- package/esm/babel-plugin-imports.d.ts +0 -6
- package/esm/babel-plugin-imports.d.ts.map +1 -1
- package/esm/babel-plugin-imports.js +2 -134
- package/esm/babel-plugin-imports.js.map +1 -1
- package/esm/cli.d.ts +1 -0
- package/esm/cli.d.ts.map +1 -1
- package/esm/cli.js +31 -6
- package/esm/cli.js.map +1 -1
- package/esm/css.js +13 -13
- package/esm/esbuild.d.ts.map +1 -1
- package/esm/esbuild.js +82 -66
- package/esm/esbuild.js.map +1 -1
- package/esm/example-code.test.js +40 -40
- package/esm/example-code.test.js.map +1 -1
- package/esm/exporter.d.ts.map +1 -1
- package/esm/exporter.js +100 -50
- package/esm/exporter.js.map +1 -1
- package/esm/flat-cache-interceptor.d.ts +27 -0
- package/esm/flat-cache-interceptor.d.ts.map +1 -0
- package/esm/flat-cache-interceptor.js +95 -0
- package/esm/flat-cache-interceptor.js.map +1 -0
- package/esm/framer.d.ts.map +1 -1
- package/esm/framer.js +871 -729
- package/esm/framer.js.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/react.d.ts.map +1 -1
- package/esm/react.js +15 -3
- package/esm/react.js.map +1 -1
- package/esm/sentry.d.ts +1 -1
- package/esm/sentry.d.ts.map +1 -1
- package/esm/sentry.js +2 -17
- package/esm/sentry.js.map +1 -1
- package/esm/undici-dispatcher.d.ts +2 -0
- package/esm/undici-dispatcher.d.ts.map +1 -0
- package/esm/undici-dispatcher.js +10 -0
- package/esm/undici-dispatcher.js.map +1 -0
- package/esm/utils.d.ts +3 -3
- package/esm/utils.d.ts.map +1 -1
- package/esm/utils.js +3 -9
- package/esm/utils.js.map +1 -1
- package/esm/utils.test.d.ts +2 -0
- package/esm/utils.test.d.ts.map +1 -0
- package/esm/utils.test.js +141 -0
- package/esm/utils.test.js.map +1 -0
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/package.json +8 -10
- package/src/babel-jsx.ts +277 -0
- package/src/babel-plugin-imports.ts +6 -169
- package/src/cli.ts +45 -6
- package/src/css.ts +13 -13
- package/src/esbuild.ts +93 -74
- package/src/example-code.test.ts +40 -41
- package/src/exporter.ts +124 -54
- package/src/flat-cache-interceptor.ts +114 -0
- package/src/framer.js +921 -764
- package/src/index.ts +1 -1
- package/src/react.tsx +15 -1
- package/src/sentry.ts +3 -22
- package/src/undici-dispatcher.ts +13 -0
- package/src/utils.test.ts +148 -0
- package/src/utils.ts +4 -17
- package/src/version.ts +1 -1
package/src/index.ts
CHANGED
package/src/react.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { combinedCSSRules, withCSS as originalWithCSS } from './framer.js'
|
|
3
|
+
import { preconnect, prefetchDNS } from 'react-dom'
|
|
3
4
|
|
|
4
5
|
import {
|
|
5
6
|
ComponentPropsWithoutRef,
|
|
@@ -20,6 +21,12 @@ import { version } from './version.js'
|
|
|
20
21
|
function classNames(...args) {
|
|
21
22
|
return args.filter(Boolean).join(' ')
|
|
22
23
|
}
|
|
24
|
+
function Hints() {
|
|
25
|
+
prefetchDNS('https://fonts.gstatic.com')
|
|
26
|
+
preconnect('https://fonts.gstatic.com')
|
|
27
|
+
preconnect('https://framerusercontent.com')
|
|
28
|
+
return null // nothing to render
|
|
29
|
+
}
|
|
23
30
|
|
|
24
31
|
// breakpoints from the higher to the lower
|
|
25
32
|
const defaultBreakpoints = Object.keys(
|
|
@@ -303,7 +310,12 @@ export function AdaptedLink({
|
|
|
303
310
|
const route = routes?.[webPageId]
|
|
304
311
|
const target = openInNewTab ? '_blank' : undefined
|
|
305
312
|
if (isRelativeLink(href) || isMailto(href)) {
|
|
306
|
-
return React.cloneElement(children, {
|
|
313
|
+
return React.cloneElement(children, {
|
|
314
|
+
...rest,
|
|
315
|
+
onClick: navigateClientSide,
|
|
316
|
+
href,
|
|
317
|
+
target,
|
|
318
|
+
})
|
|
307
319
|
}
|
|
308
320
|
if (!webPageId) {
|
|
309
321
|
return <Link href={href} {...rest} {...onlyForFramer} />
|
|
@@ -353,6 +365,7 @@ export function ContextProviders({
|
|
|
353
365
|
}, [activeLocale, locales])
|
|
354
366
|
return (
|
|
355
367
|
<FetchClientProvider>
|
|
368
|
+
<Hints />
|
|
356
369
|
<CustomCursorHost>
|
|
357
370
|
<FormContext.Provider value={framerSiteId}>
|
|
358
371
|
<LocaleInfoContext value={localeInfo}>
|
|
@@ -402,6 +415,7 @@ const unframerContext = createContext<Partial<UnframerProviderProps>>({
|
|
|
402
415
|
export function UnframerProvider(props: UnframerProviderProps) {
|
|
403
416
|
return (
|
|
404
417
|
<unframerContext.Provider value={props}>
|
|
418
|
+
<Hints />
|
|
405
419
|
{props.children}
|
|
406
420
|
</unframerContext.Provider>
|
|
407
421
|
)
|
package/src/sentry.ts
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
let sentry: typeof import('@sentry/node') | null = null
|
|
5
|
-
|
|
6
|
-
export async function notifyError(error: unknown, msg?: string) {
|
|
7
|
-
console.error(msg, error)
|
|
8
|
-
|
|
9
|
-
if (!sentry) {
|
|
10
|
-
const mod = await import('@sentry/node')
|
|
11
|
-
mod.init({
|
|
12
|
-
dsn: SENTRY_DSN,
|
|
13
|
-
beforeSend(event) {
|
|
14
|
-
if (event?.['name'] === 'AbortError') return null
|
|
15
|
-
return event
|
|
16
|
-
},
|
|
17
|
-
})
|
|
18
|
-
sentry = mod
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
sentry.captureException(error, { extra: { msg } })
|
|
22
|
-
await sentry.flush(1000)
|
|
1
|
+
// TODO the idea was to use Sentry to send back info but the package is too bloated
|
|
2
|
+
export async function notifyError(error: any, msg?: string) {
|
|
3
|
+
console.error(msg, error?.['stack'] || error)
|
|
23
4
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Agent, interceptors, setGlobalDispatcher } from 'undici'
|
|
2
|
+
import { FlatCacheStore } from './flat-cache-interceptor'
|
|
3
|
+
|
|
4
|
+
export const dispatcher = new Agent({
|
|
5
|
+
keepAliveTimeout: 20,
|
|
6
|
+
keepAliveMaxTimeout: 20,
|
|
7
|
+
}).compose(
|
|
8
|
+
interceptors.cache({
|
|
9
|
+
store: new FlatCacheStore(),
|
|
10
|
+
}),
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
setGlobalDispatcher(dispatcher)
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { dedent } from './utils'
|
|
3
|
+
|
|
4
|
+
describe('dedent', () => {
|
|
5
|
+
it('should remove common indentation from template literals', () => {
|
|
6
|
+
const result = dedent`
|
|
7
|
+
Hello world
|
|
8
|
+
This is a test
|
|
9
|
+
|
|
10
|
+
With multiple lines
|
|
11
|
+
`
|
|
12
|
+
expect(result).toMatchInlineSnapshot(`
|
|
13
|
+
"Hello world
|
|
14
|
+
This is a test
|
|
15
|
+
|
|
16
|
+
With multiple lines"
|
|
17
|
+
`)
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('should handle mixed indentation levels', () => {
|
|
21
|
+
const result = dedent`
|
|
22
|
+
function example() {
|
|
23
|
+
const x = 1
|
|
24
|
+
if (x) {
|
|
25
|
+
console.log('hello')
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`
|
|
29
|
+
expect(result).toMatchInlineSnapshot(`
|
|
30
|
+
"function example() {
|
|
31
|
+
const x = 1
|
|
32
|
+
if (x) {
|
|
33
|
+
console.log('hello')
|
|
34
|
+
}
|
|
35
|
+
}"
|
|
36
|
+
`)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('should handle template values', () => {
|
|
40
|
+
const name = 'world'
|
|
41
|
+
const count = 42
|
|
42
|
+
const result = dedent`
|
|
43
|
+
Hello ${name}!
|
|
44
|
+
The count is ${count}
|
|
45
|
+
End of message
|
|
46
|
+
`
|
|
47
|
+
expect(result).toMatchInlineSnapshot(`
|
|
48
|
+
"Hello world!
|
|
49
|
+
The count is 42
|
|
50
|
+
End of message"
|
|
51
|
+
`)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('should handle empty lines and preserve relative indentation', () => {
|
|
55
|
+
|
|
56
|
+
const result = dedent`
|
|
57
|
+
Start
|
|
58
|
+
|
|
59
|
+
Indented line
|
|
60
|
+
|
|
61
|
+
End
|
|
62
|
+
`
|
|
63
|
+
expect(result).toMatchInlineSnapshot(`
|
|
64
|
+
"Start
|
|
65
|
+
|
|
66
|
+
Indented line
|
|
67
|
+
|
|
68
|
+
End"
|
|
69
|
+
`)
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('should handle single line', () => {
|
|
73
|
+
const result = dedent`
|
|
74
|
+
Single line
|
|
75
|
+
`
|
|
76
|
+
expect(result).toMatchInlineSnapshot(`"Single line"`)
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
it('should handle lines with only whitespace', () => {
|
|
80
|
+
const result = dedent`
|
|
81
|
+
Line 1
|
|
82
|
+
|
|
83
|
+
Line 3
|
|
84
|
+
`
|
|
85
|
+
expect(result).toMatchInlineSnapshot(`
|
|
86
|
+
"Line 1
|
|
87
|
+
|
|
88
|
+
Line 3"
|
|
89
|
+
`)
|
|
90
|
+
})
|
|
91
|
+
it('should handle nested dedent calls', () => {
|
|
92
|
+
const inner = dedent`
|
|
93
|
+
function inner() {
|
|
94
|
+
return 'hello'
|
|
95
|
+
}
|
|
96
|
+
`
|
|
97
|
+
const result = dedent`
|
|
98
|
+
class Example {
|
|
99
|
+
${inner}
|
|
100
|
+
|
|
101
|
+
method() {
|
|
102
|
+
console.log('test')
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
`
|
|
106
|
+
expect(result).toMatchInlineSnapshot(`
|
|
107
|
+
"class Example {
|
|
108
|
+
function inner() {
|
|
109
|
+
return 'hello'
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
method() {
|
|
113
|
+
console.log('test')
|
|
114
|
+
}
|
|
115
|
+
}"
|
|
116
|
+
`)
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
it('should preserve additional indentation in template values', () => {
|
|
120
|
+
const codeBlock = dedent`
|
|
121
|
+
if (condition) {
|
|
122
|
+
doSomething()
|
|
123
|
+
.then(result => {
|
|
124
|
+
console.log(result)
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
`
|
|
128
|
+
const result = dedent`
|
|
129
|
+
function wrapper() {
|
|
130
|
+
${codeBlock}
|
|
131
|
+
|
|
132
|
+
return true
|
|
133
|
+
}
|
|
134
|
+
`
|
|
135
|
+
expect(result).toMatchInlineSnapshot(`
|
|
136
|
+
"function wrapper() {
|
|
137
|
+
if (condition) {
|
|
138
|
+
doSomething()
|
|
139
|
+
.then(result => {
|
|
140
|
+
console.log(result)
|
|
141
|
+
})
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return true
|
|
145
|
+
}"
|
|
146
|
+
`)
|
|
147
|
+
})
|
|
148
|
+
})
|
package/src/utils.ts
CHANGED
|
@@ -1,27 +1,12 @@
|
|
|
1
|
+
import dedent from 'string-dedent'
|
|
1
2
|
import pico from 'picocolors'
|
|
2
|
-
import {
|
|
3
|
-
Agent,
|
|
4
|
-
fetch,
|
|
5
|
-
getGlobalDispatcher,
|
|
6
|
-
interceptors,
|
|
7
|
-
setGlobalDispatcher,
|
|
8
|
-
} from 'undici'
|
|
9
3
|
|
|
10
|
-
import { marked } from 'marked'
|
|
11
|
-
import { markedTerminal } from 'marked-terminal'
|
|
12
4
|
import { createSpinner } from 'nanospinner'
|
|
13
5
|
|
|
14
|
-
marked.use(markedTerminal())
|
|
15
|
-
|
|
16
6
|
export function terminalMarkdown(markdown: string) {
|
|
17
|
-
return
|
|
7
|
+
return markdown
|
|
18
8
|
}
|
|
19
9
|
|
|
20
|
-
export const dispatcher = new Agent({
|
|
21
|
-
keepAliveTimeout: 20,
|
|
22
|
-
keepAliveMaxTimeout: 20,
|
|
23
|
-
})
|
|
24
|
-
|
|
25
10
|
const shouldDebugUnframer = !!process.env.DEBUG_UNFRAMER
|
|
26
11
|
|
|
27
12
|
const prefix = '[unframer]'
|
|
@@ -104,3 +89,5 @@ export function isTruthy<T>(x: T | null | undefined | false | 0 | ''): x is T {
|
|
|
104
89
|
}
|
|
105
90
|
|
|
106
91
|
export const stackblitzDemoExample = process.env.STACKBLITZ_DEMO_EXAMPLE
|
|
92
|
+
|
|
93
|
+
export { dedent }
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.
|
|
1
|
+
export const version = '2.26.0'
|