unframer 2.25.3 → 2.25.4

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 (55) hide show
  1. package/dist/cli.d.ts +21 -0
  2. package/dist/cli.d.ts.map +1 -1
  3. package/dist/cli.js +79 -48
  4. package/dist/cli.js.map +1 -1
  5. package/dist/example-code.test.d.ts +2 -0
  6. package/dist/example-code.test.d.ts.map +1 -0
  7. package/dist/example-code.test.js +72 -0
  8. package/dist/example-code.test.js.map +1 -0
  9. package/dist/exporter.d.ts +17 -55
  10. package/dist/exporter.d.ts.map +1 -1
  11. package/dist/exporter.js +68 -68
  12. package/dist/exporter.js.map +1 -1
  13. package/dist/framer.d.ts.map +1 -1
  14. package/dist/framer.js +99 -53
  15. package/dist/framer.js.map +1 -1
  16. package/dist/generated/api-client.js +0 -1
  17. package/dist/generated/api-client.js.map +1 -1
  18. package/dist/generated/api-client.test.js +0 -69
  19. package/dist/generated/api-client.test.js.map +1 -1
  20. package/dist/version.d.ts +1 -1
  21. package/dist/version.js +1 -1
  22. package/esm/cli.d.ts +21 -0
  23. package/esm/cli.d.ts.map +1 -1
  24. package/esm/cli.js +78 -48
  25. package/esm/cli.js.map +1 -1
  26. package/esm/example-code.test.d.ts +2 -0
  27. package/esm/example-code.test.d.ts.map +1 -0
  28. package/esm/example-code.test.js +70 -0
  29. package/esm/example-code.test.js.map +1 -0
  30. package/esm/exporter.d.ts +17 -55
  31. package/esm/exporter.d.ts.map +1 -1
  32. package/esm/exporter.js +67 -68
  33. package/esm/exporter.js.map +1 -1
  34. package/esm/framer.d.ts.map +1 -1
  35. package/esm/framer.js +99 -53
  36. package/esm/framer.js.map +1 -1
  37. package/esm/generated/api-client.js +0 -1
  38. package/esm/generated/api-client.js.map +1 -1
  39. package/esm/generated/api-client.test.d.ts +0 -1
  40. package/esm/generated/api-client.test.js +1 -69
  41. package/esm/generated/api-client.test.js.map +1 -1
  42. package/esm/version.d.ts +1 -1
  43. package/esm/version.js +1 -1
  44. package/package.json +4 -4
  45. package/src/{cli.tsx → cli.ts} +114 -64
  46. package/src/example-code.test.ts +72 -0
  47. package/src/exporter.ts +94 -80
  48. package/src/framer.js +128 -79
  49. package/src/generated/api-client.d.ts +1048 -682
  50. package/src/generated/api-client.d.ts.map +1 -1
  51. package/src/generated/api-client.js +5 -6
  52. package/src/generated/api-client.js.map +1 -1
  53. package/src/generated/api-client.test.d.ts +1 -1
  54. package/src/generated/api-client.test.js +1 -69
  55. package/src/version.ts +1 -1
package/src/framer.js CHANGED
@@ -11104,7 +11104,7 @@ function stagger(duration = 0.1, {
11104
11104
  };
11105
11105
  }
11106
11106
 
11107
- // /:https://app.framerstatic.com/framer.ZDVTUSJ2.mjs
11107
+ // /:https://app.framerstatic.com/framer.4LIH3HZD.mjs
11108
11108
  import { lazy as ReactLazy, } from 'react';
11109
11109
  import React4 from 'react';
11110
11110
  import { startTransition as startTransition2, } from 'react';
@@ -12816,6 +12816,7 @@ async function replacePathVariables(path, currentLocale, nextLocale, defaultLoca
12816
12816
  hasMatch = true;
12817
12817
  }
12818
12818
  if (hasMatch) {
12819
+ replacedPath += resultPath.substring(lastIndex,);
12819
12820
  resultPath = replacedPath;
12820
12821
  }
12821
12822
  return {
@@ -13909,20 +13910,6 @@ function TurnOnReactEventHandling() {
13909
13910
  }, [],);
13910
13911
  return null;
13911
13912
  }
