framercode 0.1.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 (31) hide show
  1. package/dist/breakpoints.d.ts +17 -0
  2. package/dist/breakpoints.js +28 -0
  3. package/dist/framer-chunks/SqliteDatabase-VAKIICSG-OPV4MG3Y.js +98 -0
  4. package/dist/framer-chunks/chunk-7ZLQTYXQ.js +102 -0
  5. package/dist/framer-chunks/chunk-IKQSD2QC.js +10 -0
  6. package/dist/framer-chunks/default-blog-sqlite-7ZHEY3GT-TVGUYU6H.js +7 -0
  7. package/dist/framer-chunks/fontshare-4THNDPMZ-FLLTWCDO.js +7 -0
  8. package/dist/framer-chunks/fontshare-B2QLD7YB-5V3XZJAH.js +7 -0
  9. package/dist/framer-chunks/fontshare-O22OBJ3D-FIG3CRN3.js +7 -0
  10. package/dist/framer-chunks/fontshare-PZLWRK4B-MHMZIGTX.js +7 -0
  11. package/dist/framer-chunks/fontshare-SXU5BGFE-OWTMMPGS.js +7 -0
  12. package/dist/framer-chunks/fontshare-TIA7QUPT-PUDLUTQ7.js +7 -0
  13. package/dist/framer-chunks/framer-font-45AI7UCZ-CKGC4MJC.js +7 -0
  14. package/dist/framer-chunks/framer-font-RD2SUPQH-Q4MS7WS6.js +7 -0
  15. package/dist/framer-chunks/google-3FCAKCAC-AM34UPJK.js +7 -0
  16. package/dist/framer-chunks/google-3SZHWBC6-2VTQEQ7J.js +7 -0
  17. package/dist/framer-chunks/google-EGNT223R-P4DUHBW2.js +7 -0
  18. package/dist/framer-chunks/google-GXDJLGJB-JNEJGCGD.js +7 -0
  19. package/dist/framer-chunks/google-H6SFY4F5-5JSJCGDR.js +7 -0
  20. package/dist/framer-chunks/google-YSYBFRE6-L7YAHH7V.js +7 -0
  21. package/dist/framer-chunks/sqlite-wasm-FGP37EAY-NO5QVZDI.js +7 -0
  22. package/dist/framer-chunks/sqlite3-SISQ6ENZ-5WRKGWTY.js +7 -0
  23. package/dist/framer.d.ts +4990 -0
  24. package/dist/framer.js +63235 -0
  25. package/dist/index.d.ts +5 -0
  26. package/dist/index.js +5 -0
  27. package/dist/react.d.ts +44 -0
  28. package/dist/react.js +79 -0
  29. package/dist/styles/framer.css +920 -0
  30. package/dist/styles/reset.css +37 -0
  31. package/package.json +38 -0
