unframer 4.1.9 → 4.2.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 (85) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.d.ts.map +1 -1
  3. package/dist/cli.js +238 -15
  4. package/dist/cli.js.map +1 -1
  5. package/dist/exporter.d.ts.map +1 -1
  6. package/dist/exporter.js +29 -5
  7. package/dist/exporter.js.map +1 -1
  8. package/dist/framer-chunks/{SqliteDatabase-VAKIICSG-W43ZSXBO.js → SqliteDatabase-VAKIICSG-OPV4MG3Y.js} +5 -4
  9. package/dist/framer-chunks/{chunk-WYG6DFEF.js → chunk-7ZLQTYXQ.js} +4 -23
  10. package/dist/framer-chunks/chunk-IKQSD2QC.js +10 -0
  11. package/dist/framer-chunks/default-blog-sqlite-7ZHEY3GT-TVGUYU6H.js +7 -0
  12. package/dist/framer-chunks/fontshare-4THNDPMZ-FLLTWCDO.js +7 -0
  13. package/dist/framer-chunks/fontshare-B2QLD7YB-5V3XZJAH.js +7 -0
  14. package/dist/framer-chunks/fontshare-O22OBJ3D-FIG3CRN3.js +7 -0
  15. package/dist/framer-chunks/framer-font-45AI7UCZ-CKGC4MJC.js +7 -0
  16. package/dist/framer-chunks/google-3FCAKCAC-AM34UPJK.js +7 -0
  17. package/dist/framer-chunks/google-3SZHWBC6-2VTQEQ7J.js +7 -0
  18. package/dist/framer-chunks/google-GXDJLGJB-JNEJGCGD.js +7 -0
  19. package/dist/framer-chunks/sqlite-wasm-FGP37EAY-NO5QVZDI.js +7 -0
  20. package/dist/framer-chunks/sqlite3-SISQ6ENZ-5WRKGWTY.js +7 -0
  21. package/dist/framer.d.ts +128 -0
  22. package/dist/framer.js +395 -393
  23. package/dist/plugin-mcp-dist/lib/framer.d.ts.map +1 -1
  24. package/dist/plugin-mcp-dist/lib/framer.js +30 -14
  25. package/dist/plugin-mcp-dist/lib/framer.js.map +1 -1
  26. package/dist/plugin-mcp-dist/lib/framer.test.js +34 -64
  27. package/dist/plugin-mcp-dist/lib/framer.test.js.map +1 -1
  28. package/dist/plugin-mcp-dist/lib/mcp-handlers.d.ts.map +1 -1
  29. package/dist/plugin-mcp-dist/lib/mcp-handlers.js +59 -0
  30. package/dist/plugin-mcp-dist/lib/mcp-handlers.js.map +1 -1
  31. package/dist/plugin-mcp-dist/lib/react-export.d.ts.map +1 -1
  32. package/dist/plugin-mcp-dist/lib/react-export.js +79 -61
  33. package/dist/plugin-mcp-dist/lib/react-export.js.map +1 -1
  34. package/dist/plugin-mcp-dist/lib/schema.d.ts +8 -0
  35. package/dist/plugin-mcp-dist/lib/schema.d.ts.map +1 -1
  36. package/dist/plugin-mcp-dist/lib/schema.js +18 -1
  37. package/dist/plugin-mcp-dist/lib/schema.js.map +1 -1
  38. package/dist/plugin-mcp-dist/lib/store.d.ts +1 -1
  39. package/dist/plugin-mcp-dist/lib/store.d.ts.map +1 -1
  40. package/dist/plugin-mcp-dist/lib/utils.d.ts.map +1 -1
  41. package/dist/plugin-mcp-dist/lib/utils.js +11 -7
  42. package/dist/plugin-mcp-dist/lib/utils.js.map +1 -1
  43. package/dist/react.d.ts.map +1 -1
  44. package/dist/react.js +0 -2
  45. package/dist/react.js.map +1 -1
  46. package/dist/version.d.ts +1 -1
  47. package/dist/version.js +1 -1
  48. package/package.json +4 -5
  49. package/src/cli.ts +265 -14
  50. package/src/exporter.ts +39 -6
  51. package/src/framer.d.ts +128 -0
  52. package/src/framer.js +395 -393
  53. package/src/plugin-mcp-dist/lib/framer.d.ts.map +1 -1
  54. package/src/plugin-mcp-dist/lib/framer.js +30 -14
  55. package/src/plugin-mcp-dist/lib/framer.js.map +1 -1
  56. package/src/plugin-mcp-dist/lib/framer.test.js +34 -64
  57. package/src/plugin-mcp-dist/lib/framer.test.js.map +1 -1
  58. package/src/plugin-mcp-dist/lib/mcp-handlers.d.ts +2 -2
  59. package/src/plugin-mcp-dist/lib/mcp-handlers.d.ts.map +1 -1
  60. package/src/plugin-mcp-dist/lib/mcp-handlers.js +59 -0
  61. package/src/plugin-mcp-dist/lib/mcp-handlers.js.map +1 -1
  62. package/src/plugin-mcp-dist/lib/react-export.d.ts +1 -1
  63. package/src/plugin-mcp-dist/lib/react-export.d.ts.map +1 -1
  64. package/src/plugin-mcp-dist/lib/react-export.js +79 -61
  65. package/src/plugin-mcp-dist/lib/react-export.js.map +1 -1
  66. package/src/plugin-mcp-dist/lib/schema.d.ts +11 -3
  67. package/src/plugin-mcp-dist/lib/schema.d.ts.map +1 -1
  68. package/src/plugin-mcp-dist/lib/schema.js +18 -1
  69. package/src/plugin-mcp-dist/lib/schema.js.map +1 -1
  70. package/src/plugin-mcp-dist/lib/utils.d.ts.map +1 -1
  71. package/src/plugin-mcp-dist/lib/utils.js +11 -7
  72. package/src/plugin-mcp-dist/lib/utils.js.map +1 -1
  73. package/src/react.tsx +0 -3
  74. package/src/styles/framer.css +34 -64
  75. package/src/version.ts +1 -1
  76. package/dist/framer-chunks/default-blog-sqlite-7ZHEY3GT-DXFOTMBP.js +0 -9
  77. package/dist/framer-chunks/fontshare-4THNDPMZ-L3NZDIOE.js +0 -27099
  78. package/dist/framer-chunks/fontshare-B2QLD7YB-ZLNQ44LW.js +0 -119
  79. package/dist/framer-chunks/fontshare-O22OBJ3D-VY7WF3BB.js +0 -825
  80. package/dist/framer-chunks/framer-font-45AI7UCZ-Z3XHDH5K.js +0 -7
  81. package/dist/framer-chunks/google-3FCAKCAC-K2ZVMKHN.js +0 -623876
  82. package/dist/framer-chunks/google-3SZHWBC6-MIC5SCB4.js +0 -1627
  83. package/dist/framer-chunks/google-GXDJLGJB-356NWSZ7.js +0 -6885
  84. package/dist/framer-chunks/sqlite-wasm-FGP37EAY-MBPG3MPB.js +0 -11479
  85. package/dist/framer-chunks/sqlite3-SISQ6ENZ-RRHGROT5.js +0 -9