13912
- var hydrationRunning = false;
13913
- function setInitialHydrationState() {
13914
- hydrationRunning = true;
13915
- }
13916
- function setHydrationDone() {
13917
- hydrationRunning = false;
13918
- }
13919
- function useIsHydrationOrSSR() {
13920
- const isHydrationOrSSR = useRef3(!isWindow || hydrationRunning,);
13921
- useEffect(() => {
13922
- isHydrationOrSSR.current = false;
13923
- }, [],);
13924
- return isHydrationOrSSR;
13925
- }
13926
13913
  function onlyRunOnce(originalMethod,) {
13927
13914
  let hasRun = false;
13928
13915
  return function (...args) {
@@ -24322,6 +24309,24 @@ function MagicMotionCrossfadeRoot(props,) {
24322
24309
  children: props.children,
24323
24310
  },);
24324
24311
  }
24312
+ function useMemoOne(factory, inputs,) {
24313
+ const initial = useState(() => ({
24314
+ inputs,
24315
+ result: factory(),
24316
+ }))[0];
24317
+ const isFirstRun = useRef3(true,);
24318
+ const committed = useRef3(initial,);
24319
+ const useCache = isFirstRun.current || Boolean(inputs && committed.current.inputs && isEqual(inputs, committed.current.inputs, false,),);
24320
+ const cache2 = useCache ? committed.current : {
24321
+ inputs,
24322
+ result: factory(),
24323
+ };
24324
+ useEffect(() => {
24325
+ isFirstRun.current = false;
24326
+ committed.current = cache2;
24327
+ }, [cache2,],);
24328
+ return cache2.result;
24329
+ }
24325
24330
  function setRef(ref, value,) {
24326
24331
  if (isFunction(ref,)) {
24327
24332
  ref(value,);
@@ -24387,7 +24392,7 @@ function useRefEffect(ref, effect, deps,) {
24387
24392
  var _a;
24388
24393
  const effectRef = useRef3();
24389
24394
  const depsChangedRef = useRef3();
24390
- useMemo2(() => {
24395
+ useMemoOne(() => {
24391
24396
  if (depsChangedRef.current !== void 0) depsChangedRef.current = true;
24392
24397
  }, deps ?? [{},],);
24393
24398
  if (!ref) return;
@@ -31390,17 +31395,15 @@ function propsForBreakpoint(variant, props, overrides,) {
31390
31395
  ...overrides[variant],
31391
31396
  };
31392
31397
  }
31393
- var PropertyOverridesWithoutCSS = /* @__PURE__ */ React4.forwardRef(function PropertyOverrides({
31394
- breakpoint,
31395
- overrides,
31396
- children,
31397
- ...props
31398
- }, ref,) {
31398
+ var noopSubscribe = () => () => {};
31399
+ var returnTrue = () => true;
31400
+ var returnFalse = () => false;
31401
+ var PropertyOverridesWithoutCSS = /* @__PURE__ */ React4.forwardRef(function PropertyOverrides(props, ref,) {
31399
31402
  const cloneWithRefs = useCloneChildrenWithPropsAndRef(ref,);
31400
31403
  const ancestorCtx = React4.useContext(SSRParentVariantsContext,);
31401
- const isHydrationOrSSR = useIsHydrationOrSSR();
31404
+ const isHydrationOrSSR = React4.useSyncExternalStore(noopSubscribe, returnFalse, returnTrue,);
31402
31405
  const action = useConstant2(() => {
31403
- if (isHydrationOrSSR.current) {
31406
+ if (isHydrationOrSSR) {
31404
31407
  if (isBrowser2()) {
31405
31408
  return 1;
31406
31409
  } else {
@@ -31411,50 +31414,58 @@ var PropertyOverridesWithoutCSS = /* @__PURE__ */ React4.forwardRef(function Pro
31411
31414
  }
31412
31415
  },);
31413
31416
  const generatedComponentContext = React4.useContext(GeneratedComponentContext,);
31414
- if (!generatedComponentContext) {
31415
- console.warn('PropertyOverrides is missing GeneratedComponentContext',);
31416
- return cloneWithRefs(children, props,);
31417
- }
31418
- const {
31419
- primaryVariantId,
31420
- variantClassNames,
31421
- } = generatedComponentContext;
31422
- const parentVariants = (ancestorCtx == null ? void 0 : ancestorCtx.primaryVariantId) === primaryVariantId
31423
- ? ancestorCtx == null ? void 0 : ancestorCtx.variants
31424
- : void 0;
31425
- switch (action) {
31426
- case 0:
31427
- return cloneWithRefs(children, propsForBreakpoint(breakpoint, props, overrides,),);
31428
- case 1:
31429
- return renderBranchedChildrenFromPropertyOverrides(
31430
- overrides,
31431
- children,
31432
- props,
31433
- variantClassNames,
31434
- primaryVariantId,
31435
- parentVariants,
31436
- cloneWithRefs,
31437
- breakpoint,
31438
- // only render the single, active branch
31439
- );
31440
- case 2:
31441
- return renderBranchedChildrenFromPropertyOverrides(
31442
- overrides,
31443
- children,
31444
- props,
31445
- variantClassNames,
31446
- primaryVariantId,
31447
- parentVariants,
31448
- // On the server, we use plain cloneChildrenWithProps instead of useCloneChildrenWithPropsAndRef,
31449
- // because we can't clone one ref to multiple branched-out elements (useCloneChildrenWithPropsAndRef
31450
- // even guards against it), but luckily, refs mean nothing on the server anyway.
31451
- cloneChildrenWithProps,
31452
- void 0,
31453
- // render all branches
31454
- );
31455
- default:
31456
- assertNever(action,);
31457
- }
31417
+ return useMemoOne(() => {
31418
+ const {
31419
+ breakpoint,
31420
+ overrides,
31421
+ children,
31422
+ ...restProps
31423
+ } = props;
31424
+ if (!generatedComponentContext) {
31425
+ console.warn('PropertyOverrides is missing GeneratedComponentContext',);
31426
+ return cloneWithRefs(children, restProps,);
31427
+ }
31428
+ const {
31429
+ primaryVariantId,
31430
+ variantClassNames,
31431
+ } = generatedComponentContext;
31432
+ const parentVariants = (ancestorCtx == null ? void 0 : ancestorCtx.primaryVariantId) === primaryVariantId
31433
+ ? ancestorCtx == null ? void 0 : ancestorCtx.variants
31434
+ : void 0;
31435
+ switch (action) {
31436
+ case 0:
31437
+ return cloneWithRefs(children, propsForBreakpoint(breakpoint, restProps, overrides,),);
31438
+ case 1:
31439
+ return renderBranchedChildrenFromPropertyOverrides(
31440
+ overrides,
31441
+ children,
31442
+ restProps,
31443
+ variantClassNames,
31444
+ primaryVariantId,
31445
+ parentVariants,
31446
+ cloneWithRefs,
31447
+ breakpoint,
31448
+ // only render the single, active branch
31449
+ );
31450
+ case 2:
31451
+ return renderBranchedChildrenFromPropertyOverrides(
31452
+ overrides,
31453
+ children,
31454
+ restProps,
31455
+ variantClassNames,
31456
+ primaryVariantId,
31457
+ parentVariants,
31458
+ // On the server, we use plain cloneChildrenWithProps instead of useCloneChildrenWithPropsAndRef,
31459
+ // because we can't clone one ref to multiple branched-out elements (useCloneChildrenWithPropsAndRef
31460
+ // even guards against it), but luckily, refs mean nothing on the server anyway.
31461
+ cloneChildrenWithProps,
31462
+ void 0,
31463
+ // render all branches
31464
+ );
31465
+ default:
31466
+ assertNever(action,);
31467
+ }
31468
+ }, [generatedComponentContext, ancestorCtx, cloneWithRefs, props,],);
31458
31469
  },);
31459
31470
  var PropertyOverrides2 =
31460
31471
  /* @__PURE__ */ (() => withCSS(PropertyOverridesWithoutCSS, `.${SSRVariantClassName} { display: contents }`, 'PropertyOverrides',))();
@@ -35582,7 +35593,6 @@ function useNavigationTransition() {
35582
35593
  const navigationController = useRef3(void 0,);
35583
35594
  return useCallback(async (transitionFn, nextRender, updateURL, isAbortable = true,) => {
35584
35595
  var _a, _b;
35585
- setHydrationDone();
35586
35596
  const hasUpdateURL = updateURL !== void 0;
35587
35597
  (_a = navigationController.current) == null ? void 0 : _a.abort();
35588
35598
  const controller = isAbortable ? new AbortController() : void 0;
@@ -46884,16 +46894,33 @@ var SharedSVGManager = class {
46884
46894
  *
46885
46895
  * VECTOR @TODO - Unsubscribe from vector set items.
46886
46896
  */
46887
- template(id3, svg,) {
46888
- const entry = this.vectorSetItems.get(id3,);
46889
- if (entry) return `#${entry.id}`;
46890
- this.vectorSetItems.set(id3, {
46891
- id: id3,
46897
+ template(revision, svg,) {
46898
+ const entry = this.vectorSetItems.get(revision,);
46899
+ if (entry) return `#${revision}`;
46900
+ this.vectorSetItems.set(revision, {
46892
46901
  svg,
46902
+ count: 0,
46893
46903
  },);
46894
- if (!useDOM) return `#${id3}`;
46895
- this.maybeAppendTemplate(id3, svg,);
46896
- return `#${id3}`;
46904
+ if (!useDOM) return `#${revision}`;
46905
+ this.maybeAppendTemplate(revision, svg,);
46906
+ return `#${revision}`;
46907
+ }
46908
+ subscribeToTemplate(revision,) {
46909
+ const entry = this.vectorSetItems.get(revision,);
46910
+ if (!entry) return;
46911
+ entry.count++;
46912
+ return () => {
46913
+ const latest = this.vectorSetItems.get(revision,);
46914
+ if (!latest) return;
46915
+ latest.count--;
46916
+ if (latest.count > 0) return;
46917
+ setTimeout(() => {
46918
+ var _a, _b;
46919
+ if ((_a = this.vectorSetItems.get(revision,)) == null ? void 0 : _a.count) return;
46920
+ this.vectorSetItems.delete(revision,);
46921
+ if (useDOM) (_b = document == null ? void 0 : document.getElementById(revision,)) == null ? void 0 : _b.remove();
46922
+ }, 5e3,);
46923
+ };
46897
46924
  }
46898
46925
  clear() {
46899
46926
  this.entries.clear();
@@ -46909,6 +46936,10 @@ var SharedSVGManager = class {
46909
46936
  return output.join('\n',);
46910
46937
  }
46911
46938
  };
46939
+ function useSVGTemplate(revision, svg,) {
46940
+ useEffect(() => sharedSVGManager.subscribeToTemplate(revision,), [revision,],);
46941
+ return sharedSVGManager.template(revision, svg,);
46942
+ }
46912
46943
  var sharedSVGManager = /* @__PURE__ */ new SharedSVGManager();
46913
46944
  function parseSVG(svg,) {
46914
46945
  try {
@@ -48208,6 +48239,7 @@ var Vector = /* @__PURE__ */ (() => {
48208
48239
  const {
48209
48240
  opacity,
48210
48241
  calculatedPath,
48242
+ calculatedPathBoundingBox,
48211
48243
  d,
48212
48244
  insideStroke,
48213
48245
  strokeEnabled,
@@ -48327,7 +48359,18 @@ var Vector = /* @__PURE__ */ (() => {
48327
48359
  }
48328
48360
  const internalShapeId = InternalID.forKey(id3,);
48329
48361
  const internalStrokeClipId = InternalID.forKey(strokeClipId,);
48330
- const shadow = shadowForShape(shadows, rect, internalShapeId, strokeAlpha, strokeWidth, internalStrokeClipId, svgStrokeAttributes,);
48362
+ const shadow = shadowForShape(
48363
+ shadows,
48364
+ // Shadow filter uses 'objectBoundingBox' as filter units, so calculations should be
48365
+ // relative to the referenced object itself (path), instead of the node rect, which
48366
+ // can be larger than the path bounding box.
48367
+ calculatedPathBoundingBox,
48368
+ internalShapeId,
48369
+ strokeAlpha,
48370
+ strokeWidth,
48371
+ internalStrokeClipId,
48372
+ svgStrokeAttributes,
48373
+ );
48331
48374
  const currentName = target === RenderTarget.preview ? name || void 0 : void 0;
48332
48375
  if (shadow.insetElement !== null || shadow.outsetElement !== null || insideStroke) {
48333
48376
  pathAttributes.id = internalShapeId.id;
@@ -48475,6 +48518,12 @@ var Vector = /* @__PURE__ */ (() => {
48475
48518
  rotate: void 0,
48476
48519
  opacity: void 0,
48477
48520
  calculatedPath: [],
48521
+ calculatedPathBoundingBox: {
48522
+ x: 0,
48523
+ y: 0,
48524
+ width: 0,
48525
+ height: 0,
48526
+ },
48478
48527
  d: void 0,
48479
48528
  insideStroke: false,
48480
48529
  strokeEnabled: true,
@@ -49333,7 +49382,6 @@ export {
49333
49382
  secondsToMilliseconds,
49334
49383
  setDragLock,
49335
49384
  setGlobalRenderEnvironment,
49336
- setInitialHydrationState,
49337
49385
  setStyle,
49338
49386
  Shadow,
49339
49387
  sharedSVGManager,
@@ -49455,6 +49503,7 @@ export {
49455
49503
  useScroll,
49456
49504
  useSiteRefs,
49457
49505
  useSpring,
49506
+ useSVGTemplate,
49458
49507
  useTime,
49459
49508
  useTransform,
49460
49509
  useUnmountEffect,