unframer 2.11.2 → 2.12.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/exporter.d.ts +3 -0
- package/dist/exporter.d.ts.map +1 -1
- package/dist/exporter.js +54 -30
- package/dist/exporter.js.map +1 -1
- package/dist/exporter.test.js +3 -0
- package/dist/exporter.test.js.map +1 -1
- package/dist/framer.d.ts.map +1 -1
- package/dist/framer.js +840 -488
- package/dist/framer.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +15 -6
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +66 -3
- package/dist/react.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js.map +1 -1
- package/esm/exporter.d.ts +3 -0
- package/esm/exporter.d.ts.map +1 -1
- package/esm/exporter.js +55 -32
- package/esm/exporter.js.map +1 -1
- package/esm/exporter.test.js +4 -1
- package/esm/exporter.test.js.map +1 -1
- package/esm/framer.d.ts.map +1 -1
- package/esm/framer.js +837 -488
- package/esm/framer.js.map +1 -1
- package/esm/index.d.ts +3 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +3 -1
- package/esm/index.js.map +1 -1
- package/esm/react.d.ts +15 -6
- package/esm/react.d.ts.map +1 -1
- package/esm/react.js +65 -5
- package/esm/react.js.map +1 -1
- package/esm/utils.d.ts +1 -1
- package/esm/utils.d.ts.map +1 -1
- package/esm/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/exporter.test.ts +6 -1
- package/src/exporter.ts +68 -33
- package/src/framer.js +891 -494
- package/src/index.ts +7 -1
- package/src/react.tsx +98 -16
- package/src/utils.ts +1 -1
package/esm/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export * from './framer.js';
|
|
2
|
-
|
|
2
|
+
import { AdaptedLink as Link, ResolveLinksAdapted as ResolveLinks } from './react.js';
|
|
3
|
+
export { FramerStyles, UnframerBreakpoint, WithFramerBreakpoints, ContextProviders, AdaptedLink, } from './react.js';
|
|
4
|
+
export { Link, ResolveLinks };
|
|
3
5
|
//# sourceMappingURL=index.d.ts.map
|
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,OAAO,EACH,WAAW,IAAI,IAAI,EACnB,mBAAmB,IAAI,YAAY,EACtC,MAAM,YAAY,CAAA;AACnB,OAAO,EACH,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,GACd,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,CAAA"}
|
package/esm/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export * from './framer.js';
|
|
2
|
-
|
|
2
|
+
import { AdaptedLink as Link, ResolveLinksAdapted as ResolveLinks, } from './react.js';
|
|
3
|
+
export { FramerStyles, WithFramerBreakpoints, ContextProviders, AdaptedLink, } from './react.js';
|
|
4
|
+
export { Link, ResolveLinks };
|
|
3
5
|
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,OAAO,EACH,WAAW,IAAI,IAAI,EACnB,mBAAmB,IAAI,YAAY,GACtC,MAAM,YAAY,CAAA;AACnB,OAAO,EACH,YAAY,EAEZ,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,GACd,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,CAAA"}
|
package/esm/react.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type UnframerBreakpoint = keyof typeof defaultBreakpointSizes;
|
|
|
7
7
|
export declare function FramerStyles({ Components }: {
|
|
8
8
|
Components?: any[] | undefined;
|
|
9
9
|
}): any;
|
|
10
|
-
export declare const WithFramerBreakpoints:
|
|
10
|
+
export declare const WithFramerBreakpoints: React.ForwardRefExoticComponent<{
|
|
11
11
|
Component: ComponentType<{
|
|
12
12
|
variant?: any;
|
|
13
13
|
className?: string;
|
|
@@ -16,15 +16,24 @@ export declare const WithFramerBreakpoints: import("react").ForwardRefExoticComp
|
|
|
16
16
|
} & Omit<{
|
|
17
17
|
variant?: any;
|
|
18
18
|
className?: string;
|
|
19
|
-
}, "variant"> &
|
|
20
|
-
|
|
19
|
+
}, "variant"> & React.RefAttributes<unknown>>;
|
|
20
|
+
import React from 'react';
|
|
21
|
+
export declare function ResolveLinksAdapted({ links, children }: {
|
|
22
|
+
links: any;
|
|
23
|
+
children: any;
|
|
24
|
+
}): any;
|
|
25
|
+
export declare function AdaptedLink({ href, nodeId, openInNewTab, smoothScroll, ...rest }: {
|
|
26
|
+
[x: string]: any;
|
|
27
|
+
href: any;
|
|
28
|
+
nodeId: any;
|
|
29
|
+
openInNewTab: any;
|
|
30
|
+
smoothScroll: any;
|
|
31
|
+
}): import("react/jsx-runtime.js").JSX.Element;
|
|
32
|
+
export declare function ContextProviders({ locale, children, framerSiteId, routes, locales, }: {
|
|
21
33
|
locale: any;
|
|
22
34
|
children: any;
|
|
23
35
|
framerSiteId: any;
|
|
24
36
|
routes: any;
|
|
25
|
-
routeId: any;
|
|
26
|
-
pathVariables: any;
|
|
27
|
-
collectionUtils: any;
|
|
28
37
|
locales: any;
|
|
29
38
|
}): import("react/jsx-runtime.js").JSX.Element;
|
|
30
39
|
//# sourceMappingURL=react.d.ts.map
|
package/esm/react.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEH,aAAa,EAKhB,MAAM,OAAO,CAAA;AACd,OAAO,EAEH,sBAAsB,EAEzB,MAAM,UAAU,CAAA;AAWjB,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,sBAAsB,CAAA;AA8BpE;;GAEG;AACH,wBAAgB,YAAY,CAAC,EAAE,UAAwB,EAAE;;CAAA,GAAG,GAAG,CAmD9D;AAED,eAAO,MAAM,qBAAqB;;kBACM,GAAG;oBAAc,MAAM;;;;cAAvB,GAAG;gBAAc,MAAM;
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEH,aAAa,EAKhB,MAAM,OAAO,CAAA;AACd,OAAO,EAEH,sBAAsB,EAEzB,MAAM,UAAU,CAAA;AAWjB,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,sBAAsB,CAAA;AA8BpE;;GAEG;AACH,wBAAgB,YAAY,CAAC,EAAE,UAAwB,EAAE;;CAAA,GAAG,GAAG,CAmD9D;AAED,eAAO,MAAM,qBAAqB;;kBACM,GAAG;oBAAc,MAAM;;;;cAAvB,GAAG;gBAAc,MAAM;6CAuF7D,CAAA;AAoCF,OAAO,KAAK,MAAM,OAAO,CAAA;AA0BzB,wBAAgB,mBAAmB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE;;;CAAA,OAGtD;AAED,wBAAgB,WAAW,CAAC,EACxB,IAAI,EACJ,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,GAAG,IAAI,EACV;;;;;;CAAA,8CA2BA;AAED,wBAAgB,gBAAgB,CAAC,EAC7B,MAAM,EACN,QAAQ,EACR,YAAY,EACZ,MAAM,EAEN,OAAO,GACV;;;;;;CAAA,8CAsCA"}
|
package/esm/react.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { combinedCSSRules } from './framer.js';
|
|
4
|
-
import { forwardRef, useId, useSyncExternalStore, } from 'react';
|
|
4
|
+
import { forwardRef, useId, useMemo, useSyncExternalStore, } from 'react';
|
|
5
5
|
import { breakpointsStyles, defaultBreakpointSizes, getFontsStyles, } from './css.js';
|
|
6
6
|
function classNames(...args) {
|
|
7
7
|
return args.filter(Boolean).join(' ');
|
|
@@ -118,9 +118,69 @@ FetchClientProvider,
|
|
|
118
118
|
// @ts-ignore
|
|
119
119
|
FormContext,
|
|
120
120
|
// @ts-ignore
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
121
|
+
LocaleInfoContext,
|
|
122
|
+
// @ts-ignore
|
|
123
|
+
FramerLink as Link, } from './framer.js';
|
|
124
|
+
import React from 'react';
|
|
125
|
+
const routesContext = React.createContext({});
|
|
126
|
+
function replacePathParams(path, params) {
|
|
127
|
+
const paramRegex = /:[a-zA-Z]+/g;
|
|
128
|
+
const matches = path.match(paramRegex);
|
|
129
|
+
// If there is only one match
|
|
130
|
+
if (matches?.length === 1) {
|
|
131
|
+
const paramValue = Object.values(params)[0];
|
|
132
|
+
let res = path.replace(paramRegex, paramValue);
|
|
133
|
+
// console.log({ matches, params, paramValue, res })
|
|
134
|
+
return res;
|
|
135
|
+
}
|
|
136
|
+
return path.replace(paramRegex, (match) => {
|
|
137
|
+
const param = match.slice(1); // Remove the : prefix
|
|
138
|
+
return params[param] || match; // Replace with param value or keep original if not found
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
export function ResolveLinksAdapted({ links, children }) {
|
|
142
|
+
// TODO add ref
|
|
143
|
+
return children(links.map((x) => x.href));
|
|
144
|
+
}
|
|
145
|
+
export function AdaptedLink({ href, nodeId, openInNewTab, smoothScroll, ...rest }) {
|
|
146
|
+
const onlyForFramer = { nodeId, openInNewTab, smoothScroll };
|
|
147
|
+
const routes = React.useContext(routesContext);
|
|
148
|
+
const webPageId = href?.webPageId;
|
|
149
|
+
const pathVariables = href?.pathVariables;
|
|
150
|
+
const route = routes?.[webPageId];
|
|
151
|
+
const target = openInNewTab ? '_blank' : undefined;
|
|
152
|
+
// console.log({ href, pathVariables, path: route?.path, ...rest })
|
|
153
|
+
if (href?.startsWith && href.startsWith('/')) {
|
|
154
|
+
return _jsx("a", { href: href, target: target, ...rest });
|
|
155
|
+
}
|
|
156
|
+
if (!webPageId) {
|
|
157
|
+
return _jsx(Link, { href: href, ...rest, ...onlyForFramer });
|
|
158
|
+
}
|
|
159
|
+
if (!route || !route.path) {
|
|
160
|
+
return _jsx(Link, { href: href, ...rest, ...onlyForFramer });
|
|
161
|
+
}
|
|
162
|
+
let path = route.path;
|
|
163
|
+
if (pathVariables) {
|
|
164
|
+
path = replacePathParams(path, pathVariables);
|
|
165
|
+
}
|
|
166
|
+
if (path?.startsWith?.('/')) {
|
|
167
|
+
return _jsx("a", { href: path, target: target, ...rest });
|
|
168
|
+
}
|
|
169
|
+
return _jsx(Link, { href: path, ...rest, ...onlyForFramer });
|
|
170
|
+
}
|
|
171
|
+
export function ContextProviders({ locale, children, framerSiteId, routes,
|
|
172
|
+
// collectionUtils,
|
|
173
|
+
locales, }) {
|
|
174
|
+
const activeLocale = locales?.find((l) => l.slug === locale || l.code === locale || l.id === locale);
|
|
175
|
+
const localeInfo = useMemo(() => {
|
|
176
|
+
return {
|
|
177
|
+
activeLocale,
|
|
178
|
+
locales,
|
|
179
|
+
setLocale: async (localeOrLocaleId) => {
|
|
180
|
+
console.log('setLocale', localeOrLocaleId);
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
}, [activeLocale, locales]);
|
|
184
|
+
return (_jsx(FetchClientProvider, { children: _jsx(CustomCursorHost, { children: _jsx(FormContext.Provider, { value: framerSiteId, children: _jsx(LocaleInfoContext, { value: localeInfo, children: _jsx(routesContext.Provider, { value: routes, children: children }) }) }) }) }));
|
|
125
185
|
}
|
|
126
186
|
//# sourceMappingURL=react.js.map
|
package/esm/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AACZ,OAAO,EAAE,gBAAgB,EAA6B,MAAM,aAAa,CAAA;AAEzE,OAAO,EAGH,UAAU,EACV,KAAK,
|
|
1
|
+
{"version":3,"file":"react.js","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AACZ,OAAO,EAAE,gBAAgB,EAA6B,MAAM,aAAa,CAAA;AAEzE,OAAO,EAGH,UAAU,EACV,KAAK,EACL,OAAO,EACP,oBAAoB,GACvB,MAAM,OAAO,CAAA;AACd,OAAO,EACH,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,GACjB,MAAM,UAAU,CAAA;AAEjB,SAAS,UAAU,CAAC,GAAG,IAAI;IACvB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACzC,CAAC;AAED,2CAA2C;AAC3C,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAClC,sBAAsB,CACzB,CAAC,OAAO,EAA0B,CAAA;AAInC,SAAS,gCAAgC,CAAC,WAAmB;IACzD,OAAO,kBAAkB,CAAC,IAAI,CAC1B,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,IAAI,sBAAsB,CAAC,IAAI,CAAC,CACxD,CAAA;AACL,CAAC;AAID,SAAS,eAAe,CAAC,WAAwB;IAC7C,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;IACh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C,QAAQ,GACY,GACT,GACD,GACR,GACD,CACzB,CAAA;AACL,CAAC"}
|
package/esm/utils.d.ts
CHANGED
package/esm/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,OAAO,+BAAiD,CAAA;AAIrE,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,4BAEhD;AAKD,eAAO,MAAM,MAAM;;;;;CAclB,CAAA;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,mBAOrD;AAED,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,oBAE/B"}
|
package/esm/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,YAAY,CAAA;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAAC,+BAA+B,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,YAAY,CAAA;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAAC,+BAA+B,CAAC,CA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IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;SAC9B,IAAI,CAAC,GAAG,CAAC,CAAA;AAClB,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,EAAU;IAC5B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;AAC5D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unframer",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0",
|
|
4
4
|
"description": "Import Framer components directly in your React app, type safe and customizable",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"repository": "https://github.com/remorses/unframer",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"react-dom": "*"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
|
-
"node": ">=
|
|
42
|
+
"node": ">=22.0.0"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"async-sema": "^3.1.1",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"just-kebab-case": "^4.2.0",
|
|
53
53
|
"marked": "^15.0.3",
|
|
54
54
|
"marked-terminal": "^7.2.1",
|
|
55
|
-
"nanospinner": "^1.2.
|
|
55
|
+
"nanospinner": "^1.2.2",
|
|
56
56
|
"picocolors": "^1.0.1",
|
|
57
57
|
"real-framer-motion": "npm:framer-motion@11.2.10",
|
|
58
58
|
"spiceflow": "^1.4.1",
|
package/src/exporter.test.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { describe, test, expect } from 'vitest'
|
|
2
|
-
import { propCamelCase } from './exporter'
|
|
2
|
+
import { checkUnframerVersion, propCamelCase } from './exporter'
|
|
3
3
|
import { replaceWebPageIds } from './esbuild'
|
|
4
|
+
import path from 'path'
|
|
5
|
+
|
|
6
|
+
test('checkUnframerVersion', () => {
|
|
7
|
+
checkUnframerVersion({ cwd: process.cwd() })
|
|
8
|
+
})
|
|
4
9
|
|
|
5
10
|
describe('replaceWebPageIds', () => {
|
|
6
11
|
test('replaces webPageIds with paths', () => {
|
package/src/exporter.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { build, BuildResult, context } from 'esbuild'
|
|
2
|
+
import packageJson from '../package.json'
|
|
2
3
|
|
|
3
4
|
import url from 'url'
|
|
4
5
|
import { Config } from './cli'
|
|
@@ -8,7 +9,7 @@ import dprint from 'dprint-node'
|
|
|
8
9
|
|
|
9
10
|
import { nodeModulesPolyfillPlugin } from 'esbuild-plugins-node-modules-polyfill'
|
|
10
11
|
|
|
11
|
-
import { exec } from 'child_process'
|
|
12
|
+
import { exec, execSync } from 'child_process'
|
|
12
13
|
import fs from 'fs'
|
|
13
14
|
import path from 'path'
|
|
14
15
|
import dedent from 'string-dedent'
|
|
@@ -68,6 +69,12 @@ export async function bundle({
|
|
|
68
69
|
|
|
69
70
|
spinner.start()
|
|
70
71
|
|
|
72
|
+
const otherRoutes = Object.fromEntries(
|
|
73
|
+
(config.framerWebPages || []).map((page) => [
|
|
74
|
+
page.webPageId,
|
|
75
|
+
{ path: page.path },
|
|
76
|
+
]),
|
|
77
|
+
)
|
|
71
78
|
const buildContext = await context({
|
|
72
79
|
absWorkingDir: out,
|
|
73
80
|
entryPoints: Object.keys(components).map((name) => {
|
|
@@ -121,20 +128,17 @@ export async function bundle({
|
|
|
121
128
|
JSON.stringify(config.locales) || '[]'
|
|
122
129
|
}
|
|
123
130
|
|
|
124
|
-
Component.Responsive = ({ locale, ...
|
|
131
|
+
Component.Responsive = ({ locale, ...rest }) => {
|
|
125
132
|
return (
|
|
126
133
|
<ContextProviders
|
|
127
134
|
routeId="x"
|
|
128
|
-
routes={{
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
135
|
+
routes={${JSON.stringify(
|
|
136
|
+
otherRoutes,
|
|
137
|
+
)}}
|
|
138
|
+
children={<WithFramerBreakpoints
|
|
132
139
|
Component={Component}
|
|
133
|
-
{...
|
|
134
|
-
|
|
135
|
-
path: '/',
|
|
136
|
-
},
|
|
137
|
-
}}
|
|
140
|
+
{...rest}
|
|
141
|
+
/>}
|
|
138
142
|
framerSiteId={${JSON.stringify(
|
|
139
143
|
config.fullFramerProjectId,
|
|
140
144
|
)}}
|
|
@@ -148,13 +152,12 @@ export async function bundle({
|
|
|
148
152
|
return (
|
|
149
153
|
<ContextProviders
|
|
150
154
|
routeId="x"
|
|
151
|
-
routes={{
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}}
|
|
155
|
+
routes={${JSON.stringify(
|
|
156
|
+
otherRoutes,
|
|
157
|
+
null,
|
|
158
|
+
2,
|
|
159
|
+
)}}
|
|
160
|
+
children={<Component {...rest} />}
|
|
158
161
|
framerSiteId={${JSON.stringify(
|
|
159
162
|
config.fullFramerProjectId,
|
|
160
163
|
)}}
|
|
@@ -227,21 +230,21 @@ export async function bundle({
|
|
|
227
230
|
`/* eslint-disable */\n` +
|
|
228
231
|
doNotEditComment +
|
|
229
232
|
formatted
|
|
230
|
-
if (framerWebPages?.length) {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
const lines = findRelativeLinks(codeNew)
|
|
237
|
-
if (lines.length) {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
233
|
+
// if (framerWebPages?.length) {
|
|
234
|
+
// codeNew = replaceWebPageIds({
|
|
235
|
+
// code: codeNew,
|
|
236
|
+
// elements: framerWebPages,
|
|
237
|
+
// })
|
|
238
|
+
// }
|
|
239
|
+
// const lines = findRelativeLinks(codeNew)
|
|
240
|
+
// if (lines.length) {
|
|
241
|
+
// spinner.error(
|
|
242
|
+
// `found broken links for ${path.relative(out, file.path)}`,
|
|
243
|
+
// )
|
|
244
|
+
// lines.forEach((line) => {
|
|
245
|
+
// logger.log(`${path.resolve(out, file.path)}:${line + 1}`)
|
|
246
|
+
// })
|
|
247
|
+
// }
|
|
245
248
|
|
|
246
249
|
if (existing === codeNew) {
|
|
247
250
|
continue
|
|
@@ -402,11 +405,15 @@ export async function bundle({
|
|
|
402
405
|
|
|
403
406
|
// when user press ctrl+c dispose
|
|
404
407
|
process.on('SIGINT', async () => {
|
|
408
|
+
spinner.stop()
|
|
409
|
+
console.log()
|
|
405
410
|
await buildContext.cancel()
|
|
406
411
|
buildContext.dispose()
|
|
407
412
|
process.exit(0) // Ensure process exits
|
|
408
413
|
})
|
|
409
414
|
process.on('SIGABRT', async () => {
|
|
415
|
+
spinner.stop()
|
|
416
|
+
console.log()
|
|
410
417
|
await buildContext.cancel()
|
|
411
418
|
buildContext.dispose()
|
|
412
419
|
process.exit(0) // Ensure process exits
|
|
@@ -529,6 +536,8 @@ export async function bundle({
|
|
|
529
536
|
|
|
530
537
|
`),
|
|
531
538
|
)
|
|
539
|
+
checkUnframerVersion({ cwd: out })
|
|
540
|
+
console.log()
|
|
532
541
|
return { result, rebuild, buildContext }
|
|
533
542
|
|
|
534
543
|
// // when user press ctrl+c dispose
|
|
@@ -578,6 +587,32 @@ export async function bundle({
|
|
|
578
587
|
// return res
|
|
579
588
|
}
|
|
580
589
|
|
|
590
|
+
export function checkUnframerVersion({ cwd }) {
|
|
591
|
+
const currentVersion = packageJson.version
|
|
592
|
+
try {
|
|
593
|
+
const code = `import('unframer/package.json', { with: { type: 'json' } }).then(pkg => console.log(pkg.version || pkg.default?.version));`
|
|
594
|
+
|
|
595
|
+
const command = [nodePath, '-e', JSON.stringify(code)].join(' ')
|
|
596
|
+
const installedVersion = execSync(command, {
|
|
597
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
598
|
+
cwd,
|
|
599
|
+
})
|
|
600
|
+
.toString()
|
|
601
|
+
.trim()
|
|
602
|
+
|
|
603
|
+
if (installedVersion !== currentVersion) {
|
|
604
|
+
spinner.error(
|
|
605
|
+
`Unframer version mismatch. Please run: npm update unframer@latest`,
|
|
606
|
+
)
|
|
607
|
+
}
|
|
608
|
+
} catch (e: any) {
|
|
609
|
+
// console.error(e.stderr.toString())
|
|
610
|
+
spinner.error(
|
|
611
|
+
'Unframer is not installed in your project. Please run: npm install unframer',
|
|
612
|
+
)
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
581
616
|
export function getDarkModeSelector(opts: {
|
|
582
617
|
darkModeType?: 'class' | 'media'
|
|
583
618
|
content: string
|