@common-stack/components-pro 7.1.1-alpha.0 → 7.1.1-alpha.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/lib/index.js +1 -1
- package/lib/plugin/context.d.ts +7 -0
- package/lib/plugin/context.js +1 -0
- package/lib/plugin/context.js.map +1 -0
- package/lib/plugin/dynamic-render.d.ts +1 -4
- package/lib/plugin/dynamic-render.js +16 -29
- package/lib/plugin/dynamic-render.js.map +1 -1
- package/lib/plugin/index.d.ts +2 -1
- package/lib/plugin/loader.d.ts +6 -0
- package/lib/plugin/loader.js +20 -0
- package/lib/plugin/loader.js.map +1 -0
- package/lib/plugin/plugin-render.d.ts +9 -10
- package/lib/plugin/plugin-render.js +21 -24
- package/lib/plugin/plugin-render.js.map +1 -1
- package/lib/plugin/provider.d.ts +6 -0
- package/lib/plugin/provider.js +4 -0
- package/lib/plugin/provider.js.map +1 -0
- package/lib/slot-fill/__tests__/filler-slot.test.d.ts +1 -1
- package/lib/slot-fill/__tests__/slot-features.test.d.ts +1 -1
- package/lib/slot-fill/__tests__/slot-fill-provider.test.d.ts +1 -0
- package/lib/slot-fill/base/context.js +2 -4
- package/lib/slot-fill/base/context.js.map +1 -1
- package/lib/slot-fill/base/provider.d.ts +0 -3
- package/lib/slot-fill/base/provider.js +1 -37
- package/lib/slot-fill/base/provider.js.map +1 -1
- package/lib/slot-fill/base/slot.js +76 -53
- package/lib/slot-fill/base/slot.js.map +1 -1
- package/lib/slot-fill/interfaces/index.d.ts +4 -6
- package/lib/slot-fill/utils/index.js +9 -0
- package/lib/slot-fill/utils/index.js.map +1 -0
- package/lib/slot-fill/utils/isEmptyElement.d.ts +1 -1
- package/lib/slot-fill/utils/isEmptyElement.js +18 -0
- package/lib/slot-fill/utils/isEmptyElement.js.map +1 -0
- package/package.json +5 -5
- package/lib/plugin/reset-rendered-fills.d.ts +0 -2
- package/lib/plugin/reset-rendered-fills.js +0 -4
- package/lib/plugin/reset-rendered-fills.js.map +0 -1
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{Fill,Slot,Provider as SlotFillProvider,createSlotFill}from'./slot-fill/index.js';export{removeUniversalPortals}from'./slot-fill/utils/removeUniversalPortals.js';export{
|
|
1
|
+
export{Fill,Slot,Provider as SlotFillProvider,createSlotFill}from'./slot-fill/index.js';export{removeUniversalPortals}from'./slot-fill/utils/removeUniversalPortals.js';export{default as FillRenderProvider}from'./plugin/provider.js';export{PluginsLoader}from'./plugin/loader.js';export{default as __experimentalUseSlot}from'./slot-fill/bubbles-virtually/use-slot.js';//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ILoadedPlugin } from '../slot-fill/interfaces';
|
|
3
|
+
export interface IFillRenderContext {
|
|
4
|
+
loadedPlugins: ILoadedPlugin[];
|
|
5
|
+
}
|
|
6
|
+
declare const FillRenderContext: React.Context<IFillRenderContext>;
|
|
7
|
+
export default FillRenderContext;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as React from'react';const FillRenderContext = React.createContext(null);export{FillRenderContext as default};//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sources":["../../src/plugin/context.tsx"],"sourcesContent":[null],"names":[],"mappings":"4BAOM,MAAA,iBAAiB,GAAG,KAAK,CAAC,aAAa,CAA4B,IAAI"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export declare const DynamicRender: ({ renderImporter,
|
|
2
|
+
export declare const DynamicRender: ({ renderImporter, ...props }: {
|
|
3
3
|
[x: string]: any;
|
|
4
4
|
renderImporter: any;
|
|
5
|
-
registerPluginData: any;
|
|
6
|
-
loadPluginData: any;
|
|
7
|
-
loaderContext: any;
|
|
8
5
|
}) => React.JSX.Element;
|
|
@@ -1,32 +1,19 @@
|
|
|
1
|
-
import React__default,{
|
|
2
|
-
|
|
1
|
+
import React__default,{useState,useEffect}from'react';const DynamicRender = ({ renderImporter, ...props }) => {
|
|
2
|
+
const [Component, setComponent] = useState(null);
|
|
3
|
+
useEffect(() => {
|
|
4
|
+
if (renderImporter) {
|
|
5
|
+
renderImporter()
|
|
6
|
+
.then((module) => {
|
|
7
|
+
const ImportedComponent = module.default;
|
|
8
|
+
setComponent(() => ImportedComponent);
|
|
9
|
+
})
|
|
10
|
+
.catch((error) => {
|
|
11
|
+
console.error(`Failed to load component from ${renderImporter}:`, error);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}, [renderImporter]);
|
|
15
|
+
if (!Component) {
|
|
3
16
|
return React__default.createElement(React__default.Fragment, null);
|
|
4
17
|
}
|
|
5
|
-
|
|
6
|
-
const LazyComponent = lazy(async () => {
|
|
7
|
-
try {
|
|
8
|
-
const module = await renderImporter();
|
|
9
|
-
let loaderData = {};
|
|
10
|
-
if (module.loader && typeof module.loader === 'function') {
|
|
11
|
-
if (typeof window === 'undefined' && loaderContext) {
|
|
12
|
-
loaderData = await module.loader(loaderContext);
|
|
13
|
-
registerPluginData(loaderData);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
loaderData = loadPluginData();
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
// Create a wrapper component that includes the loader data
|
|
20
|
-
const WrappedComponent = (componentProps) => {
|
|
21
|
-
return React__default.createElement(module.default, { ...componentProps, loaderData: loaderData });
|
|
22
|
-
};
|
|
23
|
-
return { default: WrappedComponent };
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
console.error(`Failed to load component from ${renderImporter}:`, error);
|
|
27
|
-
return { default: () => React__default.createElement(React__default.Fragment, null) };
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
return (React__default.createElement(Suspense, { fallback: React__default.createElement(React__default.Fragment, null) },
|
|
31
|
-
React__default.createElement(LazyComponent, { ...props })));
|
|
18
|
+
return React__default.createElement(Component, { ...props });
|
|
32
19
|
};export{DynamicRender};//# sourceMappingURL=dynamic-render.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-render.js","sources":["../../src/plugin/dynamic-render.tsx"],"sourcesContent":[null],"names":["React"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dynamic-render.js","sources":["../../src/plugin/dynamic-render.tsx"],"sourcesContent":[null],"names":["React"],"mappings":"sDAEO,MAAM,aAAa,GAAG,CAAC,EAAE,cAAc,EAAE,GAAG,KAAK,EAAE,KAAI;IAC1D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAkB,IAAI,CAAC,CAAC;IAElE,SAAS,CAAC,MAAK;QACX,IAAI,cAAc,EAAE;AAChB,YAAA,cAAc,EAAE;AACX,iBAAA,IAAI,CAAC,CAAC,MAAM,KAAI;AACb,gBAAA,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC;AACzC,gBAAA,YAAY,CAAC,MAAM,iBAAiB,CAAC,CAAC;AAC1C,aAAC,CAAC;AACD,iBAAA,KAAK,CAAC,CAAC,KAAK,KAAI;gBACb,OAAO,CAAC,KAAK,CAAC,CAAA,8BAAA,EAAiC,cAAc,CAAG,CAAA,CAAA,EAAE,KAAK,CAAC,CAAC;AAC7E,aAAC,CAAC,CAAC;SACV;AACL,KAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;IAErB,IAAI,CAAC,SAAS,EAAE;AACZ,QAAA,OAAOA,2DAAK,CAAC;KAChB;AAED,IAAA,OAAOA,cAAC,CAAA,aAAA,CAAA,SAAS,EAAK,EAAA,GAAA,KAAK,GAAI,CAAC;AACpC"}
|
package/lib/plugin/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { default as FillRenderProvider } from './provider';
|
|
2
|
+
export { PluginsLoader } from './loader';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
async function PluginsLoader(plugins, loaderContext) {
|
|
2
|
+
const loadedPlugins = await Promise.all(plugins.map(async (plugin) => {
|
|
3
|
+
try {
|
|
4
|
+
if (plugin.renderImporter) {
|
|
5
|
+
const module = await plugin.renderImporter();
|
|
6
|
+
const ImportedComponent = module.default;
|
|
7
|
+
// if (module.loader && typeof module.loader === 'function') {
|
|
8
|
+
// const loaderData = await module.loader(loaderContext);
|
|
9
|
+
// return { ...plugin, Component: ImportedComponent, loaderData };
|
|
10
|
+
// }
|
|
11
|
+
return { ...plugin, Component: ImportedComponent };
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
console.error('Error in PluginsLoader', error);
|
|
16
|
+
}
|
|
17
|
+
return plugin;
|
|
18
|
+
}));
|
|
19
|
+
return loadedPlugins;
|
|
20
|
+
}export{PluginsLoader};//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sources":["../../src/plugin/loader.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEO,eAAe,aAAa,CAC/B,OAAc,EACd,aAAsF,EAAA;AAEtF,IAAA,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,GAAG,CACnC,OAAO,CAAC,GAAG,CAAC,OAAO,MAAW,KAAI;AAC9B,QAAA,IAAI;AACA,YAAA,IAAI,MAAM,CAAC,cAAc,EAAE;AACvB,gBAAA,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,cAAc,EAAE,CAAC;AAC7C,gBAAA,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC;;;;;gBAMzC,OAAO,EAAE,GAAG,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;aACtD;SACJ;QAAC,OAAO,KAAK,EAAE;AACZ,YAAA,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;SAClD;AACD,QAAA,OAAO,MAAM,CAAC;KACjB,CAAC,CACL,CAAC;AACF,IAAA,OAAO,aAAa,CAAC;AACzB"}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
3
|
-
interface
|
|
4
|
-
|
|
5
|
-
[key: string]: any;
|
|
6
|
-
}
|
|
7
|
-
export declare const ChildrenRender: React.FC<ChildrenRenderProps>;
|
|
8
|
-
interface PluginRenderProps extends Partial<IProviderState> {
|
|
9
|
-
fills: IExtendedFill[];
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ILoadedPlugin, Name } from '../slot-fill/interfaces';
|
|
3
|
+
interface IPluginRenderProps {
|
|
4
|
+
fills: ILoadedPlugin[];
|
|
10
5
|
name: Name;
|
|
11
6
|
[key: string]: any;
|
|
12
7
|
}
|
|
13
|
-
export declare const
|
|
8
|
+
export declare const ChildrenRender: ({ children, ...props }: {
|
|
9
|
+
[x: string]: any;
|
|
10
|
+
children: any;
|
|
11
|
+
}) => React.JSX.Element;
|
|
12
|
+
export declare const PluginRender: (props: IPluginRenderProps) => React.JSX.Element;
|
|
14
13
|
export {};
|
|
@@ -1,47 +1,44 @@
|
|
|
1
|
-
import React__default,{
|
|
2
|
-
|
|
3
|
-
if (typeof children === 'function') {
|
|
4
|
-
return children(props);
|
|
5
|
-
}
|
|
6
|
-
return children;
|
|
7
|
-
};
|
|
8
|
-
return React__default.createElement(React__default.Fragment, null, renderChildren(props));
|
|
1
|
+
import React__default,{useContext}from'react';import {DynamicRender}from'./dynamic-render.js';import {isFunction}from'../slot-fill/utils/index.js';import FillRenderContext from'./context.js';const ChildrenRender = ({ children, ...props }) => {
|
|
2
|
+
return React__default.createElement(React__default.Fragment, null, isFunction(children) ? children(props) : children);
|
|
9
3
|
};
|
|
10
4
|
const PluginRender = (props) => {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
5
|
+
const context = useContext(FillRenderContext);
|
|
6
|
+
if (!context?.loadedPlugins) {
|
|
7
|
+
throw new Error('PluginRender must be used within a FillRenderContext.Provider');
|
|
8
|
+
}
|
|
9
|
+
const FillRender = ({ fill, ...props }) => {
|
|
10
|
+
const plugin = context.loadedPlugins.find((plugin) => plugin.index === fill.index);
|
|
11
|
+
const loaderData = plugin?.loaderData || {};
|
|
12
|
+
if (plugin?.Component) {
|
|
13
|
+
return React__default.createElement(plugin.Component, { ...props, loaderData: loaderData });
|
|
14
|
+
}
|
|
15
|
+
else if (fill.renderImporter) {
|
|
16
|
+
return React__default.createElement(DynamicRender, { ...props, renderImporter: fill.renderImporter, loaderData: loaderData });
|
|
21
17
|
}
|
|
22
|
-
else if (
|
|
18
|
+
else if (plugin?.render) {
|
|
23
19
|
let children = null;
|
|
24
20
|
try {
|
|
25
|
-
const FillComponent =
|
|
21
|
+
const FillComponent = plugin.render(props);
|
|
26
22
|
if (React__default.isValidElement(FillComponent)) {
|
|
27
|
-
|
|
23
|
+
const element = FillComponent;
|
|
24
|
+
children = element.props?.children;
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
27
|
catch (error) {
|
|
31
28
|
console.error('Error in PluginRender', error);
|
|
32
29
|
}
|
|
33
30
|
if (children) {
|
|
34
|
-
return React__default.createElement(ChildrenRender, { ...
|
|
31
|
+
return React__default.createElement(ChildrenRender, { ...props, children: children });
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
34
|
else if (fill.children) {
|
|
38
|
-
return React__default.createElement(ChildrenRender, { ...
|
|
35
|
+
return React__default.createElement(ChildrenRender, { ...props, children: fill.children });
|
|
39
36
|
}
|
|
40
37
|
return React__default.createElement(React__default.Fragment, null);
|
|
41
38
|
};
|
|
42
39
|
return (React__default.createElement(React__default.Fragment, null, props.fills.map((fill, i) => {
|
|
43
40
|
if (typeof window === 'undefined') {
|
|
44
|
-
return (React__default.createElement("div", { key: i, "data-slot-name": `slot-${
|
|
41
|
+
return (React__default.createElement("div", { key: i, "data-slot-name": `slot-${props.name}` },
|
|
45
42
|
React__default.createElement(FillRender, { fill: fill, ...props })));
|
|
46
43
|
}
|
|
47
44
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-render.js","sources":["../../src/plugin/plugin-render.tsx"],"sourcesContent":[null],"names":["React"],"mappings":"+
|
|
1
|
+
{"version":3,"file":"plugin-render.js","sources":["../../src/plugin/plugin-render.tsx"],"sourcesContent":[null],"names":["React"],"mappings":"+LAiBO,MAAM,cAAc,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,KAAI;AACrD,IAAA,OAAOA,4DAAG,UAAU,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAI,CAAC;AACpE,EAAE;AAEW,MAAA,YAAY,GAAG,CAAC,KAAyB,KAAI;AACtD,IAAA,MAAM,OAAO,GAAG,UAAU,CAAqB,iBAAiB,CAAC,CAAC;AAClE,IAAA,IAAI,CAAC,OAAO,EAAE,aAAa,EAAE;AACzB,QAAA,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;KACpF;IAED,MAAM,UAAU,GAAG,CAAC,EAAE,IAAI,EAAE,GAAG,KAAK,EAAmB,KAAI;QACvD,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC;AACnF,QAAA,MAAM,UAAU,GAAG,MAAM,EAAE,UAAU,IAAI,EAAE,CAAC;AAE5C,QAAA,IAAI,MAAM,EAAE,SAAS,EAAE;YACnB,OAAOA,cAAA,CAAA,aAAA,CAAC,MAAM,CAAC,SAAS,EAAA,EAAA,GAAK,KAAK,EAAE,UAAU,EAAE,UAAU,EAAA,CAAI,CAAC;SAClE;AAAM,aAAA,IAAI,IAAI,CAAC,cAAc,EAAE;AAC5B,YAAA,OAAOA,cAAC,CAAA,aAAA,CAAA,aAAa,EAAK,EAAA,G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;gBAC7CA,cAAC,CAAA,aAAA,CAAA,UAAU,EAAC,EAAA,IAAI,EAAE,IAAI,KAAM,KAAK,EAAA,CAAI,CACnC,EACR;SACL;aAAM;AACH,YAAA,OAAOA,cAAC,CAAA,aAAA,CAAA,UAAU,EAAC,EAAA,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAM,GAAA,KAAK,GAAI,CAAC;SACxD;KACJ,CAAC,CACH,EACL;AACN"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React__default from'react';import {useLoaderData}from'@remix-run/react';import FillRenderContext from'./context.js';const FillRenderProvider = ({ children }) => {
|
|
2
|
+
const { loadedPlugins } = useLoaderData();
|
|
3
|
+
return React__default.createElement(FillRenderContext.Provider, { value: { loadedPlugins } }, children);
|
|
4
|
+
};export{FillRenderProvider as default};//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sources":["../../src/plugin/provider.tsx"],"sourcesContent":[null],"names":["React"],"mappings":"2HAQA,MAAM,kBAAkB,GAAsC,CAAC,EAAE,QAAQ,EAAE,KAAI;AAC3E,IAAA,MAAM,EAAE,aAAa,EAAE,GAAQ,aAAa,EAAE,CAAC;AAE/C,IAAA,OAAOA,cAAC,CAAA,aAAA,CAAA,iBAAiB,CAAC,QAAQ,EAAC,EAAA,KAAK,EAAE,EAAE,aAAa,EAAE,EAAG,EAAA,QAAQ,CAA8B,CAAC;AACzG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import 'jest';
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import 'jest';
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import*as React from'react';const SlotFillContext = React.createContext({
|
|
2
|
+
// need to add default value otherwise it will fail
|
|
2
3
|
registerSlot: () => { },
|
|
3
4
|
unregisterSlot: () => { },
|
|
4
5
|
registerFill: () => { },
|
|
5
6
|
unregisterFill: () => { },
|
|
6
7
|
getSlot: () => ({}),
|
|
7
|
-
getFills: () =>
|
|
8
|
+
getFills: () => [],
|
|
8
9
|
hasFills: () => false,
|
|
9
10
|
subscribe: () => { },
|
|
10
|
-
registerRenderedFill: () => { },
|
|
11
|
-
loadRenderedFill: () => { },
|
|
12
|
-
loaderContext: null,
|
|
13
11
|
});
|
|
14
12
|
const { Provider, Consumer } = SlotFillContext;export{Consumer,Provider,SlotFillContext as default};//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sources":["../../../src/slot-fill/base/context.tsx"],"sourcesContent":[null],"names":[],"mappings":"4BAGA,MAAM,eAAe,GAAG,KAAK,CAAC,aAAa,CAAkB
|
|
1
|
+
{"version":3,"file":"context.js","sources":["../../../src/slot-fill/base/context.tsx"],"sourcesContent":[null],"names":[],"mappings":"4BAGA,MAAM,eAAe,GAAG,KAAK,CAAC,aAAa,CAAkB;;AAEzD,IAAA,YAAY,EAAE,MAAK,GAAG;AACtB,IAAA,cAAc,EAAE,MAAK,GAAG;AACxB,IAAA,YAAY,EAAE,MAAK,GAAG;AACtB,IAAA,cAAc,EAAE,MAAK,GAAG;AACxB,IAAA,OAAO,EAAE,OAAO,EAAE,CAAQ;AAC1B,IAAA,QAAQ,EAAE,MAAM,EAAE;AAClB,IAAA,QAAQ,EAAE,MAAM,KAAK;AACrB,IAAA,SAAS,EAAE,MAAK,GAAG;AACtB,CAAA,EAAE;AACH,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG"}
|
|
@@ -2,9 +2,6 @@ import React, { ReactNode } from 'react';
|
|
|
2
2
|
interface SlotFillProviderProps {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
context?: any;
|
|
5
|
-
loaderContext?: any;
|
|
6
|
-
renderedFillsPath?: string;
|
|
7
|
-
renderedFillsJson?: any;
|
|
8
5
|
}
|
|
9
6
|
declare const SlotFillProvider: React.FC<SlotFillProviderProps>;
|
|
10
7
|
export default SlotFillProvider;
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import React__default,{useRef,
|
|
1
|
+
import React__default,{useRef,useCallback}from'react';import {sortBy}from'lodash-es';import {Provider}from'./context.js';const SlotFillProvider = ({ children, context }) => {
|
|
2
2
|
const slots = useRef({});
|
|
3
3
|
const fills = useRef({});
|
|
4
4
|
const listeners = useRef([]);
|
|
5
5
|
const returnValue = useRef(context);
|
|
6
|
-
const renderedFills = useRef({});
|
|
7
|
-
// Load renderedFills from file on initialization (server-side only)
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
renderedFills.current = renderedFillsJson;
|
|
10
|
-
console.log('Loaded renderedFills from file:', renderedFills.current);
|
|
11
|
-
}, [renderedFillsJson]);
|
|
12
6
|
const forceUpdateSlot = useCallback((name) => {
|
|
13
7
|
const slot = slots.current[name];
|
|
14
8
|
if (slot && typeof slot.forceUpdate === 'function') {
|
|
@@ -66,33 +60,6 @@ import React__default,{useRef,useEffect,useCallback}from'react';import {sortBy}f
|
|
|
66
60
|
listeners.current = listeners.current.filter((l) => l !== listener);
|
|
67
61
|
};
|
|
68
62
|
}, []);
|
|
69
|
-
const registerRenderedFill = useCallback((name, index, loaderData) => {
|
|
70
|
-
renderedFills.current[`${name}-${index}`] = { name, index, loaderData };
|
|
71
|
-
if (typeof window === 'undefined' && fs) {
|
|
72
|
-
try {
|
|
73
|
-
// Ensure directory exists
|
|
74
|
-
const dir = path.dirname(renderedFillsPath);
|
|
75
|
-
if (!fs.existsSync(dir)) {
|
|
76
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
77
|
-
}
|
|
78
|
-
// Write to file
|
|
79
|
-
fs.writeFileSync(renderedFillsPath, JSON.stringify(renderedFills.current, null, 2));
|
|
80
|
-
console.log(`Saved renderedFills to ${renderedFillsPath}`);
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
console.error('Error writing renderedFills to file:', error);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
triggerListeners();
|
|
87
|
-
}, [triggerListeners, renderedFillsPath]);
|
|
88
|
-
const loadRenderedFill = useCallback((name, index) => {
|
|
89
|
-
// Client-side: first check if we have it in memory
|
|
90
|
-
const key = `${name}-${index}`;
|
|
91
|
-
if (renderedFills.current[key]) {
|
|
92
|
-
return renderedFills.current[key].loaderData;
|
|
93
|
-
}
|
|
94
|
-
return null;
|
|
95
|
-
}, []);
|
|
96
63
|
const contextValue = {
|
|
97
64
|
registerSlot,
|
|
98
65
|
unregisterSlot,
|
|
@@ -102,9 +69,6 @@ import React__default,{useRef,useEffect,useCallback}from'react';import {sortBy}f
|
|
|
102
69
|
getFills,
|
|
103
70
|
hasFills,
|
|
104
71
|
subscribe,
|
|
105
|
-
registerRenderedFill,
|
|
106
|
-
loadRenderedFill,
|
|
107
|
-
loaderContext,
|
|
108
72
|
};
|
|
109
73
|
if (context) {
|
|
110
74
|
returnValue.current = context;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sources":["../../../src/slot-fill/base/provider.tsx"],"sourcesContent":[null],"names":["React"],"mappings":"
|
|
1
|
+
{"version":3,"file":"provider.js","sources":["../../../src/slot-fill/base/provider.tsx"],"sourcesContent":[null],"names":["React"],"mappings":"yHAUM,MAAA,gBAAgB,GAAoC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAI;AAChF,IAAA,MAAM,KAAK,GAAG,MAAM,CAA2B,EAAE,CAAC,CAAC;AACnD,IAAA,MAAM,KAAK,GAAG,MAAM,CAA6B,EAAE,CAAC,CAAC;AACrD,IAAA,MAAM,SAAS,GAAG,MAAM,CAAiB,EAAE,CAAC,CAAC;AAC7C,IAAA,MAAM,WAAW,GAAG,MAAM,CAAM,OAAO,CAAC,CAAC;AAEzC,IAAA,MAAM,eAAe,GAAG,WAAW,CAAC,CAAC,IAAY,KAAI;QACjD,MAAM,IAA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AO,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,QAAQ,CAAC,CAAC;AACxE,SAAC,CAAC;KACL,EAAE,EAAE,CAAC,CAAC;AAEP,IAAA,MAAM,YAAY,GAAmB;QACjC,YAAY;QACZ,cAAc;QACd,YAAY;QACZ,cAAc;QACd,OAAO;QACP,QAAQ;QACR,QAAQ;QACR,SAAS;KACZ,CAAC;IAEF,IAAI,OAAO,EAAE;AACT,QAAA,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC;QAC9B,WAAW,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC;KAC7C;IAED,OAAOA,cAAA,CAAA,aAAA,CAAC,QAAQ,EAAC,EAAA,KAAK,EAAE,YAAY,EAAA,EAAG,QAAQ,CAAY,CAAC;AAChE"}
|
|
@@ -1,62 +1,85 @@
|
|
|
1
|
-
import React__default,{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import React__default,{Component,Children,cloneElement}from'react';import {Consumer}from'./context.js';import {isFunction}from'../utils/index.js';import {PluginRender}from'../../plugin/plugin-render.js';import {isEmptyElement}from'../utils/isEmptyElement.js';class SlotComponent extends Component {
|
|
2
|
+
node;
|
|
3
|
+
isUnmounted;
|
|
4
|
+
constructor(props) {
|
|
5
|
+
super(props);
|
|
6
|
+
this.isUnmounted = false;
|
|
7
|
+
this.bindNode = this.bindNode.bind(this);
|
|
8
|
+
}
|
|
9
|
+
componentDidMount() {
|
|
10
|
+
const { registerSlot, serverMode } = this.props;
|
|
7
11
|
if (!serverMode) {
|
|
8
|
-
registerSlot(name,
|
|
12
|
+
registerSlot(this.props.name, this);
|
|
9
13
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
}
|
|
15
|
+
componentWillUnmount() {
|
|
16
|
+
const { unregisterSlot } = this.props;
|
|
17
|
+
this.isUnmounted = true;
|
|
18
|
+
unregisterSlot(this.props.name, this);
|
|
19
|
+
}
|
|
20
|
+
componentDidUpdate(prevProps) {
|
|
21
|
+
this.props;
|
|
22
|
+
// Commented following as we need the Slot to render at multiple places
|
|
23
|
+
// if (prevProps.name !== name) {
|
|
24
|
+
// unregisterSlot(prevProps.name);
|
|
25
|
+
// registerSlot(name, this);
|
|
26
|
+
// }
|
|
27
|
+
}
|
|
28
|
+
bindNode(node) {
|
|
29
|
+
this.node = node;
|
|
30
|
+
}
|
|
31
|
+
forceUpdate() {
|
|
32
|
+
if (this.isUnmounted) {
|
|
17
33
|
return;
|
|
18
34
|
}
|
|
19
|
-
if (!serverMode) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
35
|
+
if (!this.props.serverMode) {
|
|
36
|
+
super.forceUpdate();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
render() {
|
|
40
|
+
const { children, name, fillProps = {}, getFills, serverMode } = this.props;
|
|
41
|
+
const fills = getFills(name).filter((element) => !isEmptyElement(element));
|
|
42
|
+
if (fills.length > 0) {
|
|
43
|
+
if (isFunction(children)) {
|
|
44
|
+
const childrenFills = fills.map((fill) => {
|
|
45
|
+
const fillChildren = isFunction(fill.children)
|
|
46
|
+
? fill.children(fillProps)
|
|
47
|
+
: fill.children;
|
|
48
|
+
return Children.map(fillChildren, (child, childIndex) => {
|
|
49
|
+
if (!child || typeof child === 'string') {
|
|
50
|
+
return child;
|
|
51
|
+
}
|
|
52
|
+
const childKey = child.key || childIndex;
|
|
53
|
+
return cloneElement(child, { key: childKey });
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
return React__default.createElement(React__default.Fragment, null, children(childrenFills));
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
return React__default.createElement(PluginRender, { ...fillProps, name: name, fills: fills });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/*
|
|
63
|
+
if (serverMode) {
|
|
64
|
+
const fills = (getFills(name, this) ?? [])
|
|
65
|
+
.map((fill: any, i) => {
|
|
66
|
+
// unregisterFill(name, fill);
|
|
67
|
+
if (typeof fill === 'function') {
|
|
68
|
+
const child = fill({...fillProps, key: i});
|
|
69
|
+
return <div data-slot-name={`slot-${name}`}>{child}</div>;
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
});
|
|
73
|
+
return fills;
|
|
23
74
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// .map((fill: any, i) => {
|
|
27
|
-
// if (serverMode) {
|
|
28
|
-
// if (typeof fill === 'function') {
|
|
29
|
-
// const child = fill({...fillProps, key: i});
|
|
30
|
-
// return <div data-slot-name={`slot-${name}`}>{child}</div>;
|
|
31
|
-
// }
|
|
32
|
-
// return null;
|
|
33
|
-
// } else {
|
|
34
|
-
// const fillChildren: ReactElement = isFunction(fill.children) ? fill.children(fillProps) : fill.children;
|
|
35
|
-
// return Children.map(fillChildren, (child, childIndex) => {
|
|
36
|
-
// if (!child || typeof child === 'string') {
|
|
37
|
-
// return child;
|
|
38
|
-
// }
|
|
39
|
-
// const childKey = child.key || childIndex;
|
|
40
|
-
// return cloneElement(child, { key: childKey });
|
|
41
|
-
// });
|
|
42
|
-
// }
|
|
43
|
-
// })
|
|
44
|
-
// .filter(
|
|
45
|
-
// // In some cases fills are rendered only when some conditions apply.
|
|
46
|
-
// // This ensures that we only use non-empty fills when rendering, i.e.,
|
|
47
|
-
// // it allows us to render wrappers only when the fills are actually present.
|
|
48
|
-
// (element) => !isEmptyElement(element),
|
|
49
|
-
// );
|
|
50
|
-
const fills = getFills(name);
|
|
51
|
-
if (fills.length > 0) {
|
|
52
|
-
return (React__default.createElement(PluginRender, { ...fillProps, name: name, fills: fills, registerRenderedFill: registerRenderedFill, loadRenderedFill: loadRenderedFill, loaderContext: loaderContext }));
|
|
75
|
+
*/
|
|
76
|
+
return null;
|
|
53
77
|
}
|
|
54
|
-
|
|
55
|
-
};
|
|
78
|
+
}
|
|
56
79
|
const Slot = (props) => {
|
|
57
|
-
const serverMode =
|
|
58
|
-
return (React__default.createElement(Consumer, null, ({ registerSlot, unregisterSlot, getFills
|
|
59
|
-
// We need to add id to fillProps with slot name,
|
|
80
|
+
const serverMode = typeof window === 'undefined';
|
|
81
|
+
return (React__default.createElement(Consumer, null, ({ registerSlot, unregisterSlot, getFills }) => (React__default.createElement(SlotComponent, { ...props,
|
|
82
|
+
// We need to add id to fillProps with slot name,
|
|
60
83
|
// so that we can use it when remove the component during hydration.
|
|
61
|
-
getFills: getFills, registerSlot: registerSlot, unregisterSlot: unregisterSlot, serverMode: serverMode
|
|
84
|
+
getFills: getFills, registerSlot: registerSlot, unregisterSlot: unregisterSlot, serverMode: serverMode }))));
|
|
62
85
|
};export{Slot as default};//# sourceMappingURL=slot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot.js","sources":["../../../src/slot-fill/base/slot.tsx"],"sourcesContent":[null],"names":["React"],"mappings":"
|
|
1
|
+
{"version":3,"file":"slot.js","sources":["../../../src/slot-fill/base/slot.tsx"],"sourcesContent":[null],"names":["React"],"mappings":"mQAUA,MAAM,aAAc,SAAQ,SAAmC,CAAA;AACnD,IAAA,IAAI,CAAU;AACd,IAAA,WAAW,CAAU;AAC7B,IAAA,WAAA,CAAY,KAA2B,EAAA;QACnC,KAAK,CAAC,KAAK,CAAC,CAAC;AACb,QAAA,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KAC5C;IAEM,iBAAiB,GAAA;QACpB,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAChD,IAAI,CAAC,UAAU,EAAE;YACb,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SACvC;KACJ;IAEM,oBAAoB,GA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;wBACpD,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AACrC,4BAAA,OAAO,KAAK,CAAC;yBAChB;AAED,wBAAA,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,IAAI,UAAU,CAAC;wBACzC,OAAO,YAAY,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;AAClD,qBAAC,CAAC,CAAC;AACP,iBAAC,CAAC,CAAC;AACH,gBAAA,OAAOA,4DAAG,QAAQ,CAAC,aAAoB,CAAC,CAAI,CAAC;aAChD;iBAAM;AACH,gBAAA,OAAOA,cAAC,CAAA,aAAA,CAAA,YAAY,EAAK,EAAA,GAAA,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,GAAI,CAAC;aACpE;SACJ;AACD;;;;;;;;;;;;;AAaE;AACF,QAAA,OAAO,IAAI,CAAC;KACf;AACJ,CAAA;AAED,MAAM,IAAI,GAAG,CAAC,KAAiB,KAAI;AAC/B,IAAA,MAAM,UAAU,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;AACjD,IAAA,QACIA,cAAC,CAAA,aAAA,CAAA,QAAQ,QACJ,CAAC,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,MACxCA,cAAC,CAAA,aAAA,CAAA,aAAa,OACN,KAAK;;;AAGT,QAAA,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,UAAU,GACxB,CACL,CACM,EACb;AACN"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode, Component } from 'react';
|
|
2
|
-
import { IPlugin } from '@common-stack/client-
|
|
2
|
+
import { IPlugin } from '@common-stack/client-core';
|
|
3
3
|
export type Name = string | Symbol;
|
|
4
4
|
export interface IFillProps {
|
|
5
5
|
name: Name;
|
|
@@ -23,9 +23,6 @@ export interface IProviderState {
|
|
|
23
23
|
getFills: (a: Name, b?: any) => IFill[] | [];
|
|
24
24
|
hasFills: (a: Name) => boolean;
|
|
25
25
|
subscribe: (listener: any) => void;
|
|
26
|
-
registerRenderedFill: (a: Name, b: number, c: any) => void;
|
|
27
|
-
loadRenderedFill: (a: Name, b: number) => any;
|
|
28
|
-
loaderContext: any;
|
|
29
26
|
}
|
|
30
27
|
export type IReactContext = Omit<Partial<IProviderState>, 'registerSlot'> & {
|
|
31
28
|
slots?: any;
|
|
@@ -86,7 +83,8 @@ export interface ISlotProps {
|
|
|
86
83
|
*/
|
|
87
84
|
serverMode?: boolean;
|
|
88
85
|
}
|
|
89
|
-
export interface
|
|
86
|
+
export interface ILoadedPlugin extends IPlugin {
|
|
90
87
|
index?: number;
|
|
91
|
-
|
|
88
|
+
Component?: React.ComponentType<any>;
|
|
89
|
+
loaderData?: Record<string, any>;
|
|
92
90
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the argument is a function.
|
|
3
|
+
*
|
|
4
|
+
* @param {*} maybeFunc The argument to check.
|
|
5
|
+
* @returns {boolean} True if the argument is a function, false otherwise.
|
|
6
|
+
*/
|
|
7
|
+
function isFunction(maybeFunc) {
|
|
8
|
+
return typeof maybeFunc === 'function';
|
|
9
|
+
}export{isFunction};//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/slot-fill/utils/index.ts"],"sourcesContent":[null],"names":[],"mappings":"AAGA;;;;;AAKG;AACG,SAAU,UAAU,CAAC,SAAc,EAAA;AACrC,IAAA,OAAO,OAAO,SAAS,KAAK,UAAU,CAAC;AAC3C"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the provided element to check.
|
|
3
|
+
*
|
|
4
|
+
* @param element React Component to check.
|
|
5
|
+
* @returns True when an element is considered empty.
|
|
6
|
+
*/
|
|
7
|
+
const isEmptyElement = (element) => {
|
|
8
|
+
if (typeof element === 'number') {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (typeof element?.valueOf() === 'string' || Array.isArray(element)) {
|
|
12
|
+
return !element.length;
|
|
13
|
+
}
|
|
14
|
+
if (typeof element === 'object' && element !== null) {
|
|
15
|
+
return Object.keys(element).length === 0 || Object.values(element).every((value) => isEmptyElement(value));
|
|
16
|
+
}
|
|
17
|
+
return !element;
|
|
18
|
+
};export{isEmptyElement};//# sourceMappingURL=isEmptyElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isEmptyElement.js","sources":["../../../src/slot-fill/utils/isEmptyElement.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEA;;;;;AAKG;AAEU,MAAA,cAAc,GAAG,CAAC,OAAO,KAAI;AACtC,IAAA,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;AAC7B,QAAA,OAAO,KAAK,CAAC;KAChB;AAED,IAAA,IAAI,OAAO,OAAO,EAAE,OAAO,EAAE,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;AAClE,QAAA,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC;KAC1B;IAED,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE;AACjD,QAAA,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,KAAK,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;KAC9G;IAED,OAAO,CAAC,OAAO,CAAC;AACpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/components-pro",
|
|
3
|
-
"version": "7.1.1-alpha.
|
|
3
|
+
"version": "7.1.1-alpha.3",
|
|
4
4
|
"description": "browser plugin for git",
|
|
5
5
|
"homepage": "https://github.com/cdmbase/fullstack-pro#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
"build:lib:watch": "npm run build:lib -- --watch",
|
|
25
25
|
"jest": "./node_modules/.bin/jest",
|
|
26
26
|
"prepublish": "npm run build",
|
|
27
|
-
"test": "
|
|
27
|
+
"test": "vitest",
|
|
28
28
|
"test:debug": "npm test -- --runInBand",
|
|
29
29
|
"test:watch": "npm test -- --watch",
|
|
30
30
|
"watch": "npm run build:lib:watch"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@common-stack/client-core": "7.
|
|
33
|
+
"@common-stack/client-core": "7.1.1-alpha.3",
|
|
34
34
|
"@wordpress/element": "^5.30.0",
|
|
35
35
|
"@wordpress/hooks": "^3.53.0",
|
|
36
36
|
"@wordpress/is-shallow-equal": "^4.53.0",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
|
+
"gitHead": "957549af03185aa8c04c216f68db9ab6251f2d0d",
|
|
53
54
|
"typescript": {
|
|
54
55
|
"definition": "lib/index.d.ts"
|
|
55
|
-
}
|
|
56
|
-
"gitHead": "93027005d418b28138e303fe77d1857867564bd8"
|
|
56
|
+
}
|
|
57
57
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reset-rendered-fills.js","sources":["../../src/plugin/reset-rendered-fills.ts"],"sourcesContent":[null],"names":[],"mappings":"mBACO,MAAM,iBAAiB,GAAG,4BAA4B;AAEhD,MAAA,kBAAkB,GAAG,CAAC,IAAY,KAAI;AAC/C,IAAA,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AACxD"}
|