package/src/exporter.ts CHANGED
@@ -8,8 +8,6 @@ const require = createRequire(import.meta.url)
8
8
 
9
9
  import { Sema } from 'async-sema'
10
10
 
11
- import { nodeModulesPolyfillPlugin } from 'esbuild-plugins-node-modules-polyfill'
12
-
13
11
  import { transform } from '@babel/core'
14
12
  import { exec } from 'child_process'
15
13
  import { error } from 'console'
@@ -219,7 +217,6 @@ export async function bundle({
219
217
  missingPackages.add(pkg)
220
218
  },
221
219
  }),
222
- nodeModulesPolyfillPlugin({}),
223
220
  {
224
221
  name: 'virtual loader',
225
222
  setup(build) {
@@ -577,17 +574,28 @@ export async function bundle({
577
574
  ?.split('\n')
578
575
  .forEach((x) => logger.log(x))
579
576
 
577
+ function isChunkPath(filePath: string) {
578
+ return (
579
+ filePath.includes('/chunks/') ||
580
+ filePath.includes('\\chunks\\')
581
+ )
582
+ }
580
583
  const jsxFiles = buildResult.outputFiles
581
584
  .filter(
582
585
  (x) =>
583
586
  x.path.endsWith('.js') &&
587
+ !isChunkPath(x.path) &&
584
588
  fs.existsSync(getFilePaths(x.path, out).jsxPath),
585
589
  )
586
590
  .map((x) => getFilePaths(x.path, out).jsxPath)
587
591
  const outFiles = buildResult.outputFiles
588
592
  .map((x) => {
589
593
  const paths = getFilePaths(x.path, out)
590
- if (x.path.endsWith('.js') && fs.existsSync(paths.jsxPath)) {
594
+ if (
595
+ x.path.endsWith('.js') &&
596
+ !isChunkPath(x.path) &&
597
+ fs.existsSync(paths.jsxPath)
598
+ ) {
591
599
  return null // Will be handled by jsx files
592
600
  }
593
601
  return paths.finalJsPath
@@ -737,8 +745,17 @@ export async function bundle({
737
745
  formatted = result.content
738
746
  }
739
747
  } catch (e) {
748
+ spinner.warn(
749
+ `Babel/Biome formatting failed for ${componentName}: ${e instanceof Error ? e.message : e}`,
750
+ )
751
+ logger.log(e instanceof Error ? e.stack : e)
740
752
  notifyError(e, 'babel transform and format')
741
753
  }
754
+ } else if (tooBig) {
755
+ const sizeMB = (file.text.length / (1024 * 1024)).toFixed(2)
756
+ spinner.warn(
757
+ `Skipping JSX formatting for ${componentName} (${sizeMB} MB exceeds ${(tooBigSize / (1024 * 1024)).toFixed(2)} MB limit)`,
758
+ )
742
759
  }
743
760
 
744
761
  const prefix =
@@ -752,12 +769,24 @@ export async function bundle({
752
769
  // Always write the temp .js file for type extraction
753
770
  await fs.promises.writeFile(paths.tempJsPath, codeJs, 'utf-8')
754
771
 
755
- // Only write .jsx file if it's different from existing or if formatting was done
772
+ // Write .jsx file if formatting succeeded, or fall back to writing
773
+ // unformatted .js content into the .jsx path when formatting fails
774
+ // (babel error, component too big, etc.) but a stale .jsx already
775
+ // exists on disk. Without this fallback the stale .jsx keeps old
776
+ // chunk imports while the old chunks are deleted, breaking the build.
756
777
  if (didFormat && codeJsx !== existing) {
757
778
  await fs.promises.writeFile(paths.jsxPath, codeJsx, 'utf-8')
758
779
  logger.log(`Updated JSX file for ${componentName}`)
759
780
  } else if (didFormat) {
760
781
  logger.log(`JSX file unchanged for ${componentName}`)
782
+ } else if (existing && codeJs !== existing) {
783
+ // Formatting failed but .jsx exists with stale content (e.g.
784
+ // old chunk hashes). Overwrite with unformatted JS so imports
785
+ // stay in sync with the current build's chunks.
786
+ await fs.promises.writeFile(paths.jsxPath, codeJs, 'utf-8')
787
+ logger.log(
788
+ `Updated JSX file (unformatted) for ${componentName}`,
789
+ )
761
790
  }
762
791
  }
763
792
  spinner.stop()
@@ -772,8 +801,12 @@ export async function bundle({
772
801
  if (file.path.endsWith('.js')) {
773
802
  const paths = getFilePaths(file.path, out)
774
803
 
775
- if (fs.existsSync(paths.jsxPath)) {
804
+ if (
805
+ !isChunkPath(paths.tempJsPath) &&
806
+ fs.existsSync(paths.jsxPath)
807
+ ) {
776
808
  // Remove temp .js file if .jsx equivalent exists
809
+ // (never applies to chunks which stay as .js)
777
810
  logger.log(
778
811
  'removing temp JS file with JSX equivalent:',
779
812
  path.relative(out, paths.tempJsPath),
package/src/framer.d.ts CHANGED
@@ -4859,4 +4859,132 @@ export declare const withVariantFX: <T extends MotionProps>(Component: React_2.C
4859
4859
  export { }
4860
4860
  export declare const combinedCSSRules: string[]
4861
4861
 
4862
+ export interface FramerMotionGlobalConfig {
4863
+ useManualTiming?: boolean
4864
+ instantAnimations?: boolean
4865
+ skipAnimations?: boolean
4866
+ mix?: unknown
4867
+ WillChange?: new (value: string) => unknown
4868
+ }
4869
+
4870
+ export interface FramerInjectedRuntimeImage {
4871
+ src?: string
4872
+ srcSet?: string
4873
+ }
4874
+
4875
+ export interface FramerInjectedRuntimeRect {
4876
+ width?: number
4877
+ height?: number
4878
+ }
4879
+
4880
+ export interface FramerInjectedRuntime {
4881
+ imagePlaceholderSvg?: string
4882
+ useImageSource?(image: FramerInjectedRuntimeImage, rect?: FramerInjectedRuntimeRect, nodeId?: string): string
4883
+ useImageElement?(image: FramerInjectedRuntimeImage, rect?: FramerInjectedRuntimeRect, nodeId?: string): HTMLImageElement
4884
+ canRenderOptimizedCanvasImage?(src?: string): boolean
4885
+ isOnPageCanvas?: boolean
4886
+ }
4887
+
4888
+ export interface FramerMotionFrameData {
4889
+ delta: number
4890
+ timestamp: number
4891
+ isProcessing: boolean
4892
+ }
4893
+
4894
+ export type FramerMotionFrameCallback = (frameData: FramerMotionFrameData) => void
4895
+
4896
+ export interface FramerMotionFrameStep {
4897
+ schedule(callback: FramerMotionFrameCallback, keepAlive?: boolean, immediate?: boolean): FramerMotionFrameCallback
4898
+ cancel(callback: FramerMotionFrameCallback): void
4899
+ process(frameData: FramerMotionFrameData): void
4900
+ }
4901
+
4902
+ export type FramerMotionFrameStepName =
4903
+ | 'setup'
4904
+ | 'read'
4905
+ | 'resolveKeyframes'
4906
+ | 'preUpdate'
4907
+ | 'update'
4908
+ | 'preRender'
4909
+ | 'render'
4910
+ | 'postRender'
4911
+
4912
+ export type FramerMotionFrameSteps = Record<FramerMotionFrameStepName, FramerMotionFrameStep>
4913
+
4914
+ export interface FramerMotionTime {
4915
+ now(): number
4916
+ set(newTime: number): void
4917
+ }
4918
+
4919
+ export interface FramerMotionGeneratorState<Value = unknown> {
4920
+ value: Value
4921
+ done?: boolean
4922
+ }
4923
+
4924
+ export interface FramerMotionGenerator<Value = unknown> {
4925
+ calculatedDuration?: number | null
4926
+ next(time: number): FramerMotionGeneratorState<Value>
4927
+ velocity?(time: number): number
4928
+ }
4929
+
4930
+ export interface FramerMotionAnimationDriver {
4931
+ now(): number
4932
+ start(autoplay?: boolean): void
4933
+ stop(): void
4934
+ }
4935
+
4936
+ export interface FramerMotionAnimationOptions<Value = unknown> {
4937
+ keyframes: Value[]
4938
+ autoplay?: boolean
4939
+ delay?: number
4940
+ repeat?: number
4941
+ repeatDelay?: number
4942
+ repeatType?: 'loop' | 'reverse' | 'mirror'
4943
+ velocity?: number
4944
+ finalKeyframe?: Value
4945
+ startTime?: number
4946
+ allowFlatten?: boolean
4947
+ motionValue?: { updatedAt?: number }
4948
+ type?: (options: FramerMotionAnimationOptions<Value>) => FramerMotionGenerator<Value>
4949
+ driver?: (update: (timestamp: number) => void) => FramerMotionAnimationDriver
4950
+ onUpdate?(latest: Value): void
4951
+ onPlay?(): void
4952
+ onComplete?(): void
4953
+ onCancel?(): void
4954
+ onStop?(): void
4955
+ }
4956
+
4957
+ export declare class JSAnimation<Value = unknown> implements PromiseLike<void> {
4958
+ constructor(options: FramerMotionAnimationOptions<Value>)
4959
+ options: FramerMotionAnimationOptions<Value>
4960
+ state: 'idle' | 'running' | 'paused' | 'finished'
4961
+ currentTime: number
4962
+ playbackSpeed: number
4963
+ readonly duration: number
4964
+ readonly iterationDuration: number
4965
+ time: number
4966
+ speed: number
4967
+ readonly finished: Promise<void>
4968
+ then<TResult1 = void, TResult2 = never>(
4969
+ onfulfilled?: ((value: void) => TResult1 | PromiseLike<TResult1>) | null,
4970
+ onrejected?: ((reason: Error) => TResult2 | PromiseLike<TResult2>) | null,
4971
+ ): Promise<TResult1 | TResult2>
4972
+ play(): void
4973
+ pause(): void
4974
+ complete(): void
4975
+ finish(): void
4976
+ cancel(): void
4977
+ stop(): void
4978
+ tick(timestamp: number, sample?: boolean): FramerMotionGeneratorState<Value>
4979
+ sample(sampleTime: number): FramerMotionGeneratorState<Value>
4980
+ attachTimeline(timeline: { observe(animation: JSAnimation<Value>): VoidFunction }): VoidFunction
4981
+ }
4982
+
4983
+ export declare const MotionGlobalConfig: FramerMotionGlobalConfig
4984
+ export declare const frameData: FramerMotionFrameData
4985
+ export declare const frameSteps: FramerMotionFrameSteps
4986
+ export declare const time: FramerMotionTime
4987
+ export declare const visualElementStore: WeakMap<object, unknown>
4988
+ export declare function _injectRuntime(injectedRuntime: FramerInjectedRuntime): void
4989
+
4862
4990
  export * from 'real-framer-motion'