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.
Files changed (119) hide show
  1. package/dist/babel-jsx.d.ts +15 -0
  2. package/dist/babel-jsx.d.ts.map +1 -0
  3. package/dist/babel-jsx.js +223 -0
  4. package/dist/babel-jsx.js.map +1 -0
  5. package/dist/babel-plugin-imports.d.ts +0 -6
  6. package/dist/babel-plugin-imports.d.ts.map +1 -1
  7. package/dist/babel-plugin-imports.js +2 -135
  8. package/dist/babel-plugin-imports.js.map +1 -1
  9. package/dist/cli.d.ts +1 -0
  10. package/dist/cli.d.ts.map +1 -1
  11. package/dist/cli.js +31 -6
  12. package/dist/cli.js.map +1 -1
  13. package/dist/css.js +13 -13
  14. package/dist/esbuild.d.ts.map +1 -1
  15. package/dist/esbuild.js +82 -66
  16. package/dist/esbuild.js.map +1 -1
  17. package/dist/example-code.test.js +39 -39
  18. package/dist/example-code.test.js.map +1 -1
  19. package/dist/exporter.d.ts.map +1 -1
  20. package/dist/exporter.js +137 -87
  21. package/dist/exporter.js.map +1 -1
  22. package/dist/flat-cache-interceptor.d.ts +27 -0
  23. package/dist/flat-cache-interceptor.d.ts.map +1 -0
  24. package/dist/flat-cache-interceptor.js +99 -0
  25. package/dist/flat-cache-interceptor.js.map +1 -0
  26. package/dist/framer.d.ts.map +1 -1
  27. package/dist/framer.js +895 -741
  28. package/dist/framer.js.map +1 -1
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/react.d.ts.map +1 -1
  32. package/dist/react.js +15 -3
  33. package/dist/react.js.map +1 -1
  34. package/dist/sentry.d.ts +1 -1
  35. package/dist/sentry.d.ts.map +1 -1
  36. package/dist/sentry.js +2 -17
  37. package/dist/sentry.js.map +1 -1
  38. package/dist/undici-dispatcher.d.ts +2 -0
  39. package/dist/undici-dispatcher.d.ts.map +1 -0
  40. package/dist/undici-dispatcher.js +13 -0
  41. package/dist/undici-dispatcher.js.map +1 -0
  42. package/dist/utils.d.ts +3 -3
  43. package/dist/utils.d.ts.map +1 -1
  44. package/dist/utils.js +4 -10
  45. package/dist/utils.js.map +1 -1
  46. package/dist/utils.test.d.ts +2 -0
  47. package/dist/utils.test.d.ts.map +1 -0
  48. package/dist/utils.test.js +143 -0
  49. package/dist/utils.test.js.map +1 -0
  50. package/dist/version.d.ts +1 -1
  51. package/dist/version.js +1 -1
  52. package/esm/babel-jsx.d.ts +15 -0
  53. package/esm/babel-jsx.d.ts.map +1 -0
  54. package/esm/babel-jsx.js +219 -0
  55. package/esm/babel-jsx.js.map +1 -0
  56. package/esm/babel-plugin-imports.d.ts +0 -6
  57. package/esm/babel-plugin-imports.d.ts.map +1 -1
  58. package/esm/babel-plugin-imports.js +2 -134
  59. package/esm/babel-plugin-imports.js.map +1 -1
  60. package/esm/cli.d.ts +1 -0
  61. package/esm/cli.d.ts.map +1 -1
  62. package/esm/cli.js +31 -6
  63. package/esm/cli.js.map +1 -1
  64. package/esm/css.js +13 -13
  65. package/esm/esbuild.d.ts.map +1 -1
  66. package/esm/esbuild.js +82 -66
  67. package/esm/esbuild.js.map +1 -1
  68. package/esm/example-code.test.js +40 -40
  69. package/esm/example-code.test.js.map +1 -1
  70. package/esm/exporter.d.ts.map +1 -1
  71. package/esm/exporter.js +100 -50
  72. package/esm/exporter.js.map +1 -1
  73. package/esm/flat-cache-interceptor.d.ts +27 -0
  74. package/esm/flat-cache-interceptor.d.ts.map +1 -0
  75. package/esm/flat-cache-interceptor.js +95 -0
  76. package/esm/flat-cache-interceptor.js.map +1 -0
  77. package/esm/framer.d.ts.map +1 -1
  78. package/esm/framer.js +871 -729
  79. package/esm/framer.js.map +1 -1
  80. package/esm/index.d.ts +1 -1
  81. package/esm/index.d.ts.map +1 -1
  82. package/esm/react.d.ts.map +1 -1
  83. package/esm/react.js +15 -3
  84. package/esm/react.js.map +1 -1
  85. package/esm/sentry.d.ts +1 -1
  86. package/esm/sentry.d.ts.map +1 -1
  87. package/esm/sentry.js +2 -17
  88. package/esm/sentry.js.map +1 -1
  89. package/esm/undici-dispatcher.d.ts +2 -0
  90. package/esm/undici-dispatcher.d.ts.map +1 -0
  91. package/esm/undici-dispatcher.js +10 -0
  92. package/esm/undici-dispatcher.js.map +1 -0
  93. package/esm/utils.d.ts +3 -3
  94. package/esm/utils.d.ts.map +1 -1
  95. package/esm/utils.js +3 -9
  96. package/esm/utils.js.map +1 -1
  97. package/esm/utils.test.d.ts +2 -0
  98. package/esm/utils.test.d.ts.map +1 -0
  99. package/esm/utils.test.js +141 -0
  100. package/esm/utils.test.js.map +1 -0
  101. package/esm/version.d.ts +1 -1
  102. package/esm/version.js +1 -1
  103. package/package.json +8 -10
  104. package/src/babel-jsx.ts +277 -0
  105. package/src/babel-plugin-imports.ts +6 -169
  106. package/src/cli.ts +45 -6
  107. package/src/css.ts +13 -13
  108. package/src/esbuild.ts +93 -74
  109. package/src/example-code.test.ts +40 -41
  110. package/src/exporter.ts +124 -54
  111. package/src/flat-cache-interceptor.ts +114 -0
  112. package/src/framer.js +921 -764
  113. package/src/index.ts +1 -1
  114. package/src/react.tsx +15 -1
  115. package/src/sentry.ts +3 -22
  116. package/src/undici-dispatcher.ts +13 -0
  117. package/src/utils.test.ts +148 -0
  118. package/src/utils.ts +4 -17
  119. package/src/version.ts +1 -1
package/src/index.ts CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  } from './react.js'
6
6
  export {
7
7
  FramerStyles,
8
- UnframerBreakpoint,
8
+ type UnframerBreakpoint,
9
9
  WithFramerBreakpoints,
10
10
  ContextProviders,
11
11
  AdaptedLink,
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, { ...rest, onClick: navigateClientSide, href, target })
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
- const SENTRY_DSN =
2
- 'https://67125acb9a41f616144a07c90a16775e@o4508014272446464.ingest.de.sentry.io/4509202968674384'
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 marked(markdown)
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.25.4'
1
+ export const version = '2.26.0'