@makeswift/runtime 0.28.7 → 0.28.8-canary.1
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/api-resources-client.js +47 -0
- package/dist/cjs/api/api-resources-client.js.map +1 -1
- package/dist/cjs/api/graphql-api-client.js +1 -1
- package/dist/cjs/api/host-api-resources-client.js +38 -32
- package/dist/cjs/api/host-api-resources-client.js.map +1 -1
- package/dist/cjs/api/makeswift-api-resources-client.js +84 -0
- package/dist/cjs/api/makeswift-api-resources-client.js.map +1 -0
- package/dist/cjs/api/rest-api-client.js +1 -1
- package/dist/cjs/api/rest-api-client.js.map +1 -1
- package/dist/cjs/api/types.js.map +1 -1
- package/dist/cjs/api-handler/handlers/manifest.js +1 -1
- package/dist/cjs/client/index.js +1 -1
- package/dist/cjs/runtimes/react/components/ElementData.js +2 -2
- package/dist/cjs/runtimes/react/components/ElementData.js.map +1 -1
- package/dist/cjs/runtimes/react/components/resolve-props.js +43 -0
- package/dist/cjs/runtimes/react/components/resolve-props.js.map +1 -0
- package/dist/cjs/runtimes/react/hooks/use-control-defs.js +40 -0
- package/dist/cjs/runtimes/react/hooks/use-control-defs.js.map +1 -0
- package/dist/cjs/runtimes/react/runtime-core.js +13 -0
- package/dist/cjs/runtimes/react/runtime-core.js.map +1 -1
- package/dist/cjs/state/api-client/fetch-api-resource.js +5 -47
- package/dist/cjs/state/api-client/fetch-api-resource.js.map +1 -1
- package/dist/esm/api/api-resources-client.js +47 -0
- package/dist/esm/api/api-resources-client.js.map +1 -1
- package/dist/esm/api/graphql-api-client.js +1 -1
- package/dist/esm/api/host-api-resources-client.js +38 -33
- package/dist/esm/api/host-api-resources-client.js.map +1 -1
- package/dist/esm/api/makeswift-api-resources-client.js +50 -0
- package/dist/esm/api/makeswift-api-resources-client.js.map +1 -0
- package/dist/esm/api/rest-api-client.js +1 -1
- package/dist/esm/api/rest-api-client.js.map +1 -1
- package/dist/esm/api/types.js.map +1 -1
- package/dist/esm/api-handler/handlers/manifest.js +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/runtimes/react/components/ElementData.js +1 -1
- package/dist/esm/runtimes/react/components/ElementData.js.map +1 -1
- package/dist/esm/runtimes/react/components/resolve-props.js +19 -0
- package/dist/esm/runtimes/react/components/resolve-props.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-control-defs.js +16 -0
- package/dist/esm/runtimes/react/hooks/use-control-defs.js.map +1 -0
- package/dist/esm/runtimes/react/runtime-core.js +13 -0
- package/dist/esm/runtimes/react/runtime-core.js.map +1 -1
- package/dist/esm/state/api-client/fetch-api-resource.js +5 -47
- package/dist/esm/state/api-client/fetch-api-resource.js.map +1 -1
- package/dist/types/api/api-resources-client.d.ts +18 -10
- package/dist/types/api/api-resources-client.d.ts.map +1 -1
- package/dist/types/api/host-api-resources-client.d.ts +9 -14
- package/dist/types/api/host-api-resources-client.d.ts.map +1 -1
- package/dist/types/api/makeswift-api-resources-client.d.ts +30 -0
- package/dist/types/api/makeswift-api-resources-client.d.ts.map +1 -0
- package/dist/types/api/rest-api-client.d.ts +1 -1
- package/dist/types/api/rest-api-client.d.ts.map +1 -1
- package/dist/types/api/types.d.ts +3 -0
- package/dist/types/api/types.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/resolve-props.d.ts +7 -0
- package/dist/types/runtimes/react/components/resolve-props.d.ts.map +1 -0
- package/dist/types/runtimes/react/hooks/use-control-defs.d.ts +6 -0
- package/dist/types/runtimes/react/hooks/use-control-defs.d.ts.map +1 -0
- package/dist/types/runtimes/react/runtime-core.d.ts +4 -2
- package/dist/types/runtimes/react/runtime-core.d.ts.map +1 -1
- package/dist/types/state/api-client/fetch-api-resource.d.ts +3 -4
- package/dist/types/state/api-client/fetch-api-resource.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/runtimes/react/controls.js +0 -59
- package/dist/cjs/runtimes/react/controls.js.map +0 -1
- package/dist/esm/runtimes/react/controls.js +0 -25
- package/dist/esm/runtimes/react/controls.js.map +0 -1
- package/dist/types/runtimes/react/controls.d.ts +0 -9
- package/dist/types/runtimes/react/controls.d.ts.map +0 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ControlDefinition } from '@makeswift/controls';
|
|
2
|
+
import { type LegacyDescriptor } from '../../../prop-controllers/descriptors';
|
|
3
|
+
export declare function useControlDefs({ elementType, }: {
|
|
4
|
+
elementType: string;
|
|
5
|
+
}): readonly [Record<string, LegacyDescriptor>, Record<string, ControlDefinition>];
|
|
6
|
+
//# sourceMappingURL=use-control-defs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-control-defs.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/hooks/use-control-defs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAKvD,OAAO,EAAE,KAAK,gBAAgB,EAAsB,MAAM,uCAAuC,CAAA;AAIjG,wBAAgB,cAAc,CAAC,EAC7B,WAAW,GACZ,EAAE;IACD,WAAW,EAAE,MAAM,CAAA;CACpB,GAAG,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAIjF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type SerializableReplacementContext } from '@makeswift/controls';
|
|
2
2
|
import { type HttpFetch } from '../../api/types';
|
|
3
3
|
import { type SiteVersion } from '../../api/site-version';
|
|
4
|
-
import { Breakpoints, BreakpointsInput } from '../../state/modules/breakpoints';
|
|
4
|
+
import { type Breakpoints, type BreakpointsInput } from '../../state/modules/breakpoints';
|
|
5
5
|
import { type Element, type ElementData } from '../../state/read-only-state';
|
|
6
6
|
import { type ProtoStore, type Store } from '../../state/store';
|
|
7
7
|
export type StoreKey = {
|
|
@@ -10,14 +10,16 @@ export type StoreKey = {
|
|
|
10
10
|
};
|
|
11
11
|
export declare class RuntimeCore {
|
|
12
12
|
private readonly activeStores;
|
|
13
|
+
private readonly apiKey;
|
|
13
14
|
readonly protoStore: ProtoStore;
|
|
14
15
|
readonly appOrigin: string;
|
|
15
16
|
readonly apiOrigin: string;
|
|
16
17
|
readonly requestKey: StoreKey | undefined;
|
|
17
18
|
readonly fetch: HttpFetch;
|
|
18
|
-
constructor({ appOrigin, apiOrigin, breakpoints, requestKey, fetch, }: {
|
|
19
|
+
constructor({ appOrigin, apiOrigin, apiKey, breakpoints, requestKey, fetch, }: {
|
|
19
20
|
appOrigin?: string;
|
|
20
21
|
apiOrigin?: string;
|
|
22
|
+
apiKey?: string;
|
|
21
23
|
breakpoints?: BreakpointsInput;
|
|
22
24
|
requestKey?: StoreKey;
|
|
23
25
|
fetch: HttpFetch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-core.d.ts","sourceRoot":"","sources":["../../../../src/runtimes/react/runtime-core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,8BAA8B,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"runtime-core.d.ts","sourceRoot":"","sources":["../../../../src/runtimes/react/runtime-core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,8BAA8B,EAAE,MAAM,qBAAqB,CAAA;AAKzE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEzD,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,gBAAgB,EAEtB,MAAM,iCAAiC,CAAA;AAIxC,OAAO,EAAkB,KAAK,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC5F,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,KAAK,EACX,MAAM,mBAAmB,CAAA;AAK1B,MAAM,MAAM,QAAQ,GAAG;IACrB,WAAW,EAAE,WAAW,GAAG,IAAI,CAAA;IAC/B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;CAC3B,CAAA;AAID,qBAAa,WAAW;IAKtB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAM3B;IAEF,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;IAE3C,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAA;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,UAAU,EAAE,QAAQ,GAAG,SAAS,CAAA;IACzC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;gBAEb,EACV,SAAuC,EACvC,SAAuC,EACvC,MAAM,EACN,WAAW,EACX,UAAU,EACV,KAAK,GACN,EAAE;QACD,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,WAAW,CAAC,EAAE,gBAAgB,CAAA;QAC9B,UAAU,CAAC,EAAE,QAAQ,CAAA;QACrB,KAAK,EAAE,SAAS,CAAA;KACjB;IAaD,gBAAgB,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,QAAQ,GAAG,KAAK;IA+B1D,WAAW,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI;IAalE,YAAY,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI;IAanE,eAAe,CACb,WAAW,EAAE,WAAW,EACxB,kBAAkB,EAAE,8BAA8B,GACjD,OAAO;IAIV,cAAc,IAAI,WAAW;IAI7B,IAAI,kBAAkB,IAAI,MAAM,CAE/B;IAED,OAAO,CAAC,wBAAwB;IAoBhC,OAAO,CAAC,wBAAwB;CAKjC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { type ThunkAction } from '@reduxjs/toolkit';
|
|
2
|
+
import { type SiteVersion } from '../../api/site-version';
|
|
2
3
|
import { type Action } from '../actions';
|
|
3
|
-
import { APIResourceType, type
|
|
4
|
+
import { APIResourceType, type APIResourceByType, type APIResourceLocale } from '../../api/types';
|
|
4
5
|
import { type State } from './state';
|
|
5
6
|
type Thunk<ReturnType> = ThunkAction<ReturnType, State, unknown, Action>;
|
|
6
|
-
export declare function fetchAPIResource<T extends APIResourceType>(resourceType: T, resourceId: string,
|
|
7
|
-
__typename: T;
|
|
8
|
-
}> | null>>;
|
|
7
|
+
export declare function fetchAPIResource<T extends APIResourceType>(resourceType: T, resourceId: string, fetchResource: (resourceId: string, version: SiteVersion | null, locale?: APIResourceLocale<T>) => Promise<APIResourceByType<T> | null>, locale?: APIResourceLocale<T>): Thunk<Promise<APIResourceByType<T> | null>>;
|
|
9
8
|
export {};
|
|
10
9
|
//# sourceMappingURL=fetch-api-resource.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-api-resource.d.ts","sourceRoot":"","sources":["../../../../src/state/api-client/fetch-api-resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"fetch-api-resource.d.ts","sourceRoot":"","sources":["../../../../src/state/api-client/fetch-api-resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAIzD,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,YAAY,CAAA;AAIxC,OAAO,EACL,eAAe,EAEf,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACvB,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAAE,KAAK,KAAK,EAA6D,MAAM,SAAS,CAAA;AAE/F,KAAK,KAAK,CAAC,UAAU,IAAI,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;AAExE,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,eAAe,EACxD,YAAY,EAAE,CAAC,EACf,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,CACb,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,WAAW,GAAG,IAAI,EAC3B,MAAM,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,KAC1B,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,EACzC,MAAM,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC5B,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAmD7C"}
|
package/package.json
CHANGED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var controls_exports = {};
|
|
30
|
-
__export(controls_exports, {
|
|
31
|
-
ResolveProps: () => ResolveProps
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(controls_exports);
|
|
34
|
-
var import_react = require("react");
|
|
35
|
-
var import_partition = require("../../utils/partition");
|
|
36
|
-
var State = __toESM(require("../../state/read-only-state"));
|
|
37
|
-
var import_descriptors = require("../../prop-controllers/descriptors");
|
|
38
|
-
var import_use_store = require("./hooks/use-store");
|
|
39
|
-
var import_legacy_controls = require("./legacy-controls");
|
|
40
|
-
var import_use_resolved_props = require("./hooks/use-resolved-props");
|
|
41
|
-
function useControlDefs(elementType) {
|
|
42
|
-
const store = (0, import_use_store.useStore)();
|
|
43
|
-
const all = State.getComponentPropControllerDescriptors(store.getState(), elementType) ?? {};
|
|
44
|
-
return (0, import_react.useRef)((0, import_partition.partitionRecord)(all, import_descriptors.isLegacyDescriptor)).current;
|
|
45
|
-
}
|
|
46
|
-
function ResolveProps({ element, children: renderComponent }) {
|
|
47
|
-
const [legacyDescriptors, definitions] = useControlDefs(element.type);
|
|
48
|
-
const resolvedProps = (0, import_use_resolved_props.useResolvedProps)(definitions, element.props, element.key);
|
|
49
|
-
const renderFn = Object.entries(legacyDescriptors).reduceRight(
|
|
50
|
-
(renderFn2, [propName, descriptor]) => (props) => (0, import_legacy_controls.resolveLegacyDescriptorProp)(descriptor, propName, element.props[propName], props, renderFn2),
|
|
51
|
-
renderComponent
|
|
52
|
-
);
|
|
53
|
-
return renderFn(resolvedProps);
|
|
54
|
-
}
|
|
55
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
-
0 && (module.exports = {
|
|
57
|
-
ResolveProps
|
|
58
|
-
});
|
|
59
|
-
//# sourceMappingURL=controls.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/runtimes/react/controls.tsx"],"sourcesContent":["import { useRef, ReactNode } from 'react'\n\nimport { ControlDefinition } from '@makeswift/controls'\n\nimport { partitionRecord } from '../../utils/partition'\n\nimport * as State from '../../state/read-only-state'\nimport { isLegacyDescriptor, LegacyDescriptor } from '../../prop-controllers/descriptors'\n\nimport { useStore } from './hooks/use-store'\n\nimport { resolveLegacyDescriptorProp } from './legacy-controls'\nimport { useResolvedProps } from './hooks/use-resolved-props'\n\ntype PropsValueProps = {\n element: State.ElementData\n children(props: Record<string, unknown>): ReactNode\n}\n\nfunction useControlDefs(\n elementType: string,\n): readonly [Record<string, LegacyDescriptor>, Record<string, ControlDefinition>] {\n const store = useStore()\n const all = State.getComponentPropControllerDescriptors(store.getState(), elementType) ?? {}\n return useRef(partitionRecord(all, isLegacyDescriptor)).current\n}\n\nexport function ResolveProps({ element, children: renderComponent }: PropsValueProps): ReactNode {\n const [legacyDescriptors, definitions] = useControlDefs(element.type)\n\n const resolvedProps = useResolvedProps(definitions, element.props, element.key)\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkC;AAIlC,uBAAgC;AAEhC,YAAuB;AACvB,yBAAqD;AAErD,uBAAyB;AAEzB,6BAA4C;AAC5C,gCAAiC;AAOjC,SAAS,eACP,aACgF;AAChF,QAAM,YAAQ,2BAAS;AACvB,QAAM,MAAM,MAAM,sCAAsC,MAAM,SAAS,GAAG,WAAW,KAAK,CAAC;AAC3F,aAAO,yBAAO,kCAAgB,KAAK,qCAAkB,CAAC,EAAE;AAC1D;AAEO,SAAS,aAAa,EAAE,SAAS,UAAU,gBAAgB,GAA+B;AAC/F,QAAM,CAAC,mBAAmB,WAAW,IAAI,eAAe,QAAQ,IAAI;AAEpE,QAAM,oBAAgB,4CAAiB,aAAa,QAAQ,OAAO,QAAQ,GAAG;AAE9E,QAAM,WAAW,OAAO,QAAQ,iBAAiB,EAAE;AAAA,IACjD,CAACA,WAAU,CAAC,UAAU,UAAU,MAC9B,eACE,oDAA4B,YAAY,UAAU,QAAQ,MAAM,QAAQ,GAAG,OAAOA,SAAQ;AAAA,IAC9F;AAAA,EACF;AAEA,SAAO,SAAS,aAAa;AAC/B;","names":["renderFn"]}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { useRef } from "react";
|
|
2
|
-
import { partitionRecord } from "../../utils/partition";
|
|
3
|
-
import * as State from "../../state/read-only-state";
|
|
4
|
-
import { isLegacyDescriptor } from "../../prop-controllers/descriptors";
|
|
5
|
-
import { useStore } from "./hooks/use-store";
|
|
6
|
-
import { resolveLegacyDescriptorProp } from "./legacy-controls";
|
|
7
|
-
import { useResolvedProps } from "./hooks/use-resolved-props";
|
|
8
|
-
function useControlDefs(elementType) {
|
|
9
|
-
const store = useStore();
|
|
10
|
-
const all = State.getComponentPropControllerDescriptors(store.getState(), elementType) ?? {};
|
|
11
|
-
return useRef(partitionRecord(all, isLegacyDescriptor)).current;
|
|
12
|
-
}
|
|
13
|
-
function ResolveProps({ element, children: renderComponent }) {
|
|
14
|
-
const [legacyDescriptors, definitions] = useControlDefs(element.type);
|
|
15
|
-
const resolvedProps = useResolvedProps(definitions, element.props, element.key);
|
|
16
|
-
const renderFn = Object.entries(legacyDescriptors).reduceRight(
|
|
17
|
-
(renderFn2, [propName, descriptor]) => (props) => resolveLegacyDescriptorProp(descriptor, propName, element.props[propName], props, renderFn2),
|
|
18
|
-
renderComponent
|
|
19
|
-
);
|
|
20
|
-
return renderFn(resolvedProps);
|
|
21
|
-
}
|
|
22
|
-
export {
|
|
23
|
-
ResolveProps
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=controls.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/runtimes/react/controls.tsx"],"sourcesContent":["import { useRef, ReactNode } from 'react'\n\nimport { ControlDefinition } from '@makeswift/controls'\n\nimport { partitionRecord } from '../../utils/partition'\n\nimport * as State from '../../state/read-only-state'\nimport { isLegacyDescriptor, LegacyDescriptor } from '../../prop-controllers/descriptors'\n\nimport { useStore } from './hooks/use-store'\n\nimport { resolveLegacyDescriptorProp } from './legacy-controls'\nimport { useResolvedProps } from './hooks/use-resolved-props'\n\ntype PropsValueProps = {\n element: State.ElementData\n children(props: Record<string, unknown>): ReactNode\n}\n\nfunction useControlDefs(\n elementType: string,\n): readonly [Record<string, LegacyDescriptor>, Record<string, ControlDefinition>] {\n const store = useStore()\n const all = State.getComponentPropControllerDescriptors(store.getState(), elementType) ?? {}\n return useRef(partitionRecord(all, isLegacyDescriptor)).current\n}\n\nexport function ResolveProps({ element, children: renderComponent }: PropsValueProps): ReactNode {\n const [legacyDescriptors, definitions] = useControlDefs(element.type)\n\n const resolvedProps = useResolvedProps(definitions, element.props, element.key)\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":"AAAA,SAAS,cAAyB;AAIlC,SAAS,uBAAuB;AAEhC,YAAY,WAAW;AACvB,SAAS,0BAA4C;AAErD,SAAS,gBAAgB;AAEzB,SAAS,mCAAmC;AAC5C,SAAS,wBAAwB;AAOjC,SAAS,eACP,aACgF;AAChF,QAAM,QAAQ,SAAS;AACvB,QAAM,MAAM,MAAM,sCAAsC,MAAM,SAAS,GAAG,WAAW,KAAK,CAAC;AAC3F,SAAO,OAAO,gBAAgB,KAAK,kBAAkB,CAAC,EAAE;AAC1D;AAEO,SAAS,aAAa,EAAE,SAAS,UAAU,gBAAgB,GAA+B;AAC/F,QAAM,CAAC,mBAAmB,WAAW,IAAI,eAAe,QAAQ,IAAI;AAEpE,QAAM,gBAAgB,iBAAiB,aAAa,QAAQ,OAAO,QAAQ,GAAG;AAE9E,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"]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import * as State from '../../state/read-only-state';
|
|
3
|
-
type PropsValueProps = {
|
|
4
|
-
element: State.ElementData;
|
|
5
|
-
children(props: Record<string, unknown>): ReactNode;
|
|
6
|
-
};
|
|
7
|
-
export declare function ResolveProps({ element, children: renderComponent }: PropsValueProps): ReactNode;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=controls.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"controls.d.ts","sourceRoot":"","sources":["../../../../src/runtimes/react/controls.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAU,SAAS,EAAE,MAAM,OAAO,CAAA;AAMzC,OAAO,KAAK,KAAK,MAAM,6BAA6B,CAAA;AAQpD,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,KAAK,CAAC,WAAW,CAAA;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;CACpD,CAAA;AAUD,wBAAgB,YAAY,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,EAAE,eAAe,GAAG,SAAS,CAa/F"}
|