@croct/plug-react 0.10.0 → 0.11.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.
Files changed (99) hide show
  1. package/CroctProvider.cjs +81 -0
  2. package/CroctProvider.d.cts +11 -0
  3. package/CroctProvider.d.ts +8 -4
  4. package/CroctProvider.js +57 -46
  5. package/api.cjs +22 -0
  6. package/{src/react-app-env.d.ts → api.d.cts} +1 -0
  7. package/api.d.ts +1 -0
  8. package/api.js +1 -18
  9. package/components/Personalization/index.cjs +36 -0
  10. package/components/Personalization/index.d.cts +13 -0
  11. package/components/Personalization/index.d.ts +7 -4
  12. package/components/Personalization/index.js +10 -11
  13. package/components/Slot/index.cjs +36 -0
  14. package/components/Slot/index.d.cts +22 -0
  15. package/components/Slot/index.d.ts +9 -6
  16. package/components/Slot/index.js +10 -12
  17. package/components/index.cjs +24 -0
  18. package/components/index.d.cts +9 -0
  19. package/components/index.d.ts +9 -2
  20. package/components/index.js +2 -19
  21. package/global.d.cjs +1 -0
  22. package/{src/global.d.ts → global.d.d.cts} +1 -1
  23. package/global.d.d.ts +7 -0
  24. package/global.d.js +0 -0
  25. package/hash.cjs +36 -0
  26. package/hash.d.cts +2 -0
  27. package/hash.d.ts +2 -1
  28. package/hash.js +10 -11
  29. package/hooks/Cache.cjs +88 -0
  30. package/hooks/Cache.d.cts +9 -0
  31. package/hooks/Cache.d.ts +4 -17
  32. package/hooks/Cache.js +58 -56
  33. package/hooks/index.cjs +26 -0
  34. package/hooks/index.d.cts +8 -0
  35. package/hooks/index.d.ts +8 -3
  36. package/hooks/index.js +3 -20
  37. package/hooks/useContent.cjs +93 -0
  38. package/hooks/useContent.d.cts +20 -0
  39. package/hooks/useContent.d.ts +6 -5
  40. package/hooks/useContent.js +66 -42
  41. package/hooks/useCroct.cjs +38 -0
  42. package/hooks/useCroct.d.cts +5 -0
  43. package/hooks/useCroct.d.ts +4 -1
  44. package/hooks/useCroct.js +12 -12
  45. package/hooks/useEvaluation.cjs +85 -0
  46. package/hooks/useEvaluation.d.cts +14 -0
  47. package/hooks/useEvaluation.d.ts +5 -3
  48. package/hooks/useEvaluation.js +54 -45
  49. package/hooks/useLoader.cjs +82 -0
  50. package/hooks/useLoader.d.cts +7 -0
  51. package/hooks/useLoader.d.ts +5 -3
  52. package/hooks/useLoader.js +54 -59
  53. package/index.cjs +32 -0
  54. package/index.d.cts +13 -0
  55. package/index.d.ts +10 -3
  56. package/index.js +6 -23
  57. package/package.json +42 -11
  58. package/react-app-env.d.cjs +1 -0
  59. package/react-app-env.d.d.cts +2 -0
  60. package/react-app-env.d.d.ts +2 -0
  61. package/react-app-env.d.js +0 -0
  62. package/ssr-polyfills.cjs +86 -0
  63. package/ssr-polyfills.d.cts +2 -0
  64. package/ssr-polyfills.d.ts +2 -3
  65. package/ssr-polyfills.js +49 -64
  66. package/CroctProvider.js.map +0 -1
  67. package/api.js.map +0 -1
  68. package/components/Personalization/index.js.map +0 -1
  69. package/components/Slot/index.js.map +0 -1
  70. package/components/index.js.map +0 -1
  71. package/hash.js.map +0 -1
  72. package/hooks/Cache.js.map +0 -1
  73. package/hooks/index.js.map +0 -1
  74. package/hooks/useContent.js.map +0 -1
  75. package/hooks/useCroct.js.map +0 -1
  76. package/hooks/useEvaluation.js.map +0 -1
  77. package/hooks/useLoader.js.map +0 -1
  78. package/index.js.map +0 -1
  79. package/src/api.ts +0 -1
  80. package/src/components/index.ts +0 -2
  81. package/src/hash.test.ts +0 -22
  82. package/src/hash.ts +0 -12
  83. package/src/hooks/Cache.test.ts +0 -280
  84. package/src/hooks/Cache.ts +0 -97
  85. package/src/hooks/index.ts +0 -3
  86. package/src/hooks/useContent.ssr.test.ts +0 -23
  87. package/src/hooks/useContent.test.ts +0 -183
  88. package/src/hooks/useContent.ts +0 -107
  89. package/src/hooks/useCroct.ts +0 -16
  90. package/src/hooks/useEvaluation.ssr.test.ts +0 -23
  91. package/src/hooks/useEvaluation.test.ts +0 -180
  92. package/src/hooks/useEvaluation.ts +0 -94
  93. package/src/hooks/useLoader.test.ts +0 -407
  94. package/src/hooks/useLoader.ts +0 -84
  95. package/src/index.ts +0 -6
  96. package/src/ssr-polyfills.ssr.test.ts +0 -46
  97. package/src/ssr-polyfills.test.ts +0 -65
  98. package/src/ssr-polyfills.ts +0 -70
  99. 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 };