@@ -0,0 +1,5 @@
1
+ export * from './framer.js';
2
+ export { ContextProviders, WithFramerBreakpoints, FramerCodeProvider, } from './react.js';
3
+ export type { ContextProvidersProps, WithFramerBreakpointsProps, FramerCodeProviderProps, LocaleInfo, } from './react.js';
4
+ export { defaultBreakpointSizes, breakpointForWidth } from './breakpoints.js';
5
+ export type { Breakpoint, VariantMap } from './breakpoints.js';
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ // Public surface: the full Framer runtime (so `framer` / `framer-motion`
2
+ // imports in exported components resolve here) plus the React glue.
3
+ export * from './framer.js';
4
+ export { ContextProviders, WithFramerBreakpoints, FramerCodeProvider, } from './react.js';
5
+ export { defaultBreakpointSizes, breakpointForWidth } from './breakpoints.js';
@@ -0,0 +1,44 @@
1
+ import React, { type ReactNode } from 'react';
2
+ import { type VariantMap } from './breakpoints.js';
3
+ type Routes = Record<string, {
4
+ path: string;
5
+ }>;
6
+ export interface LocaleInfo {
7
+ id?: string;
8
+ slug?: string;
9
+ code?: string;
10
+ name?: string;
11
+ }
12
+ export interface FramerCodeProviderProps {
13
+ /** Client-side navigation handler (e.g. React Router / Next router). */
14
+ navigate?: (url: string) => void;
15
+ /** Active locale slug, e.g. "en". */
16
+ locale?: string;
17
+ children?: ReactNode;
18
+ }
19
+ /** App-level provider supplying navigation + locale to exported components. */
20
+ export declare function FramerCodeProvider(props: FramerCodeProviderProps): React.JSX.Element;
21
+ export interface ContextProvidersProps {
22
+ locale?: string;
23
+ locales?: LocaleInfo[];
24
+ routes?: Routes;
25
+ framerSiteId?: string;
26
+ children?: ReactNode;
27
+ }
28
+ /**
29
+ * Wraps an exported Framer component with the runtime contexts it expects
30
+ * (fetch client, custom cursor, form/site id, locale, routes).
31
+ */
32
+ export declare function ContextProviders({ locale: localeProp, locales, routes, framerSiteId, children, }: ContextProvidersProps): React.JSX.Element;
33
+ export interface WithFramerBreakpointsProps {
34
+ Component: React.ComponentType<any>;
35
+ variants: VariantMap;
36
+ [key: string]: any;
37
+ }
38
+ /**
39
+ * Renders the variant of a component matching the current viewport width.
40
+ * All variants are rendered hidden via `.framercode-hidden` and the active one is
41
+ * revealed by the breakpoint media queries in styles.css.
42
+ */
43
+ export declare function WithFramerBreakpoints({ Component, variants, ...rest }: WithFramerBreakpointsProps): any;
44
+ export {};
package/dist/react.js ADDED
@@ -0,0 +1,79 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext, useMemo, useSyncExternalStore, } from 'react';
4
+ // The bundled Framer runtime is compiled JS; pull the runtime providers via a
5
+ // namespace and treat them as untyped (the runtime d.ts doesn't declare them).
6
+ // @ts-ignore - runtime is compiled JS with a partial d.ts.
7
+ import * as FramerRuntime from './framer.js';
8
+ import { breakpointForWidth, fillBreakpoints, } from './breakpoints.js';
9
+ const { CustomCursorHost, FetchClientProvider, FormContext, LocaleInfoContext, } = FramerRuntime;
10
+ function cx(...parts) {
11
+ return parts.filter(Boolean).join(' ');
12
+ }
13
+ function isEmpty(obj) {
14
+ return Object.keys(obj).length === 0;
15
+ }
16
+ const routesContext = createContext({});
17
+ const providerContext = createContext({});
18
+ /** App-level provider supplying navigation + locale to exported components. */
19
+ export function FramerCodeProvider(props) {
20
+ return (_jsx(providerContext.Provider, { value: props, children: props.children }));
21
+ }
22
+ /**
23
+ * Wraps an exported Framer component with the runtime contexts it expects
24
+ * (fetch client, custom cursor, form/site id, locale, routes).
25
+ */
26
+ export function ContextProviders({ locale: localeProp, locales, routes, framerSiteId, children, }) {
27
+ const outer = useContext(providerContext);
28
+ const locale = localeProp || outer.locale;
29
+ const activeLocale = locales?.find((l) => l.slug === locale || l.code === locale || l.id === locale);
30
+ const localeInfo = useMemo(() => ({
31
+ activeLocale,
32
+ locales,
33
+ setLocale: async () => {
34
+ // Locale switching is not supported outside Framer; no-op.
35
+ },
36
+ }), [activeLocale, locales]);
37
+ return (_jsx(FetchClientProvider, { children: _jsx(CustomCursorHost, { children: _jsx(FormContext.Provider, { value: framerSiteId, children: _jsx(LocaleInfoContext.Provider, { value: localeInfo, children: _jsx(routesContext.Provider, { value: routes ?? {}, children: children }) }) }) }) }));
38
+ }
39
+ const subscribeResize = (callback) => {
40
+ window.addEventListener('resize', callback);
41
+ return () => window.removeEventListener('resize', callback);
42
+ };
43
+ /**
44
+ * Renders the variant of a component matching the current viewport width.
45
+ * All variants are rendered hidden via `.framercode-hidden` and the active one is
46
+ * revealed by the breakpoint media queries in styles.css.
47
+ */
48
+ export function WithFramerBreakpoints({ Component, variants, ...rest }) {
49
+ // getServerSnapshot returns '' so SSR/hydration match (server renders all).
50
+ const current = useSyncExternalStore(subscribeResize, () => breakpointForWidth(window.innerWidth) ?? '', () => '');
51
+ if (isEmpty(variants)) {
52
+ return _jsx(Component, { ...rest });
53
+ }
54
+ const filled = fillBreakpoints(variants);
55
+ const groups = new Map();
56
+ for (const bp of Object.keys(filled)) {
57
+ const variant = filled[bp];
58
+ if (!variant)
59
+ continue;
60
+ const existing = groups.get(variant);
61
+ if (existing) {
62
+ existing.breakpoints.push(bp);
63
+ existing.className = cx(existing.className, `framercode-${bp}`);
64
+ }
65
+ else {
66
+ groups.set(variant, {
67
+ variant,
68
+ className: cx('framercode', 'framercode-hidden', `framercode-${bp}`),
69
+ breakpoints: [bp],
70
+ });
71
+ }
72
+ }
73
+ return [...groups.values()].map(({ variant, className, breakpoints }) => {
74
+ const visible = !current || breakpoints.includes(current);
75
+ if (!visible)
76
+ return null;
77
+ return (_jsx(Component, { suppressHydrationWarning: true, layoutId: variant, ...rest, className: cx(className, rest.className), variant: variant }, variant));
78
+ });
79
+ }