@common-stack/components-pro 8.0.2-alpha.1 → 8.1.1-alpha.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/LICENSE +34 -21
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/index.native.d.ts +2 -1
- package/lib/index.native.js +1 -1
- package/lib/plugin/context.d.ts +2 -1
- package/lib/plugin/context.js.map +1 -1
- package/lib/plugin/index.native.d.ts +2 -0
- package/lib/plugin/loader.d.ts +7 -1
- package/lib/plugin/loader.js +14 -5
- package/lib/plugin/loader.js.map +1 -1
- package/lib/plugin/plugin-render.d.ts +8 -1
- package/lib/plugin/plugin-render.js +37 -27
- package/lib/plugin/plugin-render.js.map +1 -1
- package/lib/plugin/provider.js +3 -2
- package/lib/plugin/provider.js.map +1 -1
- package/lib/plugin/provider.native.d.ts +7 -0
- package/lib/plugin/provider.native.js +3 -0
- package/lib/plugin/provider.native.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 -1
- package/lib/slot-fill/base/context.js.map +1 -1
- package/lib/slot-fill/base/fill.js +3 -3
- package/lib/slot-fill/base/fill.js.map +1 -1
- package/lib/slot-fill/base/provider.js +2 -2
- package/lib/slot-fill/base/provider.js.map +1 -1
- package/lib/slot-fill/base/slot.js +72 -49
- package/lib/slot-fill/base/slot.js.map +1 -1
- package/lib/slot-fill/interfaces/index.d.ts +6 -0
- package/lib/slot-fill/utils/index.d.ts +0 -1
- package/lib/slot-fill/utils/index.js +1 -1
- package/lib/slot-fill/utils/index.js.map +1 -1
- 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/lib/slot-fill/utils/removeUniversalPortals.js.map +1 -1
- package/package.json +5 -6
- package/lib/index.server.d.ts +0 -1
- package/lib/index.server.js +0 -1
- package/lib/index.server.js.map +0 -1
- package/lib/plugin/middleware.d.ts +0 -3
- package/lib/plugin/middleware.js +0 -19
- package/lib/plugin/middleware.js.map +0 -1
- package/lib/slot-fill/utils/replaceServerFills.d.ts +0 -9
- package/lib/slot-fill/utils/replaceServerFills.js +0 -25
- package/lib/slot-fill/utils/replaceServerFills.js.map +0 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2017 CDMBase LLC.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
IMPLIED,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
PROPRIETARY LICENSE
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017-2025 CDMBase LLC. All Rights Reserved.
|
|
4
|
+
|
|
5
|
+
This software and associated documentation files (the "Software") are the
|
|
6
|
+
proprietary and confidential information of CDMBase LLC ("Confidential Information").
|
|
7
|
+
|
|
8
|
+
NOTICE: All information contained herein is, and remains the property of
|
|
9
|
+
CDMBase LLC. The intellectual and technical concepts contained herein are
|
|
10
|
+
proprietary to CDMBase LLC and may be covered by U.S. and Foreign Patents,
|
|
11
|
+
patents in process, and are protected by trade secret or copyright law.
|
|
12
|
+
|
|
13
|
+
Dissemination of this information or reproduction of this material is strictly
|
|
14
|
+
forbidden unless prior written permission is obtained from CDMBase LLC.
|
|
15
|
+
|
|
16
|
+
NO LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY INTELLECTUAL
|
|
17
|
+
PROPERTY RIGHTS ARE GRANTED BY THIS DOCUMENT.
|
|
18
|
+
|
|
19
|
+
RESTRICTIONS:
|
|
20
|
+
1. You may NOT use, copy, modify, merge, publish, distribute, sublicense,
|
|
21
|
+
and/or sell copies of the Software without explicit written permission
|
|
22
|
+
from CDMBase LLC.
|
|
23
|
+
2. You may NOT reverse engineer, decompile, or disassemble the Software.
|
|
24
|
+
3. You may NOT remove or alter any proprietary notices or labels on the Software.
|
|
25
|
+
4. The Software is licensed, not sold.
|
|
26
|
+
|
|
27
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
28
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
29
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
30
|
+
CDMBASE LLC BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
31
|
+
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
32
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
33
|
+
|
|
34
|
+
For licensing inquiries, please contact: legal@cdmbase.com
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { createSlotFill, Slot, Fill, Provider as SlotFillProvider, useSlot as __experimentalUseSlot, } from './slot-fill';
|
|
2
|
-
export { removeUniversalPortals
|
|
2
|
+
export { removeUniversalPortals } from './slot-fill/utils';
|
|
3
3
|
export * from './plugin';
|
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
|
package/lib/index.native.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { createSlotFill, Slot, Fill, Provider as SlotFillProvider
|
|
1
|
+
export { createSlotFill, Slot, Fill, Provider as SlotFillProvider } from './slot-fill';
|
|
2
|
+
export * from './plugin/index.native';
|
package/lib/index.native.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{Fill,Slot,Provider as SlotFillProvider,createSlotFill}from'./slot-fill/index.js';//# sourceMappingURL=index.native.js.map
|
|
1
|
+
export{Fill,Slot,Provider as SlotFillProvider,createSlotFill}from'./slot-fill/index.js';export{default as FillRenderProvider}from'./plugin/provider.native.js';export{PluginsLoader}from'./plugin/loader.js';//# sourceMappingURL=index.native.js.map
|
package/lib/plugin/context.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { ILoadedPlugin } from '../slot-fill/interfaces';
|
|
2
3
|
export interface IFillRenderContext {
|
|
3
|
-
loadedPlugins:
|
|
4
|
+
loadedPlugins: ILoadedPlugin[];
|
|
4
5
|
}
|
|
5
6
|
declare const FillRenderContext: React.Context<IFillRenderContext>;
|
|
6
7
|
export default FillRenderContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sources":["../../src/plugin/context.tsx"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.js","sources":["../../src/plugin/context.tsx"],"sourcesContent":[null],"names":[],"mappings":"4BAOM,MAAA,iBAAiB,GAAG,KAAK,CAAC,aAAa,CAA4B,IAAI"}
|
package/lib/plugin/loader.d.ts
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { IAppLoadContext } from '@common-stack/client-core';
|
|
2
|
+
import { IResourceParams } from '@common-stack/core';
|
|
3
|
+
export declare function PluginsLoader(plugins: any[], loaderContext: {
|
|
4
|
+
request: Request;
|
|
5
|
+
context: IAppLoadContext;
|
|
6
|
+
params: IResourceParams;
|
|
7
|
+
}): Promise<any[]>;
|
package/lib/plugin/loader.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
async function PluginsLoader(plugins) {
|
|
1
|
+
async function PluginsLoader(plugins, loaderContext) {
|
|
2
2
|
const loadedPlugins = await Promise.all(plugins.map(async (plugin) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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);
|
|
7
16
|
}
|
|
8
17
|
return plugin;
|
|
9
18
|
}));
|
package/lib/plugin/loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sources":["../../src/plugin/loader.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loader.js","sources":["../../src/plugin/loader.ts"],"sourcesContent":[null],"names":[],"mappings":"AAGO,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,6 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { ILoadedPlugin, Name } from '../slot-fill/interfaces';
|
|
3
|
+
interface IPluginRenderProps {
|
|
4
|
+
fills: ILoadedPlugin[];
|
|
5
|
+
name: Name;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}
|
|
2
8
|
export declare const ChildrenRender: ({ children, ...props }: {
|
|
3
9
|
[x: string]: any;
|
|
4
10
|
children: any;
|
|
5
11
|
}) => React.JSX.Element;
|
|
6
|
-
export declare const PluginRender: (props:
|
|
12
|
+
export declare const PluginRender: (props: IPluginRenderProps) => React.JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -2,37 +2,47 @@ import React__default,{useContext}from'react';import {DynamicRender}from'./dynam
|
|
|
2
2
|
return React__default.createElement(React__default.Fragment, null, isFunction(children) ? children(props) : children);
|
|
3
3
|
};
|
|
4
4
|
const PluginRender = (props) => {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
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 });
|
|
17
|
+
}
|
|
18
|
+
else if (plugin?.render) {
|
|
19
|
+
let children = null;
|
|
20
|
+
try {
|
|
21
|
+
const FillComponent = plugin.render(props);
|
|
22
|
+
if (React__default.isValidElement(FillComponent)) {
|
|
23
|
+
const element = FillComponent;
|
|
24
|
+
children = element.props?.children;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (fill.renderImporter) {
|
|
30
|
-
return React__default.createElement(DynamicRender, { key: i, ...props, renderImporter: fill.renderImporter });
|
|
27
|
+
catch (error) {
|
|
28
|
+
console.error('Error in PluginRender', error);
|
|
31
29
|
}
|
|
32
|
-
|
|
33
|
-
return React__default.createElement(ChildrenRender, {
|
|
30
|
+
if (children) {
|
|
31
|
+
return React__default.createElement(ChildrenRender, { ...props, children: children });
|
|
34
32
|
}
|
|
35
33
|
}
|
|
36
|
-
|
|
34
|
+
else if (fill.children) {
|
|
35
|
+
return React__default.createElement(ChildrenRender, { ...props, children: fill.children });
|
|
36
|
+
}
|
|
37
|
+
return React__default.createElement(React__default.Fragment, null);
|
|
38
|
+
};
|
|
39
|
+
return (React__default.createElement(React__default.Fragment, null, props.fills.map((fill, i) => {
|
|
40
|
+
if (typeof window === 'undefined') {
|
|
41
|
+
return (React__default.createElement("div", { key: i, "data-slot-name": `slot-${props.name}` },
|
|
42
|
+
React__default.createElement(FillRender, { fill: fill, ...props })));
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
return React__default.createElement(FillRender, { key: i, fill: fill, ...props });
|
|
46
|
+
}
|
|
37
47
|
})));
|
|
38
48
|
};export{ChildrenRender,PluginRender};//# sourceMappingURL=plugin-render.js.map
|
|
@@ -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,EAA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A,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;YAC/B,QACIA,cAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,GAAG,EAAE,CAAC,oBAAkB,CAAQ,KAAA,EAAA,KAAK,CAAC,IAAI,CAAE,CAAA,EAAA;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"}
|
package/lib/plugin/provider.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React__default from'react';import {useLoaderData}from'@remix-run/react';import FillRenderContext from'./context.js';const FillRenderProvider = ({ children }) => {
|
|
2
|
-
const
|
|
3
|
-
|
|
2
|
+
const loaderData = useLoaderData();
|
|
3
|
+
const loadedPlugins = loaderData?.loadedPlugins || [];
|
|
4
|
+
return React__default.createElement(FillRenderContext.Provider, { value: { loadedPlugins } }, children);
|
|
4
5
|
};export{FillRenderProvider as default};//# sourceMappingURL=provider.js.map
|
|
@@ -1 +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,
|
|
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,UAAU,GAAQ,aAAa,EAAE,CAAC;AACxC,IAAA,MAAM,aAAa,GAAG,UAAU,EAAE,aAAa,IAAI,EAAE,CAAC;AAEtD,IAAA,OAAOA,cAAC,CAAA,aAAA,CAAA,iBAAiB,CAAC,QAAQ,EAAC,EAAA,KAAK,EAAE,EAAE,aAAa,EAAE,EAAG,EAAA,QAAQ,CAA8B,CAAC;AACzG"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import React__default from'react';import FillRenderContext from'./context.js';const FillRenderProvider = ({ children, loadedPlugins = [] }) => {
|
|
2
|
+
return React__default.createElement(FillRenderContext.Provider, { value: { loadedPlugins } }, children);
|
|
3
|
+
};export{FillRenderProvider as default};//# sourceMappingURL=provider.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.native.js","sources":["../../src/plugin/provider.native.tsx"],"sourcesContent":[null],"names":["React"],"mappings":"8EAQM,MAAA,kBAAkB,GAAsC,CAAC,EAAE,QAAQ,EAAE,aAAa,GAAG,EAAE,EAAE,KAAI;AAC/F,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,10 +1,11 @@
|
|
|
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
11
|
});
|
|
@@ -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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React__default,{useRef}from'react';import {Consumer}from'./context.js';import {useSlot}from'./use-slot.js';const FillComponent = ({ name, renderImporter, children, registerFill, unregisterFill, serverMode, }) => {
|
|
1
|
+
import React__default,{useRef}from'react';import {Consumer}from'./context.js';import {useSlot}from'./use-slot.js';const FillComponent = ({ index, name, renderImporter, children, registerFill, unregisterFill, serverMode, }) => {
|
|
2
2
|
const slot = useSlot(name);
|
|
3
3
|
let useLayoutEffect;
|
|
4
|
-
const nodeProps = { renderImporter, children };
|
|
4
|
+
const nodeProps = { index, renderImporter, children };
|
|
5
5
|
if (serverMode) {
|
|
6
6
|
useLayoutEffect = (args) => { };
|
|
7
7
|
if (!!name) {
|
|
@@ -26,7 +26,7 @@ import React__default,{useRef}from'react';import {Consumer}from'./context.js';im
|
|
|
26
26
|
}, []);
|
|
27
27
|
useLayoutEffect(() => {
|
|
28
28
|
ref.current.nodeProps = nodeProps;
|
|
29
|
-
if (slot) {
|
|
29
|
+
if (slot && typeof slot.forceUpdate === 'function') {
|
|
30
30
|
slot.forceUpdate();
|
|
31
31
|
}
|
|
32
32
|
// Ignore reason: the useLayoutEffects here are written to fire at specific times, and introducing new dependencies could cause unexpected changes in behavior.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fill.js","sources":["../../../src/slot-fill/base/fill.tsx"],"sourcesContent":[null],"names":["React"],"mappings":"kHAUA,MAAM,aAAa,GAAG,CAAC,EACnB,IAAI,EACJ,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,UAAU,GACS,KAAI;AACvB,IAAA,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAC3B,IAAA,IAAI,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"fill.js","sources":["../../../src/slot-fill/base/fill.tsx"],"sourcesContent":[null],"names":["React"],"mappings":"kHAUA,MAAM,aAAa,GAAG,CAAC,EACnB,KAAK,EACL,IAAI,EACJ,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,UAAU,GACS,KAAI;AACvB,IAAA,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAC3B,IAAA,IAAI,eAAe,CAAC;IACpB,MAAM,SAAS,GAAG,EAAE,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC;IAEtD,IAAI,UAAU,EAAE;AACZ,QAAA,eAAe,GAAG,CAAC,IAAI,KAAI,GAAG,CAAC;AAC/B,QAAA,IAAI,CAAC,CAAC,IAAI,EAAE;AACR,YAAA,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;SACjC;AACD,QAAA,OAAO,IAAI,CAAC;KACf;SAAM;AACH,QAAA,eAAe,GAAGA,cAAK,CAAC,eAAe,CAAC;KAC3C;IAED,MAAM,GAAG,GAAG,MAAM,CAAC;QACf,IAAI;QAC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AC,QAAQ,EAAA,IAAA,EACJ,CAAC,EAAE,YAAY,EAAE,cAAc,EAAE,MAC9BA,6BAAC,aAAa,EAAA,EAAA,GACN,KAAK,EACT,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,UAAU,EAAA,CACxB,CACL,CACM,EACb;AACN"}
|
|
@@ -5,7 +5,7 @@ import React__default,{useRef,useCallback}from'react';import {sortBy}from'lodash
|
|
|
5
5
|
const returnValue = useRef(context);
|
|
6
6
|
const forceUpdateSlot = useCallback((name) => {
|
|
7
7
|
const slot = slots.current[name];
|
|
8
|
-
if (slot) {
|
|
8
|
+
if (slot && typeof slot.forceUpdate === 'function') {
|
|
9
9
|
slot.forceUpdate();
|
|
10
10
|
}
|
|
11
11
|
}, []);
|
|
@@ -23,7 +23,7 @@ import React__default,{useRef,useCallback}from'react';import {sortBy}from'lodash
|
|
|
23
23
|
// same name exists, force its update _after_ the new slot has been
|
|
24
24
|
// assigned into the instance, such that its own rendering of children
|
|
25
25
|
// will be empty (the new Slot will subsume all fills for this name).
|
|
26
|
-
if (previousSlot) {
|
|
26
|
+
if (previousSlot && typeof previousSlot.forceUpdate === 'function') {
|
|
27
27
|
previousSlot.forceUpdate();
|
|
28
28
|
}
|
|
29
29
|
}, [forceUpdateSlot, triggerListeners]);
|
|
@@ -1 +1 @@
|
|
|
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,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
|
-
|
|
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 });
|
|
75
|
+
*/
|
|
76
|
+
return null;
|
|
53
77
|
}
|
|
54
|
-
|
|
55
|
-
};
|
|
78
|
+
}
|
|
56
79
|
const Slot = (props) => {
|
|
57
80
|
const serverMode = typeof window === 'undefined';
|
|
58
81
|
return (React__default.createElement(Consumer, null, ({ registerSlot, unregisterSlot, getFills }) => (React__default.createElement(SlotComponent, { ...props,
|
|
@@ -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,C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1,4 +1,5 @@
|
|
|
1
1
|
import { ReactNode, Component } from 'react';
|
|
2
|
+
import { IPlugin } from '@common-stack/client-core';
|
|
2
3
|
export type Name = string | Symbol;
|
|
3
4
|
export interface IFillProps {
|
|
4
5
|
name: Name;
|
|
@@ -82,3 +83,8 @@ export interface ISlotProps {
|
|
|
82
83
|
*/
|
|
83
84
|
serverMode?: boolean;
|
|
84
85
|
}
|
|
86
|
+
export interface ILoadedPlugin extends IPlugin {
|
|
87
|
+
index?: number;
|
|
88
|
+
Component?: React.ComponentType<any>;
|
|
89
|
+
loaderData?: Record<string, any>;
|
|
90
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/slot-fill/utils/index.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removeUniversalPortals.js","sources":["../../../src/slot-fill/utils/removeUniversalPortals.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;AAEG;AACU,MAAA,sBAAsB,GAAG,CAAC,KAAe,KAAI;
|
|
1
|
+
{"version":3,"file":"removeUniversalPortals.js","sources":["../../../src/slot-fill/utils/removeUniversalPortals.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;AAEG;AACU,MAAA,sBAAsB,GAAG,CAAC,KAAe,KAAI;AACtD,IAAA,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;AACjC,QAAA,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,KAAI;AACnB,YAAA,QAAQ,CAAC,gBAAgB,CAAC,CAAA,qBAAA,EAAwB,IAAI,CAAA,CAAA,CAAG,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,KAAI;gBACxE,IAAI,CAAC,MAAM,EAAE,CAAC;AAClB,aAAC,CAAC,CAAC;AACP,SAAC,CAAC,CAAC;KACN;AACL"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/components-pro",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.1.1-alpha.1",
|
|
4
4
|
"description": "browser plugin for git",
|
|
5
5
|
"homepage": "https://github.com/cdmbase/fullstack-pro#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "git+https://github.com/cdmbase/fullstack-pro.git"
|
|
12
12
|
},
|
|
13
|
-
"license": "
|
|
13
|
+
"license": "UNLICENSED",
|
|
14
14
|
"author": "CDMBase LLC",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"main": "lib/index.js",
|
|
@@ -24,18 +24,17 @@
|
|
|
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": "8.
|
|
33
|
+
"@common-stack/client-core": "8.1.1-alpha.1",
|
|
34
34
|
"@wordpress/element": "^5.30.0",
|
|
35
35
|
"@wordpress/hooks": "^3.53.0",
|
|
36
36
|
"@wordpress/is-shallow-equal": "^4.53.0",
|
|
37
37
|
"@wordpress/warning": "^2.53.0",
|
|
38
|
-
"cheerio": "^1.0.0",
|
|
39
38
|
"history-with-query": "^4.10.4",
|
|
40
39
|
"sort-keys": "^4.1.0",
|
|
41
40
|
"valtio": "^1.7.0"
|
|
@@ -53,5 +52,5 @@
|
|
|
53
52
|
"typescript": {
|
|
54
53
|
"definition": "lib/index.d.ts"
|
|
55
54
|
},
|
|
56
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "4968f621c6a6f32d538ef5195f5c106e4f0811b8"
|
|
57
56
|
}
|
package/lib/index.server.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './plugin/middleware';
|
package/lib/index.server.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{middleware}from'./plugin/middleware.js';//# sourceMappingURL=index.server.js.map
|
package/lib/index.server.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.server.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/lib/plugin/middleware.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const middleware = async ({ context }, dataLoader, next) => {
|
|
2
|
-
const { modules } = context;
|
|
3
|
-
try {
|
|
4
|
-
const plugins = modules.getComponentFillPlugins();
|
|
5
|
-
const loadedPlugins = await Promise.all(plugins.map(async (plugin) => {
|
|
6
|
-
if (plugin.renderImporter) {
|
|
7
|
-
const module = await plugin.renderImporter();
|
|
8
|
-
const ImportedComponent = module.default;
|
|
9
|
-
return { ...plugin, Component: ImportedComponent };
|
|
10
|
-
}
|
|
11
|
-
return plugin;
|
|
12
|
-
}));
|
|
13
|
-
dataLoader.loadedPlugins = loadedPlugins;
|
|
14
|
-
}
|
|
15
|
-
catch (error) {
|
|
16
|
-
console.error(error, 'Error with plugin middleware');
|
|
17
|
-
}
|
|
18
|
-
await next();
|
|
19
|
-
};export{middleware};//# sourceMappingURL=middleware.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","sources":["../../src/plugin/middleware.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEO,MAAM,UAAU,GAAG,OAAO,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,KAAI;AAC9D,IAAA,MAAM,EAAE,OAAO,EAAE,GAAG,OAA0B,CAAC;AAE/C,IAAA,IAAI;AACA,QAAA,MAAM,OAAO,GAAI,OAAe,CAAC,uBAAuB,EAAE,CAAC;AAC3D,QAAA,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,GAAG,CACnC,OAAO,CAAC,GAAG,CAAC,OAAO,MAAW,KAAI;AAC9B,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;gBACzC,OAAO,EAAE,GAAG,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;aACtD;AACD,YAAA,OAAO,MAAM,CAAC;SACjB,CAAC,CACL,CAAC;AACF,QAAA,UAAU,CAAC,aAAa,GAAG,aAAa,CAAC;KAC5C;IAAC,OAAO,KAAK,EAAE;AACZ,QAAA,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,8BAA8B,CAAC,CAAC;KACxD;IACD,MAAM,IAAI,EAAE,CAAC;AACjB"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Replace the wrapped dom element with `[data-slot-name]` to its children,
|
|
3
|
-
* setting attrib [data-slot-name] same as parent.
|
|
4
|
-
*
|
|
5
|
-
* @param htmlContent Html content string.
|
|
6
|
-
* @param fills fill names.
|
|
7
|
-
* @returns The replaced html content string.
|
|
8
|
-
*/
|
|
9
|
-
export declare const replaceServerFills: (htmlContent: string, fills: string[]) => string;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import*as cheerio from'cheerio';/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
/* eslint-disable no-param-reassign */
|
|
3
|
-
/**
|
|
4
|
-
* Replace the wrapped dom element with `[data-slot-name]` to its children,
|
|
5
|
-
* setting attrib [data-slot-name] same as parent.
|
|
6
|
-
*
|
|
7
|
-
* @param htmlContent Html content string.
|
|
8
|
-
* @param fills fill names.
|
|
9
|
-
* @returns The replaced html content string.
|
|
10
|
-
*/
|
|
11
|
-
const replaceServerFills = (htmlContent, fills) => {
|
|
12
|
-
const $ = cheerio.load(htmlContent);
|
|
13
|
-
let newContent = htmlContent;
|
|
14
|
-
fills.forEach((name) => {
|
|
15
|
-
$(`[data-slot-name=slot-${name}]`).each((i, node) => {
|
|
16
|
-
const search = $(node).prop('outerHTML');
|
|
17
|
-
node.children.forEach((child) => {
|
|
18
|
-
child.attribs['data-slot-name'] = `slot-${name}`;
|
|
19
|
-
});
|
|
20
|
-
const replace = $(node).html() || '';
|
|
21
|
-
newContent = newContent.replace(search, replace);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
return newContent;
|
|
25
|
-
};export{replaceServerFills};//# sourceMappingURL=replaceServerFills.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"replaceServerFills.js","sources":["../../../src/slot-fill/utils/replaceServerFills.ts"],"sourcesContent":[null],"names":[],"mappings":"gCAAA;AACA;AAEA;;;;;;;AAOG;MACU,kBAAkB,GAAG,CAAC,WAAmB,EAAE,KAAe,KAAI;IACvE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACpC,IAAI,UAAU,GAAG,WAAW,CAAC;AAE7B,IAAA,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,KAAI;AACnB,QAAA,CAAC,CAAC,CAAA,qBAAA,EAAwB,IAAI,CAAA,CAAA,CAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,KAAI;YAChD,MAAM,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACzC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,KAAK,KAAI;gBAC3B,KAAoC,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAA,KAAA,EAAQ,IAAI,CAAA,CAAE,CAAC;AACrF,aAAC,CAAC,CAAC;YACH,MAAM,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;YACrC,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACrD,SAAC,CAAC,CAAC;AACP,KAAC,CAAC,CAAC;AAEH,IAAA,OAAO,UAAU,CAAC;AACtB"}
|