@@ -1,7 +1,11 @@
1
- import { FunctionComponent, PropsWithChildren } from 'react';
1
+ import * as react from 'react';
2
+ import { PropsWithChildren, FunctionComponent } from 'react';
2
3
  import { Configuration, Plug } from '@croct/plug';
3
- export type CroctProviderProps = PropsWithChildren<Configuration & Required<Pick<Configuration, 'appId'>>>;
4
- export declare const CroctContext: import("react").Context<{
4
+
5
+ type CroctProviderProps = PropsWithChildren<Configuration & Required<Pick<Configuration, 'appId'>>>;
6
+ declare const CroctContext: react.Context<{
5
7
  plug: Plug;
6
8
  } | null>;
7
- export declare const CroctProvider: FunctionComponent<CroctProviderProps>;
9
+ declare const CroctProvider: FunctionComponent<CroctProviderProps>;
10
+
11
+ export { CroctContext, CroctProvider, type CroctProviderProps };
package/CroctProvider.js CHANGED
@@ -1,51 +1,62 @@
1
- "use strict";
2
- 'use client';
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.CroctProvider = exports.CroctContext = void 0;
5
- const jsx_runtime_1 = require("react/jsx-runtime");
6
- const react_1 = require("react");
7
- const ssr_polyfills_1 = require("./ssr-polyfills");
8
- exports.CroctContext = (0, react_1.createContext)(null);
9
- exports.CroctContext.displayName = 'CroctContext';
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
- const ref = (0, react_1.useRef)(value);
12
- ref.current = value;
13
- return ref;
14
+ const ref = useRef(value);
15
+ ref.current = value;
16
+ return ref;
14
17
  }
