@croct/plug-react 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CroctProvider.cjs +81 -0
- package/CroctProvider.d.cts +11 -0
- package/CroctProvider.d.ts +8 -4
- package/CroctProvider.js +57 -46
- package/api.cjs +22 -0
- package/{src/react-app-env.d.ts → api.d.cts} +1 -0
- package/api.d.ts +1 -0
- package/api.js +1 -18
- package/components/Personalization/index.cjs +36 -0
- package/components/Personalization/index.d.cts +13 -0
- package/components/Personalization/index.d.ts +7 -4
- package/components/Personalization/index.js +10 -11
- package/components/Slot/index.cjs +36 -0
- package/components/Slot/index.d.cts +22 -0
- package/components/Slot/index.d.ts +9 -6
- package/components/Slot/index.js +10 -12
- package/components/index.cjs +24 -0
- package/components/index.d.cts +9 -0
- package/components/index.d.ts +9 -2
- package/components/index.js +2 -19
- package/global.d.cjs +1 -0
- package/{src/global.d.ts → global.d.d.cts} +1 -1
- package/global.d.d.ts +7 -0
- package/global.d.js +0 -0
- package/hash.cjs +36 -0
- package/hash.d.cts +2 -0
- package/hash.d.ts +2 -1
- package/hash.js +10 -11
- package/hooks/Cache.cjs +88 -0
- package/hooks/Cache.d.cts +9 -0
- package/hooks/Cache.d.ts +4 -17
- package/hooks/Cache.js +58 -56
- package/hooks/index.cjs +26 -0
- package/hooks/index.d.cts +8 -0
- package/hooks/index.d.ts +8 -3
- package/hooks/index.js +3 -20
- package/hooks/useContent.cjs +92 -0
- package/hooks/useContent.d.cts +20 -0
- package/hooks/useContent.d.ts +6 -5
- package/hooks/useContent.js +65 -42
- package/hooks/useCroct.cjs +38 -0
- package/hooks/useCroct.d.cts +5 -0
- package/hooks/useCroct.d.ts +4 -1
- package/hooks/useCroct.js +12 -12
- package/hooks/useEvaluation.cjs +85 -0
- package/hooks/useEvaluation.d.cts +14 -0
- package/hooks/useEvaluation.d.ts +5 -3
- package/hooks/useEvaluation.js +54 -45
- package/hooks/useLoader.cjs +82 -0
- package/hooks/useLoader.d.cts +7 -0
- package/hooks/useLoader.d.ts +5 -3
- package/hooks/useLoader.js +54 -59
- package/index.cjs +32 -0
- package/index.d.cts +13 -0
- package/index.d.ts +10 -3
- package/index.js +6 -23
- package/package.json +42 -11
- package/react-app-env.d.cjs +1 -0
- package/react-app-env.d.d.cts +2 -0
- package/react-app-env.d.d.ts +2 -0
- package/react-app-env.d.js +0 -0
- package/ssr-polyfills.cjs +86 -0
- package/ssr-polyfills.d.cts +2 -0
- package/ssr-polyfills.d.ts +2 -3
- package/ssr-polyfills.js +49 -64
- package/CroctProvider.js.map +0 -1
- package/api.js.map +0 -1
- package/components/Personalization/index.js.map +0 -1
- package/components/Slot/index.js.map +0 -1
- package/components/index.js.map +0 -1
- package/hash.js.map +0 -1
- package/hooks/Cache.js.map +0 -1
- package/hooks/index.js.map +0 -1
- package/hooks/useContent.js.map +0 -1
- package/hooks/useCroct.js.map +0 -1
- package/hooks/useEvaluation.js.map +0 -1
- package/hooks/useLoader.js.map +0 -1
- package/index.js.map +0 -1
- package/src/api.ts +0 -1
- package/src/components/index.ts +0 -2
- package/src/hash.test.ts +0 -22
- package/src/hash.ts +0 -12
- package/src/hooks/Cache.test.ts +0 -280
- package/src/hooks/Cache.ts +0 -97
- package/src/hooks/index.ts +0 -3
- package/src/hooks/useContent.ssr.test.ts +0 -23
- package/src/hooks/useContent.test.ts +0 -183
- package/src/hooks/useContent.ts +0 -107
- package/src/hooks/useCroct.ts +0 -16
- package/src/hooks/useEvaluation.ssr.test.ts +0 -23
- package/src/hooks/useEvaluation.test.ts +0 -180
- package/src/hooks/useEvaluation.ts +0 -94
- package/src/hooks/useLoader.test.ts +0 -407
- package/src/hooks/useLoader.ts +0 -84
- package/src/index.ts +0 -6
- package/src/ssr-polyfills.ssr.test.ts +0 -46
- package/src/ssr-polyfills.test.ts +0 -65
- package/src/ssr-polyfills.ts +0 -70
- package/ssr-polyfills.js.map +0 -1
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var CroctProvider_exports = {};
|
|
21
|
+
__export(CroctProvider_exports, {
|
|
22
|
+
CroctContext: () => CroctContext,
|
|
23
|
+
CroctProvider: () => CroctProvider
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(CroctProvider_exports);
|
|
26
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
var import_ssr_polyfills = require('./ssr-polyfills.cjs');
|
|
29
|
+
const CroctContext = (0, import_react.createContext)(null);
|
|
30
|
+
CroctContext.displayName = "CroctContext";
|
|
31
|
+
function useLiveRef(value) {
|
|
32
|
+
const ref = (0, import_react.useRef)(value);
|
|
33
|
+
ref.current = value;
|
|
34
|
+
return ref;
|
|
35
|
+
}
|
|
36
|
+
const CroctProvider = (props) => {
|
|
37
|
+
const { children, ...configuration } = props;
|
|
38
|
+
const parent = (0, import_react.useContext)(CroctContext);
|
|
39
|
+
const baseConfiguration = useLiveRef(configuration);
|
|
40
|
+
if (parent !== null) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
"You cannot render <CroctProvider> inside another <CroctProvider>. Croct should only be initialized once in the application."
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
const context = (0, import_react.useMemo)(
|
|
46
|
+
() => ({
|
|
47
|
+
get plug() {
|
|
48
|
+
if (!import_ssr_polyfills.croct.initialized) {
|
|
49
|
+
import_ssr_polyfills.croct.plug(baseConfiguration.current);
|
|
50
|
+
}
|
|
51
|
+
return new Proxy(import_ssr_polyfills.croct, {
|
|
52
|
+
get: function getProperty(target, property) {
|
|
53
|
+
if (property === "plug") {
|
|
54
|
+
return (options) => {
|
|
55
|
+
target.plug({ ...baseConfiguration.current, ...options });
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return target[property];
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}),
|
|
63
|
+
[baseConfiguration]
|
|
64
|
+
);
|
|
65
|
+
(0, import_react.useEffect)(
|
|
66
|
+
() => {
|
|
67
|
+
import_ssr_polyfills.croct.plug(baseConfiguration.current);
|
|
68
|
+
return () => {
|
|
69
|
+
import_ssr_polyfills.croct.unplug().catch(() => {
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
[baseConfiguration]
|
|
74
|
+
);
|
|
75
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CroctContext.Provider, { value: context, children });
|
|
76
|
+
};
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 && (module.exports = {
|
|
79
|
+
CroctContext,
|
|
80
|
+
CroctProvider
|
|
81
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { PropsWithChildren, FunctionComponent } from 'react';
|
|
3
|
+
import { Configuration, Plug } from '@croct/plug';
|
|
4
|
+
|
|
5
|
+
type CroctProviderProps = PropsWithChildren<Configuration & Required<Pick<Configuration, 'appId'>>>;
|
|
6
|
+
declare const CroctContext: react.Context<{
|
|
7
|
+
plug: Plug;
|
|
8
|
+
} | null>;
|
|
9
|
+
declare const CroctProvider: FunctionComponent<CroctProviderProps>;
|
|
10
|
+
|
|
11
|
+
export { CroctContext, CroctProvider, type CroctProviderProps };
|
package/CroctProvider.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { PropsWithChildren, FunctionComponent } from 'react';
|
|
2
3
|
import { Configuration, Plug } from '@croct/plug';
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
type CroctProviderProps = PropsWithChildren<Configuration & Required<Pick<Configuration, 'appId'>>>;
|
|
6
|
+
declare const CroctContext: react.Context<{
|
|
5
7
|
plug: Plug;
|
|
6
8
|
} | null>;
|
|
7
|
-
|
|
9
|
+
declare const CroctProvider: FunctionComponent<CroctProviderProps>;
|
|
10
|
+
|
|
11
|
+
export { CroctContext, CroctProvider, type CroctProviderProps };
|
package/CroctProvider.js
CHANGED
|
@@ -1,51 +1,62 @@
|
|
|
1
|
-
"use
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
createContext,
|
|
5
|
+
useContext,
|
|
6
|
+
useEffect,
|
|
7
|
+
useMemo,
|
|
8
|
+
useRef
|
|
9
|
+
} from "react";
|
|
10
|
+
import { croct } from "./ssr-polyfills.js";
|
|
11
|
+
const CroctContext = createContext(null);
|
|
12
|
+
CroctContext.displayName = "CroctContext";
|
|
10
13
|
function useLiveRef(value) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
const ref = useRef(value);
|
|
15
|
+
ref.current = value;
|
|
16
|
+
return ref;
|
|
14
17
|
}
|
|
15
18
|
const CroctProvider = (props) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
const { children, ...configuration } = props;
|
|
20
|
+
const parent = useContext(CroctContext);
|
|
21
|
+
const baseConfiguration = useLiveRef(configuration);
|
|
22
|
+
if (parent !== null) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
"You cannot render <CroctProvider> inside another <CroctProvider>. Croct should only be initialized once in the application."
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
const context = useMemo(
|
|
28
|
+
() => ({
|
|
29
|
+
get plug() {
|
|
30
|
+
if (!croct.initialized) {
|
|
31
|
+
croct.plug(baseConfiguration.current);
|
|
32
|
+
}
|
|
33
|
+
return new Proxy(croct, {
|
|
34
|
+
get: function getProperty(target, property) {
|
|
35
|
+
if (property === "plug") {
|
|
36
|
+
return (options) => {
|
|
37
|
+
target.plug({ ...baseConfiguration.current, ...options });
|
|
38
|
+
};
|
|
27
39
|
}
|
|
28
|
-
return
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
return target[property];
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}),
|
|
45
|
+
[baseConfiguration]
|
|
46
|
+
);
|
|
47
|
+
useEffect(
|
|
48
|
+
() => {
|
|
49
|
+
croct.plug(baseConfiguration.current);
|
|
50
|
+
return () => {
|
|
51
|
+
croct.unplug().catch(() => {
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
[baseConfiguration]
|
|
56
|
+
);
|
|
57
|
+
return /* @__PURE__ */ jsx(CroctContext.Provider, { value: context, children });
|
|
58
|
+
};
|
|
59
|
+
export {
|
|
60
|
+
CroctContext,
|
|
61
|
+
CroctProvider
|
|
49
62
|
};
|
|
50
|
-
exports.CroctProvider = CroctProvider;
|
|
51
|
-
//# sourceMappingURL=CroctProvider.js.map
|
package/api.cjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var api_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(api_exports);
|
|
18
|
+
__reExport(api_exports, require("@croct/plug/api"), module.exports);
|
|
19
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
20
|
+
0 && (module.exports = {
|
|
21
|
+
...require("@croct/plug/api")
|
|
22
|
+
});
|
package/api.d.ts
CHANGED
package/api.js
CHANGED
|
@@ -1,18 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("@croct/plug/api"), exports);
|
|
18
|
-
//# sourceMappingURL=api.js.map
|
|
1
|
+
export * from "@croct/plug/api";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var Personalization_exports = {};
|
|
21
|
+
__export(Personalization_exports, {
|
|
22
|
+
Personalization: () => Personalization
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(Personalization_exports);
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_hooks = require('../../hooks/index.cjs');
|
|
28
|
+
function Personalization(props) {
|
|
29
|
+
const { query, children, ...options } = props;
|
|
30
|
+
const result = (0, import_hooks.useEvaluation)(query, options);
|
|
31
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Fragment, { children: children(result) });
|
|
32
|
+
}
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
Personalization
|
|
36
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { JsonValue } from '@croct/plug/sdk/json';
|
|
3
|
+
import { UseEvaluationOptions } from '../../hooks/useEvaluation.cjs';
|
|
4
|
+
import '@croct/sdk/facade/evaluatorFacade';
|
|
5
|
+
|
|
6
|
+
type Renderer<T> = (result: T) => ReactElement | string | number;
|
|
7
|
+
type PersonalizationProps<T extends JsonValue = JsonValue, I = T, F = T> = UseEvaluationOptions<I, F> & {
|
|
8
|
+
query: string;
|
|
9
|
+
children: Renderer<T | I | F>;
|
|
10
|
+
};
|
|
11
|
+
declare function Personalization<T extends JsonValue, I, F>(props: Extract<T | I | F, JsonValue> extends never ? PersonalizationProps : PersonalizationProps<T, I, F>): ReactElement;
|
|
12
|
+
|
|
13
|
+
export { Personalization, type PersonalizationProps };
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
2
|
import { JsonValue } from '@croct/plug/sdk/json';
|
|
3
|
-
import { UseEvaluationOptions } from '../../hooks';
|
|
3
|
+
import { UseEvaluationOptions } from '../../hooks/useEvaluation.js';
|
|
4
|
+
import '@croct/sdk/facade/evaluatorFacade';
|
|
5
|
+
|
|
4
6
|
type Renderer<T> = (result: T) => ReactElement | string | number;
|
|
5
|
-
|
|
7
|
+
type PersonalizationProps<T extends JsonValue = JsonValue, I = T, F = T> = UseEvaluationOptions<I, F> & {
|
|
6
8
|
query: string;
|
|
7
9
|
children: Renderer<T | I | F>;
|
|
8
10
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
declare function Personalization<T extends JsonValue, I, F>(props: Extract<T | I | F, JsonValue> extends never ? PersonalizationProps : PersonalizationProps<T, I, F>): ReactElement;
|
|
12
|
+
|
|
13
|
+
export { Personalization, type PersonalizationProps };
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
"use
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
const hooks_1 = require("../../hooks");
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Fragment } from "react";
|
|
4
|
+
import { useEvaluation } from "../../hooks/index.js";
|
|
8
5
|
function Personalization(props) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
const { query, children, ...options } = props;
|
|
7
|
+
const result = useEvaluation(query, options);
|
|
8
|
+
return /* @__PURE__ */ jsx(Fragment, { children: children(result) });
|
|
12
9
|
}
|
|
13
|
-
|
|
10
|
+
export {
|
|
11
|
+
Personalization
|
|
12
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var Slot_exports = {};
|
|
21
|
+
__export(Slot_exports, {
|
|
22
|
+
Slot: () => Slot
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(Slot_exports);
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_hooks = require('../../hooks/index.cjs');
|
|
28
|
+
const Slot = (props) => {
|
|
29
|
+
const { id, children, ...options } = props;
|
|
30
|
+
const data = (0, import_hooks.useContent)(id, options);
|
|
31
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Fragment, { children: children(data) });
|
|
32
|
+
};
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
Slot
|
|
36
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ReactNode, ReactElement } from 'react';
|
|
2
|
+
import { VersionedSlotId, VersionedSlotMap, SlotContent } from '@croct/plug/slot';
|
|
3
|
+
import { JsonObject } from '@croct/plug/sdk/json';
|
|
4
|
+
import { UseContentOptions } from '../../hooks/useContent.cjs';
|
|
5
|
+
import '@croct/plug/plug';
|
|
6
|
+
|
|
7
|
+
type Renderer<P> = (props: P) => ReactNode;
|
|
8
|
+
type SlotProps<P, I = P, F = P, S extends VersionedSlotId = VersionedSlotId> = UseContentOptions<I, F> & {
|
|
9
|
+
id: S;
|
|
10
|
+
children: Renderer<P | I | F>;
|
|
11
|
+
};
|
|
12
|
+
type SlotComponent = {
|
|
13
|
+
<P, I, F>(props: Extract<P | I | F, JsonObject> extends never ? SlotProps<JsonObject, never, never, keyof VersionedSlotMap extends never ? string : never> : SlotProps<P, I, F, keyof VersionedSlotMap extends never ? string : never>): ReactElement;
|
|
14
|
+
<S extends VersionedSlotId>(props: SlotProps<SlotContent<S>, never, never, S>): ReactElement;
|
|
15
|
+
<I, S extends VersionedSlotId>(props: SlotProps<SlotContent<S>, I, never, S>): ReactElement;
|
|
16
|
+
<F, S extends VersionedSlotId>(props: SlotProps<SlotContent<S>, never, F, S>): ReactElement;
|
|
17
|
+
<I, F, S extends VersionedSlotId>(props: SlotProps<SlotContent<S>, I, F, S>): ReactElement;
|
|
18
|
+
(props: SlotProps<void, void, void>): ReactElement;
|
|
19
|
+
};
|
|
20
|
+
declare const Slot: SlotComponent;
|
|
21
|
+
|
|
22
|
+
export { Slot, type SlotProps };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ReactNode, ReactElement } from 'react';
|
|
2
|
+
import { VersionedSlotId, VersionedSlotMap, SlotContent } from '@croct/plug/slot';
|
|
3
3
|
import { JsonObject } from '@croct/plug/sdk/json';
|
|
4
|
-
import { UseContentOptions } from '../../hooks';
|
|
4
|
+
import { UseContentOptions } from '../../hooks/useContent.js';
|
|
5
|
+
import '@croct/plug/plug';
|
|
6
|
+
|
|
5
7
|
type Renderer<P> = (props: P) => ReactNode;
|
|
6
|
-
|
|
8
|
+
type SlotProps<P, I = P, F = P, S extends VersionedSlotId = VersionedSlotId> = UseContentOptions<I, F> & {
|
|
7
9
|
id: S;
|
|
8
10
|
children: Renderer<P | I | F>;
|
|
9
11
|
};
|
|
@@ -15,5 +17,6 @@ type SlotComponent = {
|
|
|
15
17
|
<I, F, S extends VersionedSlotId>(props: SlotProps<SlotContent<S>, I, F, S>): ReactElement;
|
|
16
18
|
(props: SlotProps<void, void, void>): ReactElement;
|
|
17
19
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
declare const Slot: SlotComponent;
|
|
21
|
+
|
|
22
|
+
export { Slot, type SlotProps };
|
package/components/Slot/index.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
"use
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
const hooks_1 = require("../../hooks");
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Fragment } from "react";
|
|
4
|
+
import { useContent } from "../../hooks/index.js";
|
|
8
5
|
const Slot = (props) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
const { id, children, ...options } = props;
|
|
7
|
+
const data = useContent(id, options);
|
|
8
|
+
return /* @__PURE__ */ jsx(Fragment, { children: children(data) });
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
Slot
|
|
12
12
|
};
|
|
13
|
-
exports.Slot = Slot;
|
|
14
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var components_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(components_exports);
|
|
18
|
+
__reExport(components_exports, require('./Personalization/index.cjs'), module.exports);
|
|
19
|
+
__reExport(components_exports, require('./Slot/index.cjs'), module.exports);
|
|
20
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
21
|
+
0 && (module.exports = {
|
|
22
|
+
...require('./Personalization/index.cjs'),
|
|
23
|
+
...require('./Slot/index.cjs')
|
|
24
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { Personalization, PersonalizationProps } from './Personalization/index.cjs';
|
|
2
|
+
export { Slot, SlotProps } from './Slot/index.cjs';
|
|
3
|
+
import 'react';
|
|
4
|
+
import '@croct/plug/sdk/json';
|
|
5
|
+
import '../hooks/useEvaluation.cjs';
|
|
6
|
+
import '@croct/sdk/facade/evaluatorFacade';
|
|
7
|
+
import '@croct/plug/slot';
|
|
8
|
+
import '../hooks/useContent.cjs';
|
|
9
|
+
import '@croct/plug/plug';
|
package/components/index.d.ts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { Personalization, PersonalizationProps } from './Personalization/index.js';
|
|
2
|
+
export { Slot, SlotProps } from './Slot/index.js';
|
|
3
|
+
import 'react';
|
|
4
|
+
import '@croct/plug/sdk/json';
|
|
5
|
+
import '../hooks/useEvaluation.js';
|
|
6
|
+
import '@croct/sdk/facade/evaluatorFacade';
|
|
7
|
+
import '@croct/plug/slot';
|
|
8
|
+
import '../hooks/useContent.js';
|
|
9
|
+
import '@croct/plug/plug';
|
package/components/index.js
CHANGED
|
@@ -1,19 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./Personalization"), exports);
|
|
18
|
-
__exportStar(require("./Slot"), exports);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from "./Personalization/index.js";
|
|
2
|
+
export * from "./Slot/index.js";
|
package/global.d.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/global.d.d.ts
ADDED
package/global.d.js
ADDED
|
File without changes
|
package/hash.cjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
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 hash_exports = {};
|
|
20
|
+
__export(hash_exports, {
|
|
21
|
+
hash: () => hash
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(hash_exports);
|
|
24
|
+
function hash(value) {
|
|
25
|
+
let code = 0;
|
|
26
|
+
for (const char of value) {
|
|
27
|
+
const charCode = char.charCodeAt(0);
|
|
28
|
+
code = (code << 5) - code + charCode;
|
|
29
|
+
code |= 0;
|
|
30
|
+
}
|
|
31
|
+
return code.toString(16);
|
|
32
|
+
}
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
hash
|
|
36
|
+
});
|
package/hash.d.cts
ADDED
package/hash.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
export { }
|
package/hash.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hash = hash;
|
|
4
1
|
function hash(value) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
let code = 0;
|
|
3
|
+
for (const char of value) {
|
|
4
|
+
const charCode = char.charCodeAt(0);
|
|
5
|
+
code = (code << 5) - code + charCode;
|
|
6
|
+
code |= 0;
|
|
7
|
+
}
|
|
8
|
+
return code.toString(16);
|
|
12
9
|
}
|
|
13
|
-
|
|
10
|
+
export {
|
|
11
|
+
hash
|
|
12
|
+
};
|