@editframe/react 0.35.0-beta → 0.36.1-beta

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.
@@ -1,12 +1,9 @@
1
- import { __toESM } from "../_virtual/rolldown_runtime.js";
2
- import { require_react_dom } from "../node_modules/react-dom/index.js";
3
- import { require_client } from "../node_modules/react-dom/client.js";
4
1
  import { useEffect, useRef } from "react";
2
+ import * as ReactDOM from "react-dom/client";
3
+ import { flushSync } from "react-dom";
5
4
  import { jsx, jsxs } from "react/jsx-runtime";
6
5
 
7
6
  //#region src/components/TimelineRoot.tsx
8
- var import_client = /* @__PURE__ */ __toESM(require_client());
9
- var import_react_dom = /* @__PURE__ */ __toESM(require_react_dom());
10
7
  /**
11
8
  * TimelineRoot - Factory wrapper for React-based timelines.
12
9
  *
@@ -47,8 +44,8 @@ const TimelineRoot = ({ id, component: Component, className, style, children })
47
44
  return;
48
45
  }
49
46
  cloneEl.remove();
50
- const root = import_client.createRoot(cloneContainer);
51
- (0, import_react_dom.flushSync)(() => {
47
+ const root = ReactDOM.createRoot(cloneContainer);
48
+ flushSync(() => {
52
49
  root.render(/* @__PURE__ */ jsx(Component, {}));
53
50
  });
54
51
  const newTimegroup = cloneContainer.querySelector("ef-timegroup");