15
18
  const CroctProvider = (props) => {
16
- const { children, ...configuration } = props;
17
- const parent = (0, react_1.useContext)(exports.CroctContext);
18
- const baseConfiguration = useLiveRef(configuration);
19
- if (parent !== null) {
20
- throw new Error('You cannot render <CroctProvider> inside another <CroctProvider>. '
21
- + 'Croct should only be initialized once in the application.');
22
- }
23
- const context = (0, react_1.useMemo)(() => ({
24
- get plug() {
25
- if (!ssr_polyfills_1.croct.initialized) {
26
- ssr_polyfills_1.croct.plug(baseConfiguration.current);
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 new Proxy(ssr_polyfills_1.croct, {
29
- get: function getProperty(target, property) {
30
- if (property === 'plug') {
31
- return (options) => {
32
- target.plug({ ...baseConfiguration.current, ...options });
33
- };
34
- }
35
- return target[property];
36
- },
37
- });
38
- },
39
- }), [baseConfiguration]);
40
- (0, react_1.useEffect)(() => {
41
- ssr_polyfills_1.croct.plug(baseConfiguration.current);
42
- return () => {
43
- ssr_polyfills_1.croct.unplug().catch(() => {
44
- // Suppress errors.
45
- });
46
- };
47
- }, [baseConfiguration]);
48
- return ((0, jsx_runtime_1.jsx)(exports.CroctContext.Provider, { value: context, children: children }));
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
+ });
@@ -1 +1,2 @@
1
1
  /// <reference types="react-scripts" />
2
+ export * from '@croct/plug/api';
package/api.d.ts CHANGED
@@ -1 +1,2 @@
1
+ /// <reference types="react-scripts" />
1
2
  export * from '@croct/plug/api';
package/api.js CHANGED
@@ -1,18 +1 @@
1
- "use strict";
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
- export type PersonalizationProps<T extends JsonValue = JsonValue, I = T, F = T> = UseEvaluationOptions<I, F> & {
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
- export declare function Personalization<T extends JsonValue, I, F>(props: Extract<T | I | F, JsonValue> extends never ? PersonalizationProps : PersonalizationProps<T, I, F>): ReactElement;
10
- export {};
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 strict";
2
- 'use client';
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.Personalization = Personalization;
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
- const { query, children, ...options } = props;
10
- const result = (0, hooks_1.useEvaluation)(query, options);
11
- return ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: children(result) }));
6
+ const { query, children, ...options } = props;
7
+ const result = useEvaluation(query, options);
8
+ return /* @__PURE__ */ jsx(Fragment, { children: children(result) });
12
9
  }
13
- //# sourceMappingURL=index.js.map
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 { ReactElement, ReactNode } from 'react';
2
- import { SlotContent, VersionedSlotId, VersionedSlotMap } from '@croct/plug/slot';
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
- export type SlotProps<P, I = P, F = P, S extends VersionedSlotId = VersionedSlotId> = UseContentOptions<I, F> & {
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
- export declare const Slot: SlotComponent;
19
- export {};
20
+ declare const Slot: SlotComponent;
21
+
22
+ export { Slot, type SlotProps };
@@ -1,14 +1,12 @@
1
- "use strict";
2
- 'use client';
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.Slot = void 0;
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
- const { id, children, ...options } = props;
10
- const data = (0, hooks_1.useContent)(id, options);
11
- return (0, jsx_runtime_1.jsx)(react_1.Fragment, { children: children(data) });
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';
@@ -1,2 +1,9 @@
1
- export * from './Personalization';
2
- export * from './Slot';
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';
@@ -1,19 +1,2 @@
1
- "use strict";
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("./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";
@@ -1,4 +1,4 @@
1
- import {EapFeatures} from '@croct/plug/eap';
1
+ import { EapFeatures } from '@croct/plug/eap';
2
2
 
3
3
  declare global {
4
4
  interface Window {
package/global.d.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { EapFeatures } from '@croct/plug/eap';
2
+
3
+ declare global {
4
+ interface Window {
5
+ croctEap?: Partial<EapFeatures>;
6
+ }
7
+ }
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
@@ -0,0 +1,2 @@
1
+
2
+ export { }
package/hash.d.ts CHANGED
@@ -1 +1,2 @@
1
- export declare function hash(value: string): string;
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
- let code = 0;
6
- for (const char of value) {
7
- const charCode = char.charCodeAt(0);
8
- code = (code << 5) - code + charCode;
9
- code |= 0; // Convert to 32bit integer
10
- }
11
- return code.toString(16);
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
- //# sourceMappingURL=hash.js.map
10
+ export {
11
+ hash
12
+ };