@makeswift/runtime 0.28.8-canary.1 → 0.28.8-canary.3
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/cjs/api/graphql-api-client.js +1 -1
- package/dist/cjs/api/rest-api-client.js +1 -1
- package/dist/cjs/api-handler/handlers/manifest.js +1 -1
- package/dist/cjs/client/index.js +1 -1
- package/dist/cjs/next/components/framework-provider/app-router/index.js +0 -2
- package/dist/cjs/next/components/framework-provider/app-router/index.js.map +1 -1
- package/dist/cjs/next/components/framework-provider/index.js +1 -1
- package/dist/cjs/next/components/framework-provider/index.js.map +1 -1
- package/dist/cjs/runtimes/react/components/framework-context.js +18 -12
- package/dist/cjs/runtimes/react/components/framework-context.js.map +1 -1
- package/dist/cjs/runtimes/react/components/hooks/use-framework-context.js +1 -5
- package/dist/cjs/runtimes/react/components/hooks/use-framework-context.js.map +1 -1
- package/dist/cjs/runtimes/react/components/resolve-props.js +8 -1
- package/dist/cjs/runtimes/react/components/resolve-props.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-control-instances.js +39 -0
- package/dist/cjs/runtimes/react/hooks/use-control-instances.js.map +1 -0
- package/dist/cjs/runtimes/react/hooks/use-resolved-props.js +11 -28
- package/dist/cjs/runtimes/react/hooks/use-resolved-props.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-stylesheet-factory.js +3 -3
- package/dist/cjs/runtimes/react/hooks/use-stylesheet-factory.js.map +1 -1
- package/dist/cjs/runtimes/react/stylesheet-factory.js +17 -0
- package/dist/cjs/runtimes/react/stylesheet-factory.js.map +1 -0
- package/dist/cjs/testing/fixtures/index.js +4 -2
- package/dist/cjs/testing/fixtures/index.js.map +1 -1
- package/dist/cjs/testing/fixtures/snippet.js +36 -0
- package/dist/cjs/testing/fixtures/snippet.js.map +1 -0
- package/dist/cjs/unstable-framework-support/index.js +2 -8
- package/dist/cjs/unstable-framework-support/index.js.map +1 -1
- package/dist/esm/api/graphql-api-client.js +1 -1
- package/dist/esm/api/rest-api-client.js +1 -1
- package/dist/esm/api-handler/handlers/manifest.js +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/next/components/framework-provider/app-router/index.js +0 -4
- package/dist/esm/next/components/framework-provider/app-router/index.js.map +1 -1
- package/dist/esm/next/components/framework-provider/index.js +4 -2
- package/dist/esm/next/components/framework-provider/index.js.map +1 -1
- package/dist/esm/runtimes/react/components/framework-context.js +19 -8
- package/dist/esm/runtimes/react/components/framework-context.js.map +1 -1
- package/dist/esm/runtimes/react/components/hooks/use-framework-context.js +1 -5
- package/dist/esm/runtimes/react/components/hooks/use-framework-context.js.map +1 -1
- package/dist/esm/runtimes/react/components/resolve-props.js +8 -1
- package/dist/esm/runtimes/react/components/resolve-props.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-control-instances.js +15 -0
- package/dist/esm/runtimes/react/hooks/use-control-instances.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-resolved-props.js +10 -17
- package/dist/esm/runtimes/react/hooks/use-resolved-props.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-stylesheet-factory.js +3 -3
- package/dist/esm/runtimes/react/hooks/use-stylesheet-factory.js.map +1 -1
- package/dist/esm/runtimes/react/stylesheet-factory.js +1 -0
- package/dist/esm/runtimes/react/stylesheet-factory.js.map +1 -0
- package/dist/esm/testing/fixtures/index.js +2 -1
- package/dist/esm/testing/fixtures/index.js.map +1 -1
- package/dist/esm/testing/fixtures/snippet.js +12 -0
- package/dist/esm/testing/fixtures/snippet.js.map +1 -0
- package/dist/esm/unstable-framework-support/index.js +2 -8
- package/dist/esm/unstable-framework-support/index.js.map +1 -1
- package/dist/types/next/components/framework-provider/app-router/index.d.ts +1 -1
- package/dist/types/next/components/framework-provider/app-router/index.d.ts.map +1 -1
- package/dist/types/next/components/framework-provider/index.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/__tests__/framework-context.test.d.ts +3 -0
- package/dist/types/runtimes/react/components/__tests__/framework-context.test.d.ts.map +1 -0
- package/dist/types/runtimes/react/components/framework-context.d.ts +4 -6
- package/dist/types/runtimes/react/components/framework-context.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/hooks/use-framework-context.d.ts +1 -2
- package/dist/types/runtimes/react/components/hooks/use-framework-context.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/resolve-props.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/use-control-instances.d.ts +3 -0
- package/dist/types/runtimes/react/hooks/use-control-instances.d.ts.map +1 -0
- package/dist/types/runtimes/react/hooks/use-resolved-props.d.ts +7 -1
- package/dist/types/runtimes/react/hooks/use-resolved-props.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/use-stylesheet-factory.d.ts +1 -5
- package/dist/types/runtimes/react/hooks/use-stylesheet-factory.d.ts.map +1 -1
- package/dist/types/runtimes/react/stylesheet-factory.d.ts +6 -0
- package/dist/types/runtimes/react/stylesheet-factory.d.ts.map +1 -0
- package/dist/types/testing/fixtures/index.d.ts +2 -1
- package/dist/types/testing/fixtures/index.d.ts.map +1 -1
- package/dist/types/testing/fixtures/snippet.d.ts +6 -0
- package/dist/types/testing/fixtures/snippet.d.ts.map +1 -0
- package/dist/types/unstable-framework-support/index.d.ts +1 -1
- package/dist/types/unstable-framework-support/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/cjs/runtimes/react/controls/group.js +0 -45
- package/dist/cjs/runtimes/react/controls/group.js.map +0 -1
- package/dist/esm/runtimes/react/controls/group.js +0 -23
- package/dist/esm/runtimes/react/controls/group.js.map +0 -1
- package/dist/types/runtimes/react/controls/group.d.ts +0 -11
- package/dist/types/runtimes/react/controls/group.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/next/components/framework-provider/index.tsx"],"sourcesContent":["'use client'\n\nimport { type PropsWithChildren, useMemo } from 'react'\nimport NextImage from 'next/image'\n\nimport { useIsPagesRouter } from '../../hooks/use-is-pages-router'\nimport { FrameworkContext
|
|
1
|
+
{"version":3,"sources":["../../../../../src/next/components/framework-provider/index.tsx"],"sourcesContent":["'use client'\n\nimport { type PropsWithChildren, useMemo } from 'react'\nimport NextImage from 'next/image'\n\nimport { useIsPagesRouter } from '../../hooks/use-is-pages-router'\nimport {\n type FrameworkContext,\n FrameworkContextProvider,\n} from '../../../runtimes/react/components/framework-context'\n\nimport { context as appRouterContext } from './app-router'\nimport { context as pagesRouterContext } from './pages-router'\nimport { Link } from './link'\n\nexport function FrameworkProvider({\n children,\n forcePagesRouter,\n}: PropsWithChildren<{ forcePagesRouter?: boolean }>) {\n const isPagesRouter = useIsPagesRouter() || forcePagesRouter\n const context = useMemo<Partial<FrameworkContext>>(\n () => ({\n ...(isPagesRouter ? pagesRouterContext : appRouterContext),\n Image: NextImage,\n Link,\n }),\n [isPagesRouter],\n )\n\n return <FrameworkContextProvider value={context}>{children}</FrameworkContextProvider>\n}\n"],"mappings":";AA6BS;AA3BT,SAAiC,eAAe;AAChD,OAAO,eAAe;AAEtB,SAAS,wBAAwB;AACjC;AAAA,EAEE;AAAA,OACK;AAEP,SAAS,WAAW,wBAAwB;AAC5C,SAAS,WAAW,0BAA0B;AAC9C,SAAS,YAAY;AAEd,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AACF,GAAsD;AACpD,QAAM,gBAAgB,iBAAiB,KAAK;AAC5C,QAAM,UAAU;AAAA,IACd,OAAO;AAAA,MACL,GAAI,gBAAgB,qBAAqB;AAAA,MACzC,OAAO;AAAA,MACP;AAAA,IACF;AAAA,IACA,CAAC,aAAa;AAAA,EAChB;AAEA,SAAO,oBAAC,4BAAyB,OAAO,SAAU,UAAS;AAC7D;","names":[]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
2
|
import {
|
|
3
|
+
forwardRef,
|
|
3
4
|
createContext,
|
|
4
|
-
|
|
5
|
+
useContext,
|
|
6
|
+
useMemo
|
|
5
7
|
} from "react";
|
|
6
8
|
import { BaseHeadSnippet } from "./page/HeadSnippet";
|
|
7
9
|
const DefaultHead = ({ children }) => /* @__PURE__ */ jsx(Fragment, { children });
|
|
@@ -24,17 +26,26 @@ const DefaultImage = ({ priority, fill, style, ...props }) => /* @__PURE__ */ js
|
|
|
24
26
|
const DefaultLink = forwardRef(
|
|
25
27
|
({ linkType, ...props }, ref) => /* @__PURE__ */ jsx("a", { ...props, ref })
|
|
26
28
|
);
|
|
27
|
-
const FrameworkContext = createContext({
|
|
29
|
+
const FrameworkContext = createContext({});
|
|
30
|
+
const FrameworkContextProvider = ({
|
|
31
|
+
value,
|
|
32
|
+
children
|
|
33
|
+
}) => {
|
|
34
|
+
const parentContext = useContext(FrameworkContext);
|
|
35
|
+
const mergedContext = useMemo(() => ({ ...parentContext, ...value }), [parentContext, value]);
|
|
36
|
+
return /* @__PURE__ */ jsx(FrameworkContext.Provider, { value: mergedContext, children });
|
|
37
|
+
};
|
|
38
|
+
const defaultContext = {
|
|
28
39
|
Head: DefaultHead,
|
|
29
40
|
HeadSnippet: DefaultHeadSnippet,
|
|
30
41
|
Image: DefaultImage,
|
|
31
42
|
Link: DefaultLink
|
|
32
|
-
}
|
|
43
|
+
};
|
|
44
|
+
function useFrameworkContext() {
|
|
45
|
+
return { ...defaultContext, ...useContext(FrameworkContext) };
|
|
46
|
+
}
|
|
33
47
|
export {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
DefaultImage,
|
|
37
|
-
DefaultLink,
|
|
38
|
-
FrameworkContext
|
|
48
|
+
FrameworkContextProvider,
|
|
49
|
+
useFrameworkContext
|
|
39
50
|
};
|
|
40
51
|
//# sourceMappingURL=framework-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/components/framework-context.tsx"],"sourcesContent":["import {\n
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/components/framework-context.tsx"],"sourcesContent":["import {\n type ReactNode,\n type PropsWithChildren,\n type CSSProperties,\n type ComponentPropsWithoutRef,\n type MouseEvent,\n type ForwardRefExoticComponent,\n type RefAttributes,\n forwardRef,\n createContext,\n useContext,\n useMemo,\n} from 'react'\n\nimport { type LinkData } from '@makeswift/prop-controllers'\n\nimport { type Snippet } from '../../../client'\n\nimport { BaseHeadSnippet } from './page/HeadSnippet'\n\ntype HeadComponent = (props: { children: ReactNode }) => ReactNode\ntype HeadSnippet = (props: { snippet: Snippet }) => ReactNode\ntype ImageComponent = (props: {\n src: string\n alt: string\n sizes?: string\n width?: number\n height?: number\n priority?: boolean\n fill?: boolean\n style?: CSSProperties\n}) => ReactNode\n\ntype LinkProps = Omit<ComponentPropsWithoutRef<'a'>, 'onClick'> & {\n linkType?: LinkData['type']\n onClick?: (event: MouseEvent<HTMLAnchorElement>) => unknown\n}\n\ntype LinkComponent = ForwardRefExoticComponent<RefAttributes<HTMLAnchorElement> & LinkProps>\n\nexport type FrameworkContext = {\n Head: HeadComponent\n HeadSnippet: HeadSnippet\n Image: ImageComponent\n Link: LinkComponent\n}\n\n// React 19 automatically hoists metadata tags to the <head>\nconst DefaultHead = ({ children }: PropsWithChildren) => <>{children}</>\n\nconst DefaultHeadSnippet = BaseHeadSnippet\n\nconst DefaultImage: ImageComponent = ({ priority, fill, style, ...props }) => (\n <img\n {...props}\n style={{\n ...(fill\n ? {\n height: '100%',\n width: '100%',\n objectFit: 'cover',\n }\n : {}),\n ...style,\n }}\n loading={priority ? 'eager' : 'lazy'}\n />\n)\n\nconst DefaultLink: LinkComponent = forwardRef<HTMLAnchorElement, LinkProps>(\n ({ linkType, ...props }, ref) => <a {...props} ref={ref} />,\n)\n\nconst FrameworkContext = createContext<Partial<FrameworkContext>>({})\n\nexport const FrameworkContextProvider = ({\n value,\n children,\n}: PropsWithChildren<{ value: Partial<FrameworkContext> }>) => {\n const parentContext = useContext(FrameworkContext)\n const mergedContext = useMemo(() => ({ ...parentContext, ...value }), [parentContext, value])\n\n return <FrameworkContext.Provider value={mergedContext}>{children}</FrameworkContext.Provider>\n}\n\nconst defaultContext: FrameworkContext = {\n Head: DefaultHead,\n HeadSnippet: DefaultHeadSnippet,\n Image: DefaultImage,\n Link: DefaultLink,\n}\n\nexport function useFrameworkContext(): FrameworkContext {\n return { ...defaultContext, ...useContext(FrameworkContext) }\n}\n"],"mappings":"AAgDyD;AAhDzD;AAAA,EAQE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP,SAAS,uBAAuB;AA8BhC,MAAM,cAAc,CAAC,EAAE,SAAS,MAAyB,gCAAG,UAAS;AAErE,MAAM,qBAAqB;AAE3B,MAAM,eAA+B,CAAC,EAAE,UAAU,MAAM,OAAO,GAAG,MAAM,MACtE;AAAA,EAAC;AAAA;AAAA,IACE,GAAG;AAAA,IACJ,OAAO;AAAA,MACL,GAAI,OACA;AAAA,QACE,QAAQ;AAAA,QACR,OAAO;AAAA,QACP,WAAW;AAAA,MACb,IACA,CAAC;AAAA,MACL,GAAG;AAAA,IACL;AAAA,IACA,SAAS,WAAW,UAAU;AAAA;AAChC;AAGF,MAAM,cAA6B;AAAA,EACjC,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,oBAAC,OAAG,GAAG,OAAO,KAAU;AAC3D;AAEA,MAAM,mBAAmB,cAAyC,CAAC,CAAC;AAE7D,MAAM,2BAA2B,CAAC;AAAA,EACvC;AAAA,EACA;AACF,MAA+D;AAC7D,QAAM,gBAAgB,WAAW,gBAAgB;AACjD,QAAM,gBAAgB,QAAQ,OAAO,EAAE,GAAG,eAAe,GAAG,MAAM,IAAI,CAAC,eAAe,KAAK,CAAC;AAE5F,SAAO,oBAAC,iBAAiB,UAAjB,EAA0B,OAAO,eAAgB,UAAS;AACpE;AAEA,MAAM,iBAAmC;AAAA,EACvC,MAAM;AAAA,EACN,aAAa;AAAA,EACb,OAAO;AAAA,EACP,MAAM;AACR;AAEO,SAAS,sBAAwC;AACtD,SAAO,EAAE,GAAG,gBAAgB,GAAG,WAAW,gBAAgB,EAAE;AAC9D;","names":[]}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FrameworkContext } from "../framework-context";
|
|
3
|
-
function useFrameworkContext() {
|
|
4
|
-
return useContext(FrameworkContext);
|
|
5
|
-
}
|
|
1
|
+
import { useFrameworkContext } from "../framework-context";
|
|
6
2
|
export {
|
|
7
3
|
useFrameworkContext
|
|
8
4
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/runtimes/react/components/hooks/use-framework-context.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/runtimes/react/components/hooks/use-framework-context.tsx"],"sourcesContent":["export { useFrameworkContext } from '../framework-context'\n"],"mappings":"AAAA,SAAS,2BAA2B;","names":[]}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { useControlDefs } from "../hooks/use-control-defs";
|
|
2
2
|
import { useResolvedProps } from "../hooks/use-resolved-props";
|
|
3
|
+
import { useStylesheetFactory } from "../hooks/use-stylesheet-factory";
|
|
3
4
|
import { resolveLegacyDescriptorProp } from "../legacy-controls";
|
|
4
5
|
function ResolveProps({
|
|
5
6
|
element,
|
|
6
7
|
children: renderComponent
|
|
7
8
|
}) {
|
|
8
9
|
const [legacyDescriptors, definitions] = useControlDefs({ elementType: element.type });
|
|
9
|
-
const
|
|
10
|
+
const stylesheetFactory = useStylesheetFactory();
|
|
11
|
+
const resolvedProps = useResolvedProps({
|
|
12
|
+
propDefs: definitions,
|
|
13
|
+
propData: element.props,
|
|
14
|
+
elementKey: element.key,
|
|
15
|
+
stylesheetFactory
|
|
16
|
+
});
|
|
10
17
|
const renderFn = Object.entries(legacyDescriptors).reduceRight(
|
|
11
18
|
(renderFn2, [propName, descriptor]) => (props) => resolveLegacyDescriptorProp(descriptor, propName, element.props[propName], props, renderFn2),
|
|
12
19
|
renderComponent
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/components/resolve-props.tsx"],"sourcesContent":["import { type ReactNode } from 'react'\n\nimport { type ElementData } from '../../../state/read-only-state'\n\nimport { useControlDefs } from '../hooks/use-control-defs'\nimport { useResolvedProps } from '../hooks/use-resolved-props'\n\nimport { resolveLegacyDescriptorProp } from '../legacy-controls'\n\nexport function ResolveProps({\n element,\n children: renderComponent,\n}: {\n element: ElementData\n children: (props: Record<string, unknown>) => ReactNode\n}): ReactNode {\n const [legacyDescriptors, definitions] = useControlDefs({ elementType: element.type })\n\n const resolvedProps = useResolvedProps(definitions
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/components/resolve-props.tsx"],"sourcesContent":["import { type ReactNode } from 'react'\n\nimport { type ElementData } from '../../../state/read-only-state'\n\nimport { useControlDefs } from '../hooks/use-control-defs'\nimport { useResolvedProps } from '../hooks/use-resolved-props'\nimport { useStylesheetFactory } from '../hooks/use-stylesheet-factory'\n\nimport { resolveLegacyDescriptorProp } from '../legacy-controls'\n\nexport function ResolveProps({\n element,\n children: renderComponent,\n}: {\n element: ElementData\n children: (props: Record<string, unknown>) => ReactNode\n}): ReactNode {\n const [legacyDescriptors, definitions] = useControlDefs({ elementType: element.type })\n\n const stylesheetFactory = useStylesheetFactory()\n const resolvedProps = useResolvedProps({\n propDefs: definitions,\n propData: element.props,\n elementKey: element.key,\n stylesheetFactory,\n })\n\n const renderFn = Object.entries(legacyDescriptors).reduceRight(\n (renderFn, [propName, descriptor]) =>\n props =>\n resolveLegacyDescriptorProp(descriptor, propName, element.props[propName], props, renderFn),\n renderComponent,\n )\n\n return renderFn(resolvedProps)\n}\n"],"mappings":"AAIA,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AAErC,SAAS,mCAAmC;AAErC,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA,UAAU;AACZ,GAGc;AACZ,QAAM,CAAC,mBAAmB,WAAW,IAAI,eAAe,EAAE,aAAa,QAAQ,KAAK,CAAC;AAErF,QAAM,oBAAoB,qBAAqB;AAC/C,QAAM,gBAAgB,iBAAiB;AAAA,IACrC,UAAU;AAAA,IACV,UAAU,QAAQ;AAAA,IAClB,YAAY,QAAQ;AAAA,IACpB;AAAA,EACF,CAAC;AAED,QAAM,WAAW,OAAO,QAAQ,iBAAiB,EAAE;AAAA,IACjD,CAACA,WAAU,CAAC,UAAU,UAAU,MAC9B,WACE,4BAA4B,YAAY,UAAU,QAAQ,MAAM,QAAQ,GAAG,OAAOA,SAAQ;AAAA,IAC9F;AAAA,EACF;AAEA,SAAO,SAAS,aAAa;AAC/B;","names":["renderFn"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getPropControllers } from "../../../state/read-only-state";
|
|
2
|
+
import { useDocumentKey } from "./use-document-context";
|
|
3
|
+
import { useSelector } from "./use-selector";
|
|
4
|
+
function useControlInstances(elementKey) {
|
|
5
|
+
const documentKey = useDocumentKey();
|
|
6
|
+
return useSelector((state) => {
|
|
7
|
+
if (documentKey == null)
|
|
8
|
+
return null;
|
|
9
|
+
return getPropControllers(state, { documentKey, elementKey });
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
useControlInstances
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=use-control-instances.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-control-instances.ts"],"sourcesContent":["import { ControlInstance } from '@makeswift/controls'\n\nimport { getPropControllers } from '../../../state/read-only-state'\nimport { useDocumentKey } from './use-document-context'\nimport { useSelector } from './use-selector'\n\nexport function useControlInstances(elementKey: string): Record<string, ControlInstance> | null {\n const documentKey = useDocumentKey()\n\n return useSelector(state => {\n if (documentKey == null) return null\n\n return getPropControllers(state, { documentKey, elementKey })\n })\n}\n"],"mappings":"AAEA,SAAS,0BAA0B;AACnC,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAErB,SAAS,oBAAoB,YAA4D;AAC9F,QAAM,cAAc,eAAe;AAEnC,SAAO,YAAY,WAAS;AAC1B,QAAI,eAAe;AAAM,aAAO;AAEhC,WAAO,mBAAmB,OAAO,EAAE,aAAa,WAAW,CAAC;AAAA,EAC9D,CAAC;AACH;","names":[]}
|
|
@@ -2,29 +2,22 @@ import { useMemo, useEffect, useRef, useSyncExternalStore, useCallback } from "r
|
|
|
2
2
|
import {
|
|
3
3
|
mapValues
|
|
4
4
|
} from "@makeswift/controls";
|
|
5
|
-
import * as ReactPage from "../../../state/read-only-state";
|
|
6
5
|
import { useResourceResolver } from "./use-resource-resolver";
|
|
7
|
-
import { useDocumentKey } from "./use-document-context";
|
|
8
|
-
import { useSelector } from "./use-selector";
|
|
9
|
-
import { useStylesheetFactory } from "./use-stylesheet-factory";
|
|
10
|
-
import { useResolvableRecord } from "./use-resolvable-record";
|
|
11
6
|
import { propErrorHandlingProxy } from "../utils/prop-error-handling-proxy";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
function useResolvedProps(propDefs, elementData, elementKey) {
|
|
21
|
-
const stylesheetFactory = useStylesheetFactory();
|
|
7
|
+
import { useControlInstances } from "./use-control-instances";
|
|
8
|
+
import { useResolvableRecord } from "./use-resolvable-record";
|
|
9
|
+
function useResolvedProps({
|
|
10
|
+
propDefs,
|
|
11
|
+
propData,
|
|
12
|
+
elementKey,
|
|
13
|
+
stylesheetFactory
|
|
14
|
+
}) {
|
|
22
15
|
const resourceResolver = useResourceResolver();
|
|
23
16
|
const controls = useControlInstances(elementKey);
|
|
24
17
|
const cache = useRef({}).current;
|
|
25
18
|
const resolveProp = useCallback(
|
|
26
19
|
(def, propName) => {
|
|
27
|
-
const data =
|
|
20
|
+
const data = propData[propName];
|
|
28
21
|
const control = controls?.[propName];
|
|
29
22
|
if (cache[propName] != null && data === cache[propName].data && control === cache[propName].control) {
|
|
30
23
|
return cache[propName].resolvedValue;
|
|
@@ -38,7 +31,7 @@ function useResolvedProps(propDefs, elementData, elementKey) {
|
|
|
38
31
|
cache[propName] = { data, control, resolvedValue };
|
|
39
32
|
return resolvedValue;
|
|
40
33
|
},
|
|
41
|
-
[controls,
|
|
34
|
+
[controls, propData, resourceResolver, stylesheetFactory]
|
|
42
35
|
);
|
|
43
36
|
const resolvables = useMemo(
|
|
44
37
|
() => mapValues(propDefs, (def, propName) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-resolved-props.ts"],"sourcesContent":["import { useMemo, useEffect, useRef, useSyncExternalStore, useCallback } from 'react'\nimport {\n ControlDefinition,\n ControlInstance,\n mapValues,\n type Data,\n type Resolvable,\n} from '@makeswift/controls'\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-resolved-props.ts"],"sourcesContent":["import { useMemo, useEffect, useRef, useSyncExternalStore, useCallback } from 'react'\nimport {\n ControlDefinition,\n ControlInstance,\n mapValues,\n type Data,\n type Resolvable,\n} from '@makeswift/controls'\n\nimport { useResourceResolver } from './use-resource-resolver'\n\nimport { type StylesheetFactory } from '../stylesheet-factory'\nimport { propErrorHandlingProxy } from '../utils/prop-error-handling-proxy'\n\nimport { useControlInstances } from './use-control-instances'\nimport { useResolvableRecord } from './use-resolvable-record'\n\ntype CacheItem = {\n data: Data\n control: ControlInstance | undefined\n resolvedValue: Resolvable<unknown>\n}\n\nexport function useResolvedProps({\n propDefs,\n propData,\n elementKey,\n stylesheetFactory,\n}: {\n propDefs: Record<string, ControlDefinition>\n propData: Record<string, Data>\n elementKey: string\n stylesheetFactory: StylesheetFactory\n}): Record<string, unknown> {\n const resourceResolver = useResourceResolver()\n const controls = useControlInstances(elementKey)\n\n const cache = useRef<Record<string, CacheItem>>({}).current\n const resolveProp = useCallback(\n (def: ControlDefinition, propName: string) => {\n const data = propData[propName]\n const control = controls?.[propName]\n\n if (\n cache[propName] != null &&\n data === cache[propName].data &&\n control === cache[propName].control\n ) {\n return cache[propName].resolvedValue\n }\n\n const resolvedValue = def.resolveValue(\n data,\n resourceResolver,\n stylesheetFactory.get(propName),\n control,\n )\n\n cache[propName] = { data, control, resolvedValue }\n return resolvedValue\n },\n [controls, propData, resourceResolver, stylesheetFactory],\n )\n\n const resolvables = useMemo<Record<string, Resolvable<unknown>>>(\n () =>\n mapValues(propDefs, (def, propName) => {\n const defaultValue = (def.config as any)?.defaultValue\n return propErrorHandlingProxy(resolveProp(def, propName), defaultValue, error => {\n console.warn(\n `Error reading value for prop \"${propName}\", falling back to \\`${defaultValue}\\`.`,\n { control: def, error },\n )\n })\n }),\n [propDefs, resolveProp],\n )\n\n const props = useResolvableRecord(resolvables)\n\n // no need to call `triggerResolve` on the server, all the resources should already be in\n // the host API client's cache (populated from the snapshot's cache)\n useEffect(() => {\n props.triggerResolve()\n }, [props])\n\n // the order is important here, the styles are defined in the process of the props resolution,\n // calling `useDefinedStyles` before the props are resolved would effectively be a noop\n const resolvedProps = useSyncExternalStore(props.subscribe, props.readStable, props.readStable)\n\n stylesheetFactory.useDefinedStyles()\n\n return resolvedProps\n}\n"],"mappings":"AAAA,SAAS,SAAS,WAAW,QAAQ,sBAAsB,mBAAmB;AAC9E;AAAA,EAGE;AAAA,OAGK;AAEP,SAAS,2BAA2B;AAGpC,SAAS,8BAA8B;AAEvC,SAAS,2BAA2B;AACpC,SAAS,2BAA2B;AAQ7B,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAK4B;AAC1B,QAAM,mBAAmB,oBAAoB;AAC7C,QAAM,WAAW,oBAAoB,UAAU;AAE/C,QAAM,QAAQ,OAAkC,CAAC,CAAC,EAAE;AACpD,QAAM,cAAc;AAAA,IAClB,CAAC,KAAwB,aAAqB;AAC5C,YAAM,OAAO,SAAS,QAAQ;AAC9B,YAAM,UAAU,WAAW,QAAQ;AAEnC,UACE,MAAM,QAAQ,KAAK,QACnB,SAAS,MAAM,QAAQ,EAAE,QACzB,YAAY,MAAM,QAAQ,EAAE,SAC5B;AACA,eAAO,MAAM,QAAQ,EAAE;AAAA,MACzB;AAEA,YAAM,gBAAgB,IAAI;AAAA,QACxB;AAAA,QACA;AAAA,QACA,kBAAkB,IAAI,QAAQ;AAAA,QAC9B;AAAA,MACF;AAEA,YAAM,QAAQ,IAAI,EAAE,MAAM,SAAS,cAAc;AACjD,aAAO;AAAA,IACT;AAAA,IACA,CAAC,UAAU,UAAU,kBAAkB,iBAAiB;AAAA,EAC1D;AAEA,QAAM,cAAc;AAAA,IAClB,MACE,UAAU,UAAU,CAAC,KAAK,aAAa;AACrC,YAAM,eAAgB,IAAI,QAAgB;AAC1C,aAAO,uBAAuB,YAAY,KAAK,QAAQ,GAAG,cAAc,WAAS;AAC/E,gBAAQ;AAAA,UACN,iCAAiC,QAAQ,wBAAwB,YAAY;AAAA,UAC7E,EAAE,SAAS,KAAK,MAAM;AAAA,QACxB;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,IACH,CAAC,UAAU,WAAW;AAAA,EACxB;AAEA,QAAM,QAAQ,oBAAoB,WAAW;AAI7C,YAAU,MAAM;AACd,UAAM,eAAe;AAAA,EACvB,GAAG,CAAC,KAAK,CAAC;AAIV,QAAM,gBAAgB,qBAAqB,MAAM,WAAW,MAAM,YAAY,MAAM,UAAU;AAE9F,oBAAkB,iBAAiB;AAEnC,SAAO;AACT;","names":[]}
|
|
@@ -3,12 +3,12 @@ import { serializeStyles } from "@emotion/serialize";
|
|
|
3
3
|
import {
|
|
4
4
|
isNotNil
|
|
5
5
|
} from "@makeswift/controls";
|
|
6
|
-
import { useCache } from "../root-style-registry";
|
|
7
6
|
import { resolvedStyleToCss } from "../lib/resolved-style-to-css";
|
|
7
|
+
import { pollBoxModel } from "../poll-box-model";
|
|
8
|
+
import { useCache } from "../root-style-registry";
|
|
9
|
+
import { useStyles, serializedStyleClassName } from "../use-style";
|
|
8
10
|
import { useBreakpoints } from "./use-breakpoints";
|
|
9
11
|
import { useCssId } from "./use-css-id";
|
|
10
|
-
import { useStyles, serializedStyleClassName } from "../use-style";
|
|
11
|
-
import { pollBoxModel } from "../poll-box-model";
|
|
12
12
|
function useStylesheetFactory() {
|
|
13
13
|
const breakpoints = useBreakpoints();
|
|
14
14
|
const cache = useCache();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-stylesheet-factory.ts"],"sourcesContent":["import { useMemo, useEffect, useRef } from 'react'\nimport { serializeStyles } from '@emotion/serialize'\nimport { type EmotionCache } from '@emotion/cache'\nimport { type SerializedStyles } from '@emotion/utils'\n\nimport {\n type BoxDisplayModel,\n type Breakpoints,\n type Stylesheet,\n type ResolvedStyle,\n isNotNil,\n} from '@makeswift/controls'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-stylesheet-factory.ts"],"sourcesContent":["import { useMemo, useEffect, useRef } from 'react'\nimport { serializeStyles } from '@emotion/serialize'\nimport { type EmotionCache } from '@emotion/cache'\nimport { type SerializedStyles } from '@emotion/utils'\n\nimport {\n type BoxDisplayModel,\n type Breakpoints,\n type Stylesheet,\n type ResolvedStyle,\n isNotNil,\n} from '@makeswift/controls'\n\nimport { resolvedStyleToCss } from '../lib/resolved-style-to-css'\nimport { pollBoxModel } from '../poll-box-model'\nimport { useCache } from '../root-style-registry'\nimport { type StylesheetFactory } from '../stylesheet-factory'\nimport { useStyles, serializedStyleClassName } from '../use-style'\n\nimport { useBreakpoints } from './use-breakpoints'\nimport { useCssId } from './use-css-id'\n\nexport function useStylesheetFactory(): StylesheetFactory {\n const breakpoints = useBreakpoints()\n const cache = useCache()\n const componentUid = useCssId()\n\n const computedStyles = useRef<Record<string, SerializedStyles>>({}).current\n const boxModelCallbacks = useRef<Record<string, (boxModel: BoxDisplayModel | null) => void>>(\n {},\n ).current\n\n return useMemo(() => {\n const getStylesheet = (styleSheetId: string): Stylesheet => ({\n breakpoints(): Breakpoints {\n return breakpoints\n },\n\n defineStyle(\n style: ResolvedStyle,\n onBoxModelChange?: (boxModel: BoxDisplayModel | null) => void,\n ): string {\n const serialized = serializeStyle(breakpoints, style, cache)\n const uid = `u-${componentUid}-${styleSheetId}`\n computedStyles[uid] = serialized\n\n const className = serializedStyleClassName(cache, serialized)\n if (!onBoxModelChange) return className\n\n boxModelCallbacks[uid] = onBoxModelChange\n return `${className} ${uid}`\n },\n\n child(id: string): Stylesheet {\n return getStylesheet(`${styleSheetId}-${id}`)\n },\n })\n\n return {\n get(propName: string): Stylesheet {\n return getStylesheet(propName)\n },\n\n useDefinedStyles() {\n useStyles(cache, Object.values(computedStyles))\n\n useEffect(() => {\n const unsubscribes = Object.entries(boxModelCallbacks)\n .map(([uid, callback]) =>\n callback != null\n ? pollBoxModel({\n element: document.querySelector(`.${uid}`),\n onBoxModelChange: callback,\n })\n : undefined,\n )\n .filter(isNotNil)\n\n return () => unsubscribes.forEach(fn => fn())\n }, [Object.keys(boxModelCallbacks).join(' ')])\n },\n }\n }, [breakpoints, cache, componentUid])\n}\n\nfunction serializeStyle(\n breakpoints: Breakpoints,\n style: ResolvedStyle,\n cache: EmotionCache,\n): SerializedStyles {\n const css = resolvedStyleToCss(breakpoints, style)\n return serializeStyles([css], cache.registered)\n}\n"],"mappings":"AAAA,SAAS,SAAS,WAAW,cAAc;AAC3C,SAAS,uBAAuB;AAIhC;AAAA,EAKE;AAAA,OACK;AAEP,SAAS,0BAA0B;AACnC,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AAEzB,SAAS,WAAW,gCAAgC;AAEpD,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB;AAElB,SAAS,uBAA0C;AACxD,QAAM,cAAc,eAAe;AACnC,QAAM,QAAQ,SAAS;AACvB,QAAM,eAAe,SAAS;AAE9B,QAAM,iBAAiB,OAAyC,CAAC,CAAC,EAAE;AACpE,QAAM,oBAAoB;AAAA,IACxB,CAAC;AAAA,EACH,EAAE;AAEF,SAAO,QAAQ,MAAM;AACnB,UAAM,gBAAgB,CAAC,kBAAsC;AAAA,MAC3D,cAA2B;AACzB,eAAO;AAAA,MACT;AAAA,MAEA,YACE,OACA,kBACQ;AACR,cAAM,aAAa,eAAe,aAAa,OAAO,KAAK;AAC3D,cAAM,MAAM,KAAK,YAAY,IAAI,YAAY;AAC7C,uBAAe,GAAG,IAAI;AAEtB,cAAM,YAAY,yBAAyB,OAAO,UAAU;AAC5D,YAAI,CAAC;AAAkB,iBAAO;AAE9B,0BAAkB,GAAG,IAAI;AACzB,eAAO,GAAG,SAAS,IAAI,GAAG;AAAA,MAC5B;AAAA,MAEA,MAAM,IAAwB;AAC5B,eAAO,cAAc,GAAG,YAAY,IAAI,EAAE,EAAE;AAAA,MAC9C;AAAA,IACF;AAEA,WAAO;AAAA,MACL,IAAI,UAA8B;AAChC,eAAO,cAAc,QAAQ;AAAA,MAC/B;AAAA,MAEA,mBAAmB;AACjB,kBAAU,OAAO,OAAO,OAAO,cAAc,CAAC;AAE9C,kBAAU,MAAM;AACd,gBAAM,eAAe,OAAO,QAAQ,iBAAiB,EAClD;AAAA,YAAI,CAAC,CAAC,KAAK,QAAQ,MAClB,YAAY,OACR,aAAa;AAAA,cACX,SAAS,SAAS,cAAc,IAAI,GAAG,EAAE;AAAA,cACzC,kBAAkB;AAAA,YACpB,CAAC,IACD;AAAA,UACN,EACC,OAAO,QAAQ;AAElB,iBAAO,MAAM,aAAa,QAAQ,QAAM,GAAG,CAAC;AAAA,QAC9C,GAAG,CAAC,OAAO,KAAK,iBAAiB,EAAE,KAAK,GAAG,CAAC,CAAC;AAAA,MAC/C;AAAA,IACF;AAAA,EACF,GAAG,CAAC,aAAa,OAAO,YAAY,CAAC;AACvC;AAEA,SAAS,eACP,aACA,OACA,OACkB;AAClB,QAAM,MAAM,mBAAmB,aAAa,KAAK;AACjD,SAAO,gBAAgB,CAAC,GAAG,GAAG,MAAM,UAAU;AAChD;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=stylesheet-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/testing/fixtures/index.ts"],"sourcesContent":["export * from './origins'\nexport * from './site-version'\nexport * from './
|
|
1
|
+
{"version":3,"sources":["../../../../src/testing/fixtures/index.ts"],"sourcesContent":["export * from './origins'\nexport * from './resources'\nexport * from './site-version'\nexport * from './snippet'\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/testing/fixtures/snippet.ts"],"sourcesContent":["import { type Snippet } from '../../client/page-snapshot'\n\nexport const createSnippet = ({ id, code }: { id: string; code: string }): Snippet => ({\n id,\n code,\n location: 'HEAD',\n liveEnabled: true,\n builderEnabled: true,\n cleanup: null,\n})\n"],"mappings":"AAEO,MAAM,gBAAgB,CAAC,EAAE,IAAI,KAAK,OAA8C;AAAA,EACrF;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,aAAa;AAAA,EACb,gBAAgB;AAAA,EAChB,SAAS;AACX;","names":[]}
|
|
@@ -12,10 +12,7 @@ import { toApiRequest, pipeResponseTo } from "../api-handler/node-request-respon
|
|
|
12
12
|
import { MAKESWIFT_SITE_VERSION_COOKIE, SearchParams } from "../api-handler/preview";
|
|
13
13
|
import { MakeswiftClient } from "../client";
|
|
14
14
|
import {
|
|
15
|
-
|
|
16
|
-
DefaultHead,
|
|
17
|
-
DefaultHeadSnippet,
|
|
18
|
-
DefaultImage
|
|
15
|
+
FrameworkContextProvider
|
|
19
16
|
} from "../runtimes/react/components/framework-context";
|
|
20
17
|
import { MakeswiftComponent } from "../runtimes/react/components/MakeswiftComponent";
|
|
21
18
|
import { Page } from "../runtimes/react/components/page";
|
|
@@ -32,11 +29,8 @@ import {
|
|
|
32
29
|
} from "../runtimes/react/root-style-registry";
|
|
33
30
|
import { ReactRuntime } from "../runtimes/react/react-runtime";
|
|
34
31
|
export {
|
|
35
|
-
DefaultHead,
|
|
36
|
-
DefaultHeadSnippet,
|
|
37
|
-
DefaultImage,
|
|
38
32
|
DefaultRootStyleRegistry,
|
|
39
|
-
|
|
33
|
+
FrameworkContextProvider,
|
|
40
34
|
GoogleFontLink,
|
|
41
35
|
MAKESWIFT_SITE_VERSION_COOKIE,
|
|
42
36
|
MakeswiftClient,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/unstable-framework-support/index.ts"],"sourcesContent":["export {\n type SiteVersion,\n serializeSiteVersion,\n deserializeSiteVersion,\n secondsUntilSiteVersionExpiration,\n} from '../api/site-version'\n\nexport {\n type ApiHandlerUserConfig,\n createApiHandler,\n type SitePublishedWebhookPayloadData,\n} from '../api-handler'\nexport { SET_COOKIE_HEADER, cookieSettingOptions } from '../api-handler/cookies'\nexport { REDIRECT_SEARCH_PARAM, redirectLiveHandler } from '../api-handler/handlers/redirect-live'\nexport { toApiRequest, pipeResponseTo } from '../api-handler/node-request-response'\nexport { MAKESWIFT_SITE_VERSION_COOKIE, SearchParams } from '../api-handler/preview'\n\nexport { MakeswiftClient } from '../client'\n\nexport { type BreakpointsInput as Breakpoints } from '../state/modules/breakpoints'\n\nexport {\n FrameworkContext,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/unstable-framework-support/index.ts"],"sourcesContent":["export {\n type SiteVersion,\n serializeSiteVersion,\n deserializeSiteVersion,\n secondsUntilSiteVersionExpiration,\n} from '../api/site-version'\n\nexport {\n type ApiHandlerUserConfig,\n createApiHandler,\n type SitePublishedWebhookPayloadData,\n} from '../api-handler'\nexport { SET_COOKIE_HEADER, cookieSettingOptions } from '../api-handler/cookies'\nexport { REDIRECT_SEARCH_PARAM, redirectLiveHandler } from '../api-handler/handlers/redirect-live'\nexport { toApiRequest, pipeResponseTo } from '../api-handler/node-request-response'\nexport { MAKESWIFT_SITE_VERSION_COOKIE, SearchParams } from '../api-handler/preview'\n\nexport { MakeswiftClient } from '../client'\n\nexport { type BreakpointsInput as Breakpoints } from '../state/modules/breakpoints'\n\nexport {\n type FrameworkContext,\n FrameworkContextProvider,\n} from '../runtimes/react/components/framework-context'\n\nexport { MakeswiftComponent } from '../runtimes/react/components/MakeswiftComponent'\nexport { Page } from '../runtimes/react/components/page'\nexport { RuntimeProvider } from '../runtimes/react/components/RuntimeProvider'\nexport { Slot } from '../runtimes/react/components/Slot'\n\nexport { GoogleFontLink } from '../runtimes/react/components/GoogleFontLink'\nexport { MakeswiftFonts } from '../runtimes/react/components/MakeswiftFonts'\n\nexport {\n createRootStyleCache,\n RootStyleRegistry,\n DefaultRootStyleRegistry,\n styleTagHtml,\n StyleTagSSR,\n type RootStyleProps,\n} from '../runtimes/react/root-style-registry'\n\nexport { ReactRuntime, type StoreKey } from '../runtimes/react/react-runtime'\n"],"mappings":"AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EAEE;AAAA,OAEK;AACP,SAAS,mBAAmB,4BAA4B;AACxD,SAAS,uBAAuB,2BAA2B;AAC3D,SAAS,cAAc,sBAAsB;AAC7C,SAAS,+BAA+B,oBAAoB;AAE5D,SAAS,uBAAuB;AAIhC;AAAA,EAEE;AAAA,OACK;AAEP,SAAS,0BAA0B;AACnC,SAAS,YAAY;AACrB,SAAS,uBAAuB;AAChC,SAAS,YAAY;AAErB,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAE/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEP,SAAS,oBAAmC;","names":[]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type FrameworkContext } from '../../../../runtimes/react/components/framework-context';
|
|
2
|
-
export declare const context: Pick<FrameworkContext, '
|
|
2
|
+
export declare const context: Pick<FrameworkContext, 'HeadSnippet'>;
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/next/components/framework-provider/app-router/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/next/components/framework-provider/app-router/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,yDAAyD,CAAA;AAI/F,eAAO,MAAM,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,aAAa,CAIzD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/next/components/framework-provider/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,iBAAiB,EAAW,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/next/components/framework-provider/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,iBAAiB,EAAW,MAAM,OAAO,CAAA;AAavD,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,gBAAgB,GACjB,EAAE,iBAAiB,CAAC;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,2CAYnD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework-context.test.d.ts","sourceRoot":"","sources":["../../../../../../src/runtimes/react/components/__tests__/framework-context.test.tsx"],"names":[],"mappings":"AAAA,8BAA8B"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type ReactNode, type PropsWithChildren, type CSSProperties, type ComponentPropsWithoutRef, type MouseEvent, type ForwardRefExoticComponent, type RefAttributes } from 'react';
|
|
2
2
|
import { type LinkData } from '@makeswift/prop-controllers';
|
|
3
3
|
import { type Snippet } from '../../../client';
|
|
4
|
-
import { BaseHeadSnippet } from './page/HeadSnippet';
|
|
5
4
|
type HeadComponent = (props: {
|
|
6
5
|
children: ReactNode;
|
|
7
6
|
}) => ReactNode;
|
|
@@ -29,10 +28,9 @@ export type FrameworkContext = {
|
|
|
29
28
|
Image: ImageComponent;
|
|
30
29
|
Link: LinkComponent;
|
|
31
30
|
};
|
|
32
|
-
export declare const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
export declare
|
|
36
|
-
export declare const FrameworkContext: import("react").Context<FrameworkContext>;
|
|
31
|
+
export declare const FrameworkContextProvider: ({ value, children, }: PropsWithChildren<{
|
|
32
|
+
value: Partial<FrameworkContext>;
|
|
33
|
+
}>) => import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
export declare function useFrameworkContext(): FrameworkContext;
|
|
37
35
|
export {};
|
|
38
36
|
//# sourceMappingURL=framework-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framework-context.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/components/framework-context.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"framework-context.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/components/framework-context.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAC7B,KAAK,UAAU,EACf,KAAK,yBAAyB,EAC9B,KAAK,aAAa,EAKnB,MAAM,OAAO,CAAA;AAEd,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAE3D,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAI9C,KAAK,aAAa,GAAG,CAAC,KAAK,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,KAAK,SAAS,CAAA;AAClE,KAAK,WAAW,GAAG,CAAC,KAAK,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,KAAK,SAAS,CAAA;AAC7D,KAAK,cAAc,GAAG,CAAC,KAAK,EAAE;IAC5B,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,aAAa,CAAA;CACtB,KAAK,SAAS,CAAA;AAEf,KAAK,SAAS,GAAG,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,GAAG;IAChE,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC3B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,iBAAiB,CAAC,KAAK,OAAO,CAAA;CAC5D,CAAA;AAED,KAAK,aAAa,GAAG,yBAAyB,CAAC,aAAa,CAAC,iBAAiB,CAAC,GAAG,SAAS,CAAC,CAAA;AAE5F,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,aAAa,CAAA;IACnB,WAAW,EAAE,WAAW,CAAA;IACxB,KAAK,EAAE,cAAc,CAAA;IACrB,IAAI,EAAE,aAAa,CAAA;CACpB,CAAA;AA8BD,eAAO,MAAM,wBAAwB,GAAI,sBAGtC,iBAAiB,CAAC;IAAE,KAAK,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAA;CAAE,CAAC,4CAKzD,CAAA;AASD,wBAAgB,mBAAmB,IAAI,gBAAgB,CAEtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-framework-context.d.ts","sourceRoot":"","sources":["../../../../../../src/runtimes/react/components/hooks/use-framework-context.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-framework-context.d.ts","sourceRoot":"","sources":["../../../../../../src/runtimes/react/components/hooks/use-framework-context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-props.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/components/resolve-props.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"resolve-props.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/components/resolve-props.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gCAAgC,CAAA;AAQjE,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EACP,QAAQ,EAAE,eAAe,GAC1B,EAAE;IACD,OAAO,EAAE,WAAW,CAAA;IACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,SAAS,CAAA;CACxD,GAAG,SAAS,CAmBZ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-control-instances.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/hooks/use-control-instances.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAMrD,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,IAAI,CAQ9F"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { ControlDefinition, type Data } from '@makeswift/controls';
|
|
2
|
-
|
|
2
|
+
import { type StylesheetFactory } from '../stylesheet-factory';
|
|
3
|
+
export declare function useResolvedProps({ propDefs, propData, elementKey, stylesheetFactory, }: {
|
|
4
|
+
propDefs: Record<string, ControlDefinition>;
|
|
5
|
+
propData: Record<string, Data>;
|
|
6
|
+
elementKey: string;
|
|
7
|
+
stylesheetFactory: StylesheetFactory;
|
|
8
|
+
}): Record<string, unknown>;
|
|
3
9
|
//# sourceMappingURL=use-resolved-props.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-resolved-props.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/hooks/use-resolved-props.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EAGjB,KAAK,IAAI,EAEV,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"use-resolved-props.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/hooks/use-resolved-props.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EAGjB,KAAK,IAAI,EAEV,MAAM,qBAAqB,CAAA;AAI5B,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAY9D,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,iBAAiB,GAClB,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;IAC3C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAC9B,UAAU,EAAE,MAAM,CAAA;IAClB,iBAAiB,EAAE,iBAAiB,CAAA;CACrC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA4D1B"}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export type StylesheetFactory = {
|
|
3
|
-
get(propName: string): Stylesheet;
|
|
4
|
-
useDefinedStyles(): void;
|
|
5
|
-
};
|
|
1
|
+
import { type StylesheetFactory } from '../stylesheet-factory';
|
|
6
2
|
export declare function useStylesheetFactory(): StylesheetFactory;
|
|
7
3
|
//# sourceMappingURL=use-stylesheet-factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-stylesheet-factory.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/hooks/use-stylesheet-factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-stylesheet-factory.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/hooks/use-stylesheet-factory.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAM9D,wBAAgB,oBAAoB,IAAI,iBAAiB,CA6DxD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stylesheet-factory.d.ts","sourceRoot":"","sources":["../../../../src/runtimes/react/stylesheet-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAErD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAA;IACjC,gBAAgB,IAAI,IAAI,CAAA;CACzB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/fixtures/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/fixtures/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,WAAW,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snippet.d.ts","sourceRoot":"","sources":["../../../../src/testing/fixtures/snippet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEzD,eAAO,MAAM,aAAa,GAAI,cAAc;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,KAAG,OAOzE,CAAA"}
|
|
@@ -6,7 +6,7 @@ export { toApiRequest, pipeResponseTo } from '../api-handler/node-request-respon
|
|
|
6
6
|
export { MAKESWIFT_SITE_VERSION_COOKIE, SearchParams } from '../api-handler/preview';
|
|
7
7
|
export { MakeswiftClient } from '../client';
|
|
8
8
|
export { type BreakpointsInput as Breakpoints } from '../state/modules/breakpoints';
|
|
9
|
-
export { FrameworkContext,
|
|
9
|
+
export { type FrameworkContext, FrameworkContextProvider, } from '../runtimes/react/components/framework-context';
|
|
10
10
|
export { MakeswiftComponent } from '../runtimes/react/components/MakeswiftComponent';
|
|
11
11
|
export { Page } from '../runtimes/react/components/page';
|
|
12
12
|
export { RuntimeProvider } from '../runtimes/react/components/RuntimeProvider';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/unstable-framework-support/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,iCAAiC,GAClC,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EACL,KAAK,oBAAoB,EACzB,gBAAgB,EAChB,KAAK,+BAA+B,GACrC,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAChF,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAA;AAClG,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAA;AACnF,OAAO,EAAE,6BAA6B,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAEpF,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C,OAAO,EAAE,KAAK,gBAAgB,IAAI,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAEnF,OAAO,EACL,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/unstable-framework-support/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,iCAAiC,GAClC,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EACL,KAAK,oBAAoB,EACzB,gBAAgB,EAChB,KAAK,+BAA+B,GACrC,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAChF,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAA;AAClG,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAA;AACnF,OAAO,EAAE,6BAA6B,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAEpF,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C,OAAO,EAAE,KAAK,gBAAgB,IAAI,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAEnF,OAAO,EACL,KAAK,gBAAgB,EACrB,wBAAwB,GACzB,MAAM,gDAAgD,CAAA;AAEvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iDAAiD,CAAA;AACpF,OAAO,EAAE,IAAI,EAAE,MAAM,mCAAmC,CAAA;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,8CAA8C,CAAA;AAC9E,OAAO,EAAE,IAAI,EAAE,MAAM,mCAAmC,CAAA;AAExD,OAAO,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAA;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAA;AAE5E,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,wBAAwB,EACxB,YAAY,EACZ,WAAW,EACX,KAAK,cAAc,GACpB,MAAM,uCAAuC,CAAA;AAE9C,OAAO,EAAE,YAAY,EAAE,KAAK,QAAQ,EAAE,MAAM,iCAAiC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@makeswift/runtime",
|
|
3
|
-
"version": "0.28.8-canary.
|
|
3
|
+
"version": "0.28.8-canary.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "makeswift/makeswift",
|
|
@@ -238,9 +238,9 @@
|
|
|
238
238
|
"use-sync-external-store": "^1.5.0",
|
|
239
239
|
"uuid": "^9.0.0",
|
|
240
240
|
"zod": "^3.21.4",
|
|
241
|
-
"@makeswift/controls": "0.1.
|
|
241
|
+
"@makeswift/controls": "0.1.21-canary.0",
|
|
242
242
|
"@makeswift/next-plugin": "0.6.1",
|
|
243
|
-
"@makeswift/prop-controllers": "0.4.
|
|
243
|
+
"@makeswift/prop-controllers": "0.4.15-canary.0"
|
|
244
244
|
},
|
|
245
245
|
"devDependencies": {
|
|
246
246
|
"@emotion/jest": "^11.11.0",
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var group_exports = {};
|
|
20
|
-
__export(group_exports, {
|
|
21
|
-
GroupControlValue: () => GroupControlValue
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(group_exports);
|
|
24
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
-
var import_controls = require("@makeswift/controls");
|
|
26
|
-
var import_control = require("./control");
|
|
27
|
-
function GroupControlValue({ definition, data, children, control }) {
|
|
28
|
-
return Object.entries(definition.config.props).reduceRight(
|
|
29
|
-
(renderFn, [key, controlDefinition]) => (shapeControlValue) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
30
|
-
import_control.ControlValue,
|
|
31
|
-
{
|
|
32
|
-
definition: controlDefinition,
|
|
33
|
-
data: data != null ? import_controls.GroupDefinition.propsData(data)[key] : void 0,
|
|
34
|
-
control: control?.child(key),
|
|
35
|
-
children: (value) => renderFn({ ...shapeControlValue, [key]: value })
|
|
36
|
-
}
|
|
37
|
-
),
|
|
38
|
-
children
|
|
39
|
-
)({});
|
|
40
|
-
}
|
|
41
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
-
0 && (module.exports = {
|
|
43
|
-
GroupControlValue
|
|
44
|
-
});
|
|
45
|
-
//# sourceMappingURL=group.js.map
|