@@ -1 +1 @@
1
- {"version":3,"file":"TimelineRoot.js","names":["TimelineRoot: React.FC<TimelineRootProps>"],"sources":["../../src/components/TimelineRoot.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as ReactDOM from 'react-dom/client';\nimport { flushSync } from 'react-dom';\nimport { useEffect, useRef } from 'react';\nimport type { EFTimegroup } from '@editframe/elements';\n\ninterface TimelineRootProps {\n /** Unique identifier for the root timegroup */\n id: string;\n /** React component that renders the timeline content (must include a Timegroup at root) */\n component: React.ComponentType;\n /** Optional CSS class name for the container */\n className?: string;\n /** Optional inline styles for the container */\n style?: React.CSSProperties;\n /** Optional children to render alongside the component (e.g., Configuration wrapper) */\n children?: React.ReactNode;\n}\n\n/**\n * TimelineRoot - Factory wrapper for React-based timelines.\n * \n * This component enables proper clone rendering by providing a factory pattern\n * for creating fully functional timeline instances. When render clones are created\n * (for exports, thumbnails, etc.), the initializer re-renders the React component\n * tree to ensure all JavaScript state and React lifecycle methods work correctly.\n * \n * @example\n * ```tsx\n * const MyTimelineContent = () => (\n * <Timegroup mode=\"sequence\">\n * <MyScenes />\n * </Timegroup>\n * );\n * \n * // Wrap with Configuration if needed\n * <Configuration apiHost=\"...\">\n * <TimelineRoot id=\"root\" component={MyTimelineContent} />\n * </Configuration>\n * ```\n */\nexport const TimelineRoot: React.FC<TimelineRootProps> = ({\n id,\n component: Component,\n className,\n style,\n children,\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n \n useEffect(() => {\n const container = containerRef.current;\n if (!container) return;\n \n // Find the root timegroup rendered by Component\n const timegroup = container.querySelector('ef-timegroup') as EFTimegroup;\n if (!timegroup) {\n console.warn('[TimelineRoot] No ef-timegroup found in component. Ensure your component renders a Timegroup.');\n return;\n }\n \n // Ensure the timegroup has the specified ID\n timegroup.id = id;\n \n // Register factory initializer - MUST be synchronous\n // Uses flushSync to force React to render synchronously\n timegroup.initializer = (cloneEl: EFTimegroup) => {\n const cloneContainer = cloneEl.parentElement;\n if (!cloneContainer) {\n console.error('[TimelineRoot] No parent container for clone');\n return;\n }\n \n // Remove the cloned DOM - React will render a fresh component tree\n // The cloned DOM doesn't have React bindings, so we need to replace it\n cloneEl.remove();\n \n // Create React root for the clone container\n const root = ReactDOM.createRoot(cloneContainer);\n \n // Use flushSync to render synchronously (required by initializer contract)\n // This ensures the component tree is fully rendered before initializer returns\n flushSync(() => {\n root.render(<Component />);\n });\n \n // Find the new timegroup rendered by React and store the React root on it\n // This is needed for cleanup in createRenderClone\n const newTimegroup = cloneContainer.querySelector('ef-timegroup');\n if (newTimegroup) {\n (newTimegroup as any)._reactRoot = root;\n } else {\n // Store root on container so we can still clean up\n (cloneContainer as any)._reactRoot = root;\n console.error('[TimelineRoot] No ef-timegroup found after React render');\n }\n };\n \n // Cleanup: remove initializer when component unmounts\n return () => {\n timegroup.initializer = undefined;\n };\n }, [id, Component]);\n \n return (\n <div \n ref={containerRef} \n className={className} \n style={{ display: 'contents', ...style }}\n >\n {children}\n <Component />\n </div>\n );\n};\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAaA,gBAA6C,EACxD,IACA,WAAW,WACX,WACA,OACA,eACI;CACJ,MAAM,eAAe,OAAuB,KAAK;AAEjD,iBAAgB;EACd,MAAM,YAAY,aAAa;AAC/B,MAAI,CAAC,UAAW;EAGhB,MAAM,YAAY,UAAU,cAAc,eAAe;AACzD,MAAI,CAAC,WAAW;AACd,WAAQ,KAAK,gGAAgG;AAC7G;;AAIF,YAAU,KAAK;AAIf,YAAU,eAAe,YAAyB;GAChD,MAAM,iBAAiB,QAAQ;AAC/B,OAAI,CAAC,gBAAgB;AACnB,YAAQ,MAAM,+CAA+C;AAC7D;;AAKF,WAAQ,QAAQ;GAGhB,MAAM,qBAAgB,WAAW,eAAe;AAIhD,yCAAgB;AACd,SAAK,OAAO,oBAAC,cAAY,CAAC;KAC1B;GAIF,MAAM,eAAe,eAAe,cAAc,eAAe;AACjE,OAAI,aACF,CAAC,aAAqB,aAAa;QAC9B;AAEL,IAAC,eAAuB,aAAa;AACrC,YAAQ,MAAM,0DAA0D;;;AAK5E,eAAa;AACX,aAAU,cAAc;;IAEzB,CAAC,IAAI,UAAU,CAAC;AAEnB,QACE,qBAAC;EACC,KAAK;EACM;EACX,OAAO;GAAE,SAAS;GAAY,GAAG;GAAO;aAEvC,UACD,oBAAC,cAAY;GACT"}
1
+ {"version":3,"file":"TimelineRoot.js","names":["TimelineRoot: React.FC<TimelineRootProps>"],"sources":["../../src/components/TimelineRoot.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as ReactDOM from 'react-dom/client';\nimport { flushSync } from 'react-dom';\nimport { useEffect, useRef } from 'react';\nimport type { EFTimegroup } from '@editframe/elements';\n\ninterface TimelineRootProps {\n /** Unique identifier for the root timegroup */\n id: string;\n /** React component that renders the timeline content (must include a Timegroup at root) */\n component: React.ComponentType;\n /** Optional CSS class name for the container */\n className?: string;\n /** Optional inline styles for the container */\n style?: React.CSSProperties;\n /** Optional children to render alongside the component (e.g., Configuration wrapper) */\n children?: React.ReactNode;\n}\n\n/**\n * TimelineRoot - Factory wrapper for React-based timelines.\n * \n * This component enables proper clone rendering by providing a factory pattern\n * for creating fully functional timeline instances. When render clones are created\n * (for exports, thumbnails, etc.), the initializer re-renders the React component\n * tree to ensure all JavaScript state and React lifecycle methods work correctly.\n * \n * @example\n * ```tsx\n * const MyTimelineContent = () => (\n * <Timegroup mode=\"sequence\">\n * <MyScenes />\n * </Timegroup>\n * );\n * \n * // Wrap with Configuration if needed\n * <Configuration apiHost=\"...\">\n * <TimelineRoot id=\"root\" component={MyTimelineContent} />\n * </Configuration>\n * ```\n */\nexport const TimelineRoot: React.FC<TimelineRootProps> = ({\n id,\n component: Component,\n className,\n style,\n children,\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n \n useEffect(() => {\n const container = containerRef.current;\n if (!container) return;\n \n // Find the root timegroup rendered by Component\n const timegroup = container.querySelector('ef-timegroup') as EFTimegroup;\n if (!timegroup) {\n console.warn('[TimelineRoot] No ef-timegroup found in component. Ensure your component renders a Timegroup.');\n return;\n }\n \n // Ensure the timegroup has the specified ID\n timegroup.id = id;\n \n // Register factory initializer - MUST be synchronous\n // Uses flushSync to force React to render synchronously\n timegroup.initializer = (cloneEl: EFTimegroup) => {\n const cloneContainer = cloneEl.parentElement;\n if (!cloneContainer) {\n console.error('[TimelineRoot] No parent container for clone');\n return;\n }\n \n // Remove the cloned DOM - React will render a fresh component tree\n // The cloned DOM doesn't have React bindings, so we need to replace it\n cloneEl.remove();\n \n // Create React root for the clone container\n const root = ReactDOM.createRoot(cloneContainer);\n \n // Use flushSync to render synchronously (required by initializer contract)\n // This ensures the component tree is fully rendered before initializer returns\n flushSync(() => {\n root.render(<Component />);\n });\n \n // Find the new timegroup rendered by React and store the React root on it\n // This is needed for cleanup in createRenderClone\n const newTimegroup = cloneContainer.querySelector('ef-timegroup');\n if (newTimegroup) {\n (newTimegroup as any)._reactRoot = root;\n } else {\n // Store root on container so we can still clean up\n (cloneContainer as any)._reactRoot = root;\n console.error('[TimelineRoot] No ef-timegroup found after React render');\n }\n };\n \n // Cleanup: remove initializer when component unmounts\n return () => {\n timegroup.initializer = undefined;\n };\n }, [id, Component]);\n \n return (\n <div \n ref={containerRef} \n className={className} \n style={{ display: 'contents', ...style }}\n >\n {children}\n <Component />\n </div>\n );\n};\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAaA,gBAA6C,EACxD,IACA,WAAW,WACX,WACA,OACA,eACI;CACJ,MAAM,eAAe,OAAuB,KAAK;AAEjD,iBAAgB;EACd,MAAM,YAAY,aAAa;AAC/B,MAAI,CAAC,UAAW;EAGhB,MAAM,YAAY,UAAU,cAAc,eAAe;AACzD,MAAI,CAAC,WAAW;AACd,WAAQ,KAAK,gGAAgG;AAC7G;;AAIF,YAAU,KAAK;AAIf,YAAU,eAAe,YAAyB;GAChD,MAAM,iBAAiB,QAAQ;AAC/B,OAAI,CAAC,gBAAgB;AACnB,YAAQ,MAAM,+CAA+C;AAC7D;;AAKF,WAAQ,QAAQ;GAGhB,MAAM,OAAO,SAAS,WAAW,eAAe;AAIhD,mBAAgB;AACd,SAAK,OAAO,oBAAC,cAAY,CAAC;KAC1B;GAIF,MAAM,eAAe,eAAe,cAAc,eAAe;AACjE,OAAI,aACF,CAAC,aAAqB,aAAa;QAC9B;AAEL,IAAC,eAAuB,aAAa;AACrC,YAAQ,MAAM,0DAA0D;;;AAK5E,eAAa;AACX,aAAU,cAAc;;IAEzB,CAAC,IAAI,UAAU,CAAC;AAEnB,QACE,qBAAC;EACC,KAAK;EACM;EACX,OAAO;GAAE,SAAS;GAAY,GAAG;GAAO;aAEvC,UACD,oBAAC,cAAY;GACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@editframe/react",
3
- "version": "0.35.0-beta",
3
+ "version": "0.36.1-beta",
4
4
  "description": "",
5
5
  "exports": {
6
6
  ".": {
@@ -22,7 +22,7 @@
22
22
  "author": "",
23
23
  "license": "UNLICENSED",
24
24
  "dependencies": {
25
- "@editframe/elements": "0.35.0-beta",
25
+ "@editframe/elements": "0.36.1-beta",
26
26
  "@lit/task": "^1.0.1",
27
27
  "lit": "^3.3.1",
28
28
  "react": "^18.3.0"
package/tsdown.config.ts CHANGED
@@ -47,7 +47,13 @@ const inlineCssPlugin = (): Plugin => ({
47
47
  export default defineConfig(
48
48
  createTsdownConfig({
49
49
  plugins: [inlineCssPlugin()],
50
- external: [/@editframe\/(elements|assets)/],
50
+ external: [
51
+ /@editframe\/(elements|assets)/,
52
+ "react",
53
+ "react-dom",
54
+ "react-dom/client",
55
+ "react/jsx-runtime",
56
+ ],
51
57
  additionalExports: {
52
58
  "./types.json": "./types.json",
53
59
  },
@@ -1,31 +0,0 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJS = (cb, mod) => function() {
9
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
13
- key = keys[i];
14
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
- get: ((k) => from[k]).bind(null, key),
16
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
- });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
22
- value: mod,
23
- enumerable: true
24
- }) : target, mod));
25
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
26
- if (typeof require !== "undefined") return require.apply(this, arguments);
27
- throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function.");
28
- });
29
-
30
- //#endregion
31
- export { __commonJS, __require, __toESM };