@fabricorg/experience-react 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ # Changelog
2
+
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [337e89c]
8
+ - Updated dependencies [9a5b18a]
9
+ - Updated dependencies [9b2e55b]
10
+ - Updated dependencies [0d1f6f6]
11
+ - @fabricorg/experience-runtime@0.2.0
12
+
13
+ ## 0.1.0
14
+
15
+ ### Minor Changes
16
+
17
+ - Add deterministic React rendering for scoped plans, fragment-event and named-binding
18
+ interfaces, and accessible missing-component recovery.
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies
23
+ - @fabricorg/experience-runtime@0.1.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Fabric
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,8 @@
1
+ # `@fabricorg/experience-react`
2
+
3
+ React adapter for scoped render plans. It maps renderer-neutral component names to an
4
+ application registry and gives each component only its declared event interface.
5
+ Missing components render an accessible alert.
6
+
7
+ The adapter does not parse releases, select variants, authorize requests, or import
8
+ either governed Host.
package/dist/index.cjs ADDED
@@ -0,0 +1,61 @@
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
+
20
+ // index.tsx
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ createExperienceReactRenderer: () => createExperienceReactRenderer
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+ var import_react = require("react");
27
+ function createExperienceReactRenderer(options) {
28
+ const Missing = options.missingComponent ?? DefaultMissingComponent;
29
+ const Renderer = ({ session }) => renderFragment(session.plan.root, session, options.components, Missing);
30
+ Renderer.displayName = "FabricExperienceRenderer";
31
+ return Renderer;
32
+ }
33
+ function renderFragment(fragment, session, components, Missing) {
34
+ const children = (fragment.children ?? []).map((child) => (0, import_react.createElement)(import_react.Fragment, { key: child.id }, renderFragment(child, session, components, Missing)));
35
+ if (fragment.component === void 0) return (0, import_react.createElement)(import_react.Fragment, null, ...children);
36
+ const Component = components[fragment.component];
37
+ if (!Component) return (0, import_react.createElement)(Missing, { name: fragment.component, fragmentId: fragment.id });
38
+ const events = fragment.events ?? [];
39
+ const bindings = fragment.bindings ?? [];
40
+ return (0, import_react.createElement)(Component, {
41
+ ...fragment.props ?? {},
42
+ experience: Object.freeze({
43
+ events,
44
+ bindings,
45
+ invoke: (eventName, parameters, idempotencyKey) => session.invoke(fragment.id, eventName, parameters, idempotencyKey),
46
+ read: (bindingName, parameters) => session.read(fragment.id, bindingName, parameters)
47
+ })
48
+ }, ...children);
49
+ }
50
+ function DefaultMissingComponent({ name, fragmentId }) {
51
+ return (0, import_react.createElement)(
52
+ "div",
53
+ { role: "alert", "data-fabric-fragment": fragmentId },
54
+ `Component "${name}" is unavailable.`
55
+ );
56
+ }
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ createExperienceReactRenderer
60
+ });
61
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../index.tsx"],"sourcesContent":["import {\n\tFragment,\n\tcreateElement,\n\ttype ComponentType,\n\ttype ReactElement,\n\ttype ReactNode,\n} from \"react\";\nimport type {\n\tExperienceSession,\n\tRenderPlanFragment,\n} from \"@fabricorg/experience-runtime\";\n\nexport interface ExperienceComponentActions {\n\tevents: readonly string[];\n\tbindings: readonly string[];\n\tinvoke(eventName: string, parameters: Record<string, unknown>, idempotencyKey?: string): Promise<unknown>;\n\tread(bindingName: string, parameters?: Record<string, unknown>): Promise<unknown>;\n}\n\nexport type ExperiencePackComponent = ComponentType<Record<string, unknown> & {\n\texperience: ExperienceComponentActions;\n\tchildren?: ReactNode;\n}>;\n\nexport interface ExperienceRendererProps {\n\tsession: ExperienceSession;\n}\n\nexport function createExperienceReactRenderer(options: {\n\tcomponents: Readonly<Record<string, ExperiencePackComponent>>;\n\tmissingComponent?: ComponentType<{ name: string; fragmentId: string }>;\n}): ComponentType<ExperienceRendererProps> {\n\tconst Missing = options.missingComponent ?? DefaultMissingComponent;\n\tconst Renderer = ({ session }: ExperienceRendererProps): ReactElement =>\n\t\trenderFragment(session.plan.root, session, options.components, Missing);\n\tRenderer.displayName = \"FabricExperienceRenderer\";\n\treturn Renderer;\n}\n\nfunction renderFragment(\n\tfragment: RenderPlanFragment,\n\tsession: ExperienceSession,\n\tcomponents: Readonly<Record<string, ExperiencePackComponent>>,\n\tMissing: ComponentType<{ name: string; fragmentId: string }>,\n): ReactElement {\n\tconst children = (fragment.children ?? []).map((child) =>\n\t\tcreateElement(Fragment, { key: child.id }, renderFragment(child, session, components, Missing)));\n\tif (fragment.component === undefined) return createElement(Fragment, null, ...children);\n\tconst Component = components[fragment.component];\n\tif (!Component) return createElement(Missing, { name: fragment.component, fragmentId: fragment.id });\n\tconst events = fragment.events ?? [];\n\tconst bindings = fragment.bindings ?? [];\n\treturn createElement(Component, {\n\t\t...(fragment.props ?? {}),\n\t\texperience: Object.freeze({\n\t\t\tevents,\n\t\t\tbindings,\n\t\t\tinvoke: (eventName: string, parameters: Record<string, unknown>, idempotencyKey?: string) =>\n\t\t\t\tsession.invoke(fragment.id, eventName, parameters, idempotencyKey),\n\t\t\tread: (bindingName: string, parameters?: Record<string, unknown>) =>\n\t\t\t\tsession.read(fragment.id, bindingName, parameters),\n\t\t}),\n\t}, ...children);\n}\n\nfunction DefaultMissingComponent({ name, fragmentId }: { name: string; fragmentId: string }): ReactElement {\n\treturn createElement(\n\t\t\"div\",\n\t\t{ role: \"alert\", \"data-fabric-fragment\": fragmentId },\n\t\t`Component \"${name}\" is unavailable.`,\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAMO;AAsBA,SAAS,8BAA8B,SAGH;AAC1C,QAAM,UAAU,QAAQ,oBAAoB;AAC5C,QAAM,WAAW,CAAC,EAAE,QAAQ,MAC3B,eAAe,QAAQ,KAAK,MAAM,SAAS,QAAQ,YAAY,OAAO;AACvE,WAAS,cAAc;AACvB,SAAO;AACR;AAEA,SAAS,eACR,UACA,SACA,YACA,SACe;AACf,QAAM,YAAY,SAAS,YAAY,CAAC,GAAG,IAAI,CAAC,cAC/C,4BAAc,uBAAU,EAAE,KAAK,MAAM,GAAG,GAAG,eAAe,OAAO,SAAS,YAAY,OAAO,CAAC,CAAC;AAChG,MAAI,SAAS,cAAc,OAAW,YAAO,4BAAc,uBAAU,MAAM,GAAG,QAAQ;AACtF,QAAM,YAAY,WAAW,SAAS,SAAS;AAC/C,MAAI,CAAC,UAAW,YAAO,4BAAc,SAAS,EAAE,MAAM,SAAS,WAAW,YAAY,SAAS,GAAG,CAAC;AACnG,QAAM,SAAS,SAAS,UAAU,CAAC;AACnC,QAAM,WAAW,SAAS,YAAY,CAAC;AACvC,aAAO,4BAAc,WAAW;AAAA,IAC/B,GAAI,SAAS,SAAS,CAAC;AAAA,IACvB,YAAY,OAAO,OAAO;AAAA,MACzB;AAAA,MACA;AAAA,MACA,QAAQ,CAAC,WAAmB,YAAqC,mBAChE,QAAQ,OAAO,SAAS,IAAI,WAAW,YAAY,cAAc;AAAA,MAClE,MAAM,CAAC,aAAqB,eAC3B,QAAQ,KAAK,SAAS,IAAI,aAAa,UAAU;AAAA,IACnD,CAAC;AAAA,EACF,GAAG,GAAG,QAAQ;AACf;AAEA,SAAS,wBAAwB,EAAE,MAAM,WAAW,GAAuD;AAC1G,aAAO;AAAA,IACN;AAAA,IACA,EAAE,MAAM,SAAS,wBAAwB,WAAW;AAAA,IACpD,cAAc,IAAI;AAAA,EACnB;AACD;","names":[]}
@@ -0,0 +1,25 @@
1
+ import { ComponentType, ReactNode } from 'react';
2
+ import { ExperienceSession } from '@fabricorg/experience-runtime';
3
+
4
+ interface ExperienceComponentActions {
5
+ events: readonly string[];
6
+ bindings: readonly string[];
7
+ invoke(eventName: string, parameters: Record<string, unknown>, idempotencyKey?: string): Promise<unknown>;
8
+ read(bindingName: string, parameters?: Record<string, unknown>): Promise<unknown>;
9
+ }
10
+ type ExperiencePackComponent = ComponentType<Record<string, unknown> & {
11
+ experience: ExperienceComponentActions;
12
+ children?: ReactNode;
13
+ }>;
14
+ interface ExperienceRendererProps {
15
+ session: ExperienceSession;
16
+ }
17
+ declare function createExperienceReactRenderer(options: {
18
+ components: Readonly<Record<string, ExperiencePackComponent>>;
19
+ missingComponent?: ComponentType<{
20
+ name: string;
21
+ fragmentId: string;
22
+ }>;
23
+ }): ComponentType<ExperienceRendererProps>;
24
+
25
+ export { type ExperienceComponentActions, type ExperiencePackComponent, type ExperienceRendererProps, createExperienceReactRenderer };
@@ -0,0 +1,25 @@
1
+ import { ComponentType, ReactNode } from 'react';
2
+ import { ExperienceSession } from '@fabricorg/experience-runtime';
3
+
4
+ interface ExperienceComponentActions {
5
+ events: readonly string[];
6
+ bindings: readonly string[];
7
+ invoke(eventName: string, parameters: Record<string, unknown>, idempotencyKey?: string): Promise<unknown>;
8
+ read(bindingName: string, parameters?: Record<string, unknown>): Promise<unknown>;
9
+ }
10
+ type ExperiencePackComponent = ComponentType<Record<string, unknown> & {
11
+ experience: ExperienceComponentActions;
12
+ children?: ReactNode;
13
+ }>;
14
+ interface ExperienceRendererProps {
15
+ session: ExperienceSession;
16
+ }
17
+ declare function createExperienceReactRenderer(options: {
18
+ components: Readonly<Record<string, ExperiencePackComponent>>;
19
+ missingComponent?: ComponentType<{
20
+ name: string;
21
+ fragmentId: string;
22
+ }>;
23
+ }): ComponentType<ExperienceRendererProps>;
24
+
25
+ export { type ExperienceComponentActions, type ExperiencePackComponent, type ExperienceRendererProps, createExperienceReactRenderer };
package/dist/index.js ADDED
@@ -0,0 +1,39 @@
1
+ // index.tsx
2
+ import {
3
+ Fragment,
4
+ createElement
5
+ } from "react";
6
+ function createExperienceReactRenderer(options) {
7
+ const Missing = options.missingComponent ?? DefaultMissingComponent;
8
+ const Renderer = ({ session }) => renderFragment(session.plan.root, session, options.components, Missing);
9
+ Renderer.displayName = "FabricExperienceRenderer";
10
+ return Renderer;
11
+ }
12
+ function renderFragment(fragment, session, components, Missing) {
13
+ const children = (fragment.children ?? []).map((child) => createElement(Fragment, { key: child.id }, renderFragment(child, session, components, Missing)));
14
+ if (fragment.component === void 0) return createElement(Fragment, null, ...children);
15
+ const Component = components[fragment.component];
16
+ if (!Component) return createElement(Missing, { name: fragment.component, fragmentId: fragment.id });
17
+ const events = fragment.events ?? [];
18
+ const bindings = fragment.bindings ?? [];
19
+ return createElement(Component, {
20
+ ...fragment.props ?? {},
21
+ experience: Object.freeze({
22
+ events,
23
+ bindings,
24
+ invoke: (eventName, parameters, idempotencyKey) => session.invoke(fragment.id, eventName, parameters, idempotencyKey),
25
+ read: (bindingName, parameters) => session.read(fragment.id, bindingName, parameters)
26
+ })
27
+ }, ...children);
28
+ }
29
+ function DefaultMissingComponent({ name, fragmentId }) {
30
+ return createElement(
31
+ "div",
32
+ { role: "alert", "data-fabric-fragment": fragmentId },
33
+ `Component "${name}" is unavailable.`
34
+ );
35
+ }
36
+ export {
37
+ createExperienceReactRenderer
38
+ };
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../index.tsx"],"sourcesContent":["import {\n\tFragment,\n\tcreateElement,\n\ttype ComponentType,\n\ttype ReactElement,\n\ttype ReactNode,\n} from \"react\";\nimport type {\n\tExperienceSession,\n\tRenderPlanFragment,\n} from \"@fabricorg/experience-runtime\";\n\nexport interface ExperienceComponentActions {\n\tevents: readonly string[];\n\tbindings: readonly string[];\n\tinvoke(eventName: string, parameters: Record<string, unknown>, idempotencyKey?: string): Promise<unknown>;\n\tread(bindingName: string, parameters?: Record<string, unknown>): Promise<unknown>;\n}\n\nexport type ExperiencePackComponent = ComponentType<Record<string, unknown> & {\n\texperience: ExperienceComponentActions;\n\tchildren?: ReactNode;\n}>;\n\nexport interface ExperienceRendererProps {\n\tsession: ExperienceSession;\n}\n\nexport function createExperienceReactRenderer(options: {\n\tcomponents: Readonly<Record<string, ExperiencePackComponent>>;\n\tmissingComponent?: ComponentType<{ name: string; fragmentId: string }>;\n}): ComponentType<ExperienceRendererProps> {\n\tconst Missing = options.missingComponent ?? DefaultMissingComponent;\n\tconst Renderer = ({ session }: ExperienceRendererProps): ReactElement =>\n\t\trenderFragment(session.plan.root, session, options.components, Missing);\n\tRenderer.displayName = \"FabricExperienceRenderer\";\n\treturn Renderer;\n}\n\nfunction renderFragment(\n\tfragment: RenderPlanFragment,\n\tsession: ExperienceSession,\n\tcomponents: Readonly<Record<string, ExperiencePackComponent>>,\n\tMissing: ComponentType<{ name: string; fragmentId: string }>,\n): ReactElement {\n\tconst children = (fragment.children ?? []).map((child) =>\n\t\tcreateElement(Fragment, { key: child.id }, renderFragment(child, session, components, Missing)));\n\tif (fragment.component === undefined) return createElement(Fragment, null, ...children);\n\tconst Component = components[fragment.component];\n\tif (!Component) return createElement(Missing, { name: fragment.component, fragmentId: fragment.id });\n\tconst events = fragment.events ?? [];\n\tconst bindings = fragment.bindings ?? [];\n\treturn createElement(Component, {\n\t\t...(fragment.props ?? {}),\n\t\texperience: Object.freeze({\n\t\t\tevents,\n\t\t\tbindings,\n\t\t\tinvoke: (eventName: string, parameters: Record<string, unknown>, idempotencyKey?: string) =>\n\t\t\t\tsession.invoke(fragment.id, eventName, parameters, idempotencyKey),\n\t\t\tread: (bindingName: string, parameters?: Record<string, unknown>) =>\n\t\t\t\tsession.read(fragment.id, bindingName, parameters),\n\t\t}),\n\t}, ...children);\n}\n\nfunction DefaultMissingComponent({ name, fragmentId }: { name: string; fragmentId: string }): ReactElement {\n\treturn createElement(\n\t\t\"div\",\n\t\t{ role: \"alert\", \"data-fabric-fragment\": fragmentId },\n\t\t`Component \"${name}\" is unavailable.`,\n\t);\n}\n"],"mappings":";AAAA;AAAA,EACC;AAAA,EACA;AAAA,OAIM;AAsBA,SAAS,8BAA8B,SAGH;AAC1C,QAAM,UAAU,QAAQ,oBAAoB;AAC5C,QAAM,WAAW,CAAC,EAAE,QAAQ,MAC3B,eAAe,QAAQ,KAAK,MAAM,SAAS,QAAQ,YAAY,OAAO;AACvE,WAAS,cAAc;AACvB,SAAO;AACR;AAEA,SAAS,eACR,UACA,SACA,YACA,SACe;AACf,QAAM,YAAY,SAAS,YAAY,CAAC,GAAG,IAAI,CAAC,UAC/C,cAAc,UAAU,EAAE,KAAK,MAAM,GAAG,GAAG,eAAe,OAAO,SAAS,YAAY,OAAO,CAAC,CAAC;AAChG,MAAI,SAAS,cAAc,OAAW,QAAO,cAAc,UAAU,MAAM,GAAG,QAAQ;AACtF,QAAM,YAAY,WAAW,SAAS,SAAS;AAC/C,MAAI,CAAC,UAAW,QAAO,cAAc,SAAS,EAAE,MAAM,SAAS,WAAW,YAAY,SAAS,GAAG,CAAC;AACnG,QAAM,SAAS,SAAS,UAAU,CAAC;AACnC,QAAM,WAAW,SAAS,YAAY,CAAC;AACvC,SAAO,cAAc,WAAW;AAAA,IAC/B,GAAI,SAAS,SAAS,CAAC;AAAA,IACvB,YAAY,OAAO,OAAO;AAAA,MACzB;AAAA,MACA;AAAA,MACA,QAAQ,CAAC,WAAmB,YAAqC,mBAChE,QAAQ,OAAO,SAAS,IAAI,WAAW,YAAY,cAAc;AAAA,MAClE,MAAM,CAAC,aAAqB,eAC3B,QAAQ,KAAK,SAAS,IAAI,aAAa,UAAU;AAAA,IACnD,CAAC;AAAA,EACF,GAAG,GAAG,QAAQ;AACf;AAEA,SAAS,wBAAwB,EAAE,MAAM,WAAW,GAAuD;AAC1G,SAAO;AAAA,IACN;AAAA,IACA,EAAE,MAAM,SAAS,wBAAwB,WAAW;AAAA,IACpD,cAAc,IAAI;AAAA,EACnB;AACD;","names":[]}
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@fabricorg/experience-react",
3
+ "version": "0.1.1",
4
+ "description": "React renderer adapter for scoped Fabric experience render plans.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "main": "./dist/index.cjs",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "browser": {
13
+ "types": "./dist/index.d.ts",
14
+ "default": "./dist/index.js"
15
+ },
16
+ "import": {
17
+ "types": "./dist/index.d.ts",
18
+ "default": "./dist/index.js"
19
+ },
20
+ "require": {
21
+ "types": "./dist/index.d.cts",
22
+ "default": "./dist/index.cjs"
23
+ }
24
+ }
25
+ },
26
+ "files": [
27
+ "dist",
28
+ "README.md",
29
+ "CHANGELOG.md",
30
+ "LICENSE"
31
+ ],
32
+ "dependencies": {
33
+ "@fabricorg/experience-runtime": "^0.2.0"
34
+ },
35
+ "peerDependencies": {
36
+ "react": "^18.3.0 || ^19.0.0"
37
+ },
38
+ "devDependencies": {
39
+ "@types/node": "^22.10.0",
40
+ "@types/react": "^19.2.0",
41
+ "@types/react-dom": "^19.2.0",
42
+ "react": "^19.2.0",
43
+ "react-dom": "^19.2.0",
44
+ "tsup": "^8.5.0",
45
+ "typescript": "^5.7.3",
46
+ "vitest": "^4.1.5"
47
+ },
48
+ "engines": {
49
+ "node": ">=20"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "scripts": {
55
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
56
+ "build": "tsup",
57
+ "type-check": "tsc --noEmit",
58
+ "test": "vitest run"
59
+ }
60
+ }