@zeus-js/output-react-wrapper 0.1.0-beta.4 → 0.1.0-beta.5

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,5 +1,5 @@
1
1
  /**
2
- * output-react-wrapper v0.1.0-beta.4
2
+ * output-react-wrapper v0.1.0-beta.5
3
3
  * (c) 2026 baicie
4
4
  * Released under the MIT License.
5
5
  **/
@@ -9,6 +9,7 @@ Object.defineProperties(exports, {
9
9
  });
10
10
  let _zeus_js_bundler_plugin = require("@zeus-js/bundler-plugin");
11
11
  let _zeus_js_component_dts = require("@zeus-js/component-dts");
12
+ let _lit_react = require("@lit/react");
12
13
  //#region packages/web-c/output-react-wrapper/src/generateReactIndex.ts
13
14
  function generateReactIndex(components, options) {
14
15
  const lines = [];
@@ -22,7 +23,7 @@ function generateReactIndex(components, options) {
22
23
  //#endregion
23
24
  //#region packages/web-c/output-react-wrapper/src/generateReactWrapper.ts
24
25
  function generateReactWrapper(input) {
25
- return input.mode === "event-bridge" ? generateEventBridgeReactWrapper(input) : generateMinimalReactWrapper(input);
26
+ return input.mode === "runtime" ? generateRuntimeReactWrapper(input) : input.mode === "event-bridge" ? generateEventBridgeReactWrapper(input) : generateMinimalReactWrapper(input);
26
27
  }
27
28
  function generateMinimalReactWrapper(input) {
28
29
  const { component, namedSlots, wcModuleId } = input;
@@ -275,6 +276,42 @@ function toKebabCase(value) {
275
276
  function toReactEventProp(value) {
276
277
  return `on${value.split("-").filter(Boolean).map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`).join("")}`;
277
278
  }
279
+ function generateRuntimeReactWrapper(input) {
280
+ const { component, namedSlots } = input;
281
+ const events = createRuntimeEventMap(component);
282
+ const slots = getNamedSlots(component, namedSlots);
283
+ return [
284
+ `import React from 'react'`,
285
+ `import { createComponent } from '@zeus-js/output-react-wrapper/runtime'`,
286
+ `import { defineCustomElement } from '../wc/loader.js'`,
287
+ ``,
288
+ `export const ${component.name} = createComponent({`,
289
+ ` react: React,`,
290
+ ` tagName: ${JSON.stringify(component.tag)},`,
291
+ ` defineCustomElement: () => defineCustomElement(${JSON.stringify(component.tag)}),`,
292
+ ` events: ${formatEventObject(events)},`,
293
+ ` slots: ${JSON.stringify(slots)},`,
294
+ ` displayName: ${JSON.stringify(component.name)},`,
295
+ `})`,
296
+ ``
297
+ ].join("\n");
298
+ }
299
+ function createRuntimeEventMap(component) {
300
+ const events = {};
301
+ for (const [key, event] of Object.entries(component.events)) {
302
+ var _event$key2, _event$name2, _event$reactName2;
303
+ const sourceEventName = (_event$key2 = event.key) !== null && _event$key2 !== void 0 ? _event$key2 : key;
304
+ const domEventName = (_event$name2 = event.name) !== null && _event$name2 !== void 0 ? _event$name2 : toKebabCase(sourceEventName);
305
+ const reactPropName = (_event$reactName2 = event.reactName) !== null && _event$reactName2 !== void 0 ? _event$reactName2 : toReactEventProp(sourceEventName);
306
+ events[reactPropName] = domEventName;
307
+ }
308
+ return events;
309
+ }
310
+ function formatEventObject(value) {
311
+ const entries = Object.entries(value);
312
+ if (!entries.length) return "{}";
313
+ return `{\n${entries.map(([key, item]) => ` ${JSON.stringify(key)}: ${JSON.stringify(item)}`).join(",\n")}\n }`;
314
+ }
278
315
  const PUSH_ALL_HELPER = `
279
316
  function pushAll(target, values) {
280
317
  for (const value of values) target.push(value);
@@ -296,6 +333,52 @@ function createNamedSlot(name, value) {
296
333
  }
297
334
  `;
298
335
  //#endregion
336
+ //#region packages/web-c/output-react-wrapper/src/runtime/createComponent.ts
337
+ function createComponent(options) {
338
+ var _customElements$get;
339
+ const { defineCustomElement, react, tagName, transformTag, elementClass, events = {}, slots = [], displayName } = options;
340
+ const finalTagName = transformTag ? transformTag(tagName) : tagName;
341
+ defineCustomElement === null || defineCustomElement === void 0 || defineCustomElement();
342
+ const LitComponent = (0, _lit_react.createComponent)({
343
+ react,
344
+ tagName: finalTagName,
345
+ elementClass: elementClass !== null && elementClass !== void 0 ? elementClass : typeof customElements === "undefined" ? HTMLElement : (_customElements$get = customElements.get(finalTagName)) !== null && _customElements$get !== void 0 ? _customElements$get : HTMLElement,
346
+ events,
347
+ displayName
348
+ });
349
+ if (!slots.length) return LitComponent;
350
+ const slotSet = new Set(slots);
351
+ return react.forwardRef((inputProps, ref) => {
352
+ const rest = {};
353
+ const slottedChildren = [];
354
+ if (inputProps == null) {
355
+ rest.ref = ref;
356
+ return react.createElement(LitComponent, rest);
357
+ }
358
+ const props = inputProps;
359
+ for (const key in props) {
360
+ if (!Object.prototype.hasOwnProperty.call(props, key)) continue;
361
+ const value = props[key];
362
+ if (slotSet.has(key)) {
363
+ const child = createNamedSlot(react, key, value);
364
+ if (child != null) slottedChildren.push(child);
365
+ continue;
366
+ }
367
+ rest[key] = value;
368
+ }
369
+ rest.ref = ref;
370
+ if (props.children != null) slottedChildren.push(props.children);
371
+ return react.createElement(LitComponent, rest, ...slottedChildren);
372
+ });
373
+ }
374
+ function createNamedSlot(react, name, value) {
375
+ if (value == null || value === false) return null;
376
+ return react.createElement("span", {
377
+ slot: name,
378
+ style: { display: "contents" }
379
+ }, value);
380
+ }
381
+ //#endregion
299
382
  //#region packages/web-c/output-react-wrapper/src/index.ts
300
383
  function reactWrapper(options = {}) {
301
384
  var _options$outDir, _options$stripPrefix, _options$dts, _options$index, _options$namedSlots, _options$wrapper;
@@ -306,7 +389,7 @@ function reactWrapper(options = {}) {
306
389
  dts: (_options$dts = options.dts) !== null && _options$dts !== void 0 ? _options$dts : true,
307
390
  index: (_options$index = options.index) !== null && _options$index !== void 0 ? _options$index : true,
308
391
  namedSlots: (_options$namedSlots = options.namedSlots) !== null && _options$namedSlots !== void 0 ? _options$namedSlots : "props",
309
- wrapper: (_options$wrapper = options.wrapper) !== null && _options$wrapper !== void 0 ? _options$wrapper : "minimal"
392
+ wrapper: (_options$wrapper = options.wrapper) !== null && _options$wrapper !== void 0 ? _options$wrapper : "runtime"
310
393
  };
311
394
  return {
312
395
  name: "zeus-output-react-wrapper",
@@ -349,4 +432,5 @@ function reactWrapper(options = {}) {
349
432
  };
350
433
  }
351
434
  //#endregion
435
+ exports.createComponent = createComponent;
352
436
  exports.default = reactWrapper;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * output-react-wrapper v0.1.0-beta.4
2
+ * output-react-wrapper v0.1.0-beta.5
3
3
  * (c) 2026 baicie
4
4
  * Released under the MIT License.
5
5
  **/
@@ -9,6 +9,7 @@ Object.defineProperties(exports, {
9
9
  });
10
10
  let _zeus_js_bundler_plugin = require("@zeus-js/bundler-plugin");
11
11
  let _zeus_js_component_dts = require("@zeus-js/component-dts");
12
+ let _lit_react = require("@lit/react");
12
13
  //#region packages/web-c/output-react-wrapper/src/generateReactIndex.ts
13
14
  function generateReactIndex(components, options) {
14
15
  const lines = [];
@@ -22,7 +23,7 @@ function generateReactIndex(components, options) {
22
23
  //#endregion
23
24
  //#region packages/web-c/output-react-wrapper/src/generateReactWrapper.ts
24
25
  function generateReactWrapper(input) {
25
- return input.mode === "event-bridge" ? generateEventBridgeReactWrapper(input) : generateMinimalReactWrapper(input);
26
+ return input.mode === "runtime" ? generateRuntimeReactWrapper(input) : input.mode === "event-bridge" ? generateEventBridgeReactWrapper(input) : generateMinimalReactWrapper(input);
26
27
  }
27
28
  function generateMinimalReactWrapper(input) {
28
29
  const { component, namedSlots, wcModuleId } = input;
@@ -275,6 +276,42 @@ function toKebabCase(value) {
275
276
  function toReactEventProp(value) {
276
277
  return `on${value.split("-").filter(Boolean).map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`).join("")}`;
277
278
  }
279
+ function generateRuntimeReactWrapper(input) {
280
+ const { component, namedSlots } = input;
281
+ const events = createRuntimeEventMap(component);
282
+ const slots = getNamedSlots(component, namedSlots);
283
+ return [
284
+ `import React from 'react'`,
285
+ `import { createComponent } from '@zeus-js/output-react-wrapper/runtime'`,
286
+ `import { defineCustomElement } from '../wc/loader.js'`,
287
+ ``,
288
+ `export const ${component.name} = createComponent({`,
289
+ ` react: React,`,
290
+ ` tagName: ${JSON.stringify(component.tag)},`,
291
+ ` defineCustomElement: () => defineCustomElement(${JSON.stringify(component.tag)}),`,
292
+ ` events: ${formatEventObject(events)},`,
293
+ ` slots: ${JSON.stringify(slots)},`,
294
+ ` displayName: ${JSON.stringify(component.name)},`,
295
+ `})`,
296
+ ``
297
+ ].join("\n");
298
+ }
299
+ function createRuntimeEventMap(component) {
300
+ const events = {};
301
+ for (const [key, event] of Object.entries(component.events)) {
302
+ var _event$key2, _event$name2, _event$reactName2;
303
+ const sourceEventName = (_event$key2 = event.key) !== null && _event$key2 !== void 0 ? _event$key2 : key;
304
+ const domEventName = (_event$name2 = event.name) !== null && _event$name2 !== void 0 ? _event$name2 : toKebabCase(sourceEventName);
305
+ const reactPropName = (_event$reactName2 = event.reactName) !== null && _event$reactName2 !== void 0 ? _event$reactName2 : toReactEventProp(sourceEventName);
306
+ events[reactPropName] = domEventName;
307
+ }
308
+ return events;
309
+ }
310
+ function formatEventObject(value) {
311
+ const entries = Object.entries(value);
312
+ if (!entries.length) return "{}";
313
+ return `{\n${entries.map(([key, item]) => ` ${JSON.stringify(key)}: ${JSON.stringify(item)}`).join(",\n")}\n }`;
314
+ }
278
315
  const PUSH_ALL_HELPER = `
279
316
  function pushAll(target, values) {
280
317
  for (const value of values) target.push(value);
@@ -296,6 +333,52 @@ function createNamedSlot(name, value) {
296
333
  }
297
334
  `;
298
335
  //#endregion
336
+ //#region packages/web-c/output-react-wrapper/src/runtime/createComponent.ts
337
+ function createComponent(options) {
338
+ var _customElements$get;
339
+ const { defineCustomElement, react, tagName, transformTag, elementClass, events = {}, slots = [], displayName } = options;
340
+ const finalTagName = transformTag ? transformTag(tagName) : tagName;
341
+ defineCustomElement === null || defineCustomElement === void 0 || defineCustomElement();
342
+ const LitComponent = (0, _lit_react.createComponent)({
343
+ react,
344
+ tagName: finalTagName,
345
+ elementClass: elementClass !== null && elementClass !== void 0 ? elementClass : typeof customElements === "undefined" ? HTMLElement : (_customElements$get = customElements.get(finalTagName)) !== null && _customElements$get !== void 0 ? _customElements$get : HTMLElement,
346
+ events,
347
+ displayName
348
+ });
349
+ if (!slots.length) return LitComponent;
350
+ const slotSet = new Set(slots);
351
+ return react.forwardRef((inputProps, ref) => {
352
+ const rest = {};
353
+ const slottedChildren = [];
354
+ if (inputProps == null) {
355
+ rest.ref = ref;
356
+ return react.createElement(LitComponent, rest);
357
+ }
358
+ const props = inputProps;
359
+ for (const key in props) {
360
+ if (!Object.prototype.hasOwnProperty.call(props, key)) continue;
361
+ const value = props[key];
362
+ if (slotSet.has(key)) {
363
+ const child = createNamedSlot(react, key, value);
364
+ if (child != null) slottedChildren.push(child);
365
+ continue;
366
+ }
367
+ rest[key] = value;
368
+ }
369
+ rest.ref = ref;
370
+ if (props.children != null) slottedChildren.push(props.children);
371
+ return react.createElement(LitComponent, rest, ...slottedChildren);
372
+ });
373
+ }
374
+ function createNamedSlot(react, name, value) {
375
+ if (value == null || value === false) return null;
376
+ return react.createElement("span", {
377
+ slot: name,
378
+ style: { display: "contents" }
379
+ }, value);
380
+ }
381
+ //#endregion
299
382
  //#region packages/web-c/output-react-wrapper/src/index.ts
300
383
  function reactWrapper(options = {}) {
301
384
  var _options$outDir, _options$stripPrefix, _options$dts, _options$index, _options$namedSlots, _options$wrapper;
@@ -306,7 +389,7 @@ function reactWrapper(options = {}) {
306
389
  dts: (_options$dts = options.dts) !== null && _options$dts !== void 0 ? _options$dts : true,
307
390
  index: (_options$index = options.index) !== null && _options$index !== void 0 ? _options$index : true,
308
391
  namedSlots: (_options$namedSlots = options.namedSlots) !== null && _options$namedSlots !== void 0 ? _options$namedSlots : "props",
309
- wrapper: (_options$wrapper = options.wrapper) !== null && _options$wrapper !== void 0 ? _options$wrapper : "minimal"
392
+ wrapper: (_options$wrapper = options.wrapper) !== null && _options$wrapper !== void 0 ? _options$wrapper : "runtime"
310
393
  };
311
394
  return {
312
395
  name: "zeus-output-react-wrapper",
@@ -349,4 +432,5 @@ function reactWrapper(options = {}) {
349
432
  };
350
433
  }
351
434
  //#endregion
435
+ exports.createComponent = createComponent;
352
436
  exports.default = reactWrapper;
@@ -1,6 +1,6 @@
1
1
  import { DtsMode, ZeusComponentPlugin } from '@zeus-js/bundler-plugin';
2
2
 
3
- type ReactWrapperMode = 'minimal' | 'event-bridge';
3
+ type ReactWrapperMode = 'runtime' | 'minimal' | 'event-bridge';
4
4
  export interface OutputReactWrapperOptions {
5
5
  /**
6
6
  * React wrapper output directory.
@@ -31,8 +31,12 @@ export interface OutputReactWrapperOptions {
31
31
  */
32
32
  index?: boolean;
33
33
  /**
34
+ * runtime:
35
+ * Default. Generates thin proxies powered by @zeus-js/output-react-wrapper/runtime.
36
+ * No useEffect, no addEventListener, no prop sync — delegates to @lit/react.
37
+ *
34
38
  * minimal:
35
- * Default. Requires React 19+.
39
+ * Requires React 19+.
36
40
  * React wrapper only renders the custom element tag.
37
41
  * No useEffect prop sync, no event listeners.
38
42
  *
@@ -55,6 +59,44 @@ export interface OutputReactWrapperOptions {
55
59
  namedSlots?: 'props' | 'none';
56
60
  }
57
61
 
62
+ export type EventName<T extends Event = Event> = string & {
63
+ __eventType: T;
64
+ };
65
+ type EventNames = Record<string, EventName | string>;
66
+ type ElementProps<I extends HTMLElement> = Partial<Omit<I, keyof HTMLElement>>;
67
+ type ReactRef<I extends HTMLElement> = ((instance: I | null) => void) | {
68
+ current: I | null;
69
+ } | null;
70
+ export interface ReactModule {
71
+ createElement: (...args: unknown[]) => unknown;
72
+ forwardRef: (...args: unknown[]) => unknown;
73
+ }
74
+ type EventListeners<E extends EventNames> = {
75
+ [K in keyof E]?: E[K] extends EventName<infer T> ? (event: T) => void : (event: Event) => void;
76
+ };
77
+ type ComponentProps<I extends HTMLElement, E extends EventNames> = {
78
+ children?: unknown;
79
+ className?: string;
80
+ ref?: ReactRef<I>;
81
+ style?: unknown;
82
+ } & {
83
+ [key: string]: unknown;
84
+ } & EventListeners<E> & ElementProps<I>;
85
+ export type ZeusReactComponent<I extends HTMLElement, E extends EventNames = {}> = (props: ComponentProps<I, E>) => unknown;
86
+ export interface ZeusReactCreateComponentOptions<I extends HTMLElement, E extends EventNames> {
87
+ tagName: string;
88
+ react: ReactModule;
89
+ defineCustomElement?: () => void;
90
+ elementClass?: {
91
+ new (): I;
92
+ };
93
+ events?: E;
94
+ slots?: string[];
95
+ displayName?: string;
96
+ transformTag?: (tagName: string) => string;
97
+ }
98
+ export declare function createComponent<I extends HTMLElement, E extends EventNames = {}>(options: ZeusReactCreateComponentOptions<I, E>): ZeusReactComponent<I, E>;
99
+
58
100
  export declare function reactWrapper(options?: OutputReactWrapperOptions): ZeusComponentPlugin;
59
101
 
60
102
  export { reactWrapper as default };
@@ -1,10 +1,11 @@
1
1
  /**
2
- * output-react-wrapper v0.1.0-beta.4
2
+ * output-react-wrapper v0.1.0-beta.5
3
3
  * (c) 2026 baicie
4
4
  * Released under the MIT License.
5
5
  **/
6
6
  import { resolvePluginDts } from "@zeus-js/bundler-plugin";
7
7
  import { generateReactDts } from "@zeus-js/component-dts";
8
+ import { createComponent as createComponent$1 } from "@lit/react";
8
9
  //#region packages/web-c/output-react-wrapper/src/generateReactIndex.ts
9
10
  function generateReactIndex(components, options) {
10
11
  const lines = [];
@@ -18,7 +19,7 @@ function generateReactIndex(components, options) {
18
19
  //#endregion
19
20
  //#region packages/web-c/output-react-wrapper/src/generateReactWrapper.ts
20
21
  function generateReactWrapper(input) {
21
- return input.mode === "event-bridge" ? generateEventBridgeReactWrapper(input) : generateMinimalReactWrapper(input);
22
+ return input.mode === "runtime" ? generateRuntimeReactWrapper(input) : input.mode === "event-bridge" ? generateEventBridgeReactWrapper(input) : generateMinimalReactWrapper(input);
22
23
  }
23
24
  function generateMinimalReactWrapper(input) {
24
25
  const { component, namedSlots, wcModuleId } = input;
@@ -271,6 +272,42 @@ function toKebabCase(value) {
271
272
  function toReactEventProp(value) {
272
273
  return `on${value.split("-").filter(Boolean).map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`).join("")}`;
273
274
  }
275
+ function generateRuntimeReactWrapper(input) {
276
+ const { component, namedSlots } = input;
277
+ const events = createRuntimeEventMap(component);
278
+ const slots = getNamedSlots(component, namedSlots);
279
+ return [
280
+ `import React from 'react'`,
281
+ `import { createComponent } from '@zeus-js/output-react-wrapper/runtime'`,
282
+ `import { defineCustomElement } from '../wc/loader.js'`,
283
+ ``,
284
+ `export const ${component.name} = createComponent({`,
285
+ ` react: React,`,
286
+ ` tagName: ${JSON.stringify(component.tag)},`,
287
+ ` defineCustomElement: () => defineCustomElement(${JSON.stringify(component.tag)}),`,
288
+ ` events: ${formatEventObject(events)},`,
289
+ ` slots: ${JSON.stringify(slots)},`,
290
+ ` displayName: ${JSON.stringify(component.name)},`,
291
+ `})`,
292
+ ``
293
+ ].join("\n");
294
+ }
295
+ function createRuntimeEventMap(component) {
296
+ const events = {};
297
+ for (const [key, event] of Object.entries(component.events)) {
298
+ var _event$key2, _event$name2, _event$reactName2;
299
+ const sourceEventName = (_event$key2 = event.key) !== null && _event$key2 !== void 0 ? _event$key2 : key;
300
+ const domEventName = (_event$name2 = event.name) !== null && _event$name2 !== void 0 ? _event$name2 : toKebabCase(sourceEventName);
301
+ const reactPropName = (_event$reactName2 = event.reactName) !== null && _event$reactName2 !== void 0 ? _event$reactName2 : toReactEventProp(sourceEventName);
302
+ events[reactPropName] = domEventName;
303
+ }
304
+ return events;
305
+ }
306
+ function formatEventObject(value) {
307
+ const entries = Object.entries(value);
308
+ if (!entries.length) return "{}";
309
+ return `{\n${entries.map(([key, item]) => ` ${JSON.stringify(key)}: ${JSON.stringify(item)}`).join(",\n")}\n }`;
310
+ }
274
311
  const PUSH_ALL_HELPER = `
275
312
  function pushAll(target, values) {
276
313
  for (const value of values) target.push(value);
@@ -292,6 +329,52 @@ function createNamedSlot(name, value) {
292
329
  }
293
330
  `;
294
331
  //#endregion
332
+ //#region packages/web-c/output-react-wrapper/src/runtime/createComponent.ts
333
+ function createComponent(options) {
334
+ var _customElements$get;
335
+ const { defineCustomElement, react, tagName, transformTag, elementClass, events = {}, slots = [], displayName } = options;
336
+ const finalTagName = transformTag ? transformTag(tagName) : tagName;
337
+ defineCustomElement === null || defineCustomElement === void 0 || defineCustomElement();
338
+ const LitComponent = createComponent$1({
339
+ react,
340
+ tagName: finalTagName,
341
+ elementClass: elementClass !== null && elementClass !== void 0 ? elementClass : typeof customElements === "undefined" ? HTMLElement : (_customElements$get = customElements.get(finalTagName)) !== null && _customElements$get !== void 0 ? _customElements$get : HTMLElement,
342
+ events,
343
+ displayName
344
+ });
345
+ if (!slots.length) return LitComponent;
346
+ const slotSet = new Set(slots);
347
+ return react.forwardRef((inputProps, ref) => {
348
+ const rest = {};
349
+ const slottedChildren = [];
350
+ if (inputProps == null) {
351
+ rest.ref = ref;
352
+ return react.createElement(LitComponent, rest);
353
+ }
354
+ const props = inputProps;
355
+ for (const key in props) {
356
+ if (!Object.prototype.hasOwnProperty.call(props, key)) continue;
357
+ const value = props[key];
358
+ if (slotSet.has(key)) {
359
+ const child = createNamedSlot(react, key, value);
360
+ if (child != null) slottedChildren.push(child);
361
+ continue;
362
+ }
363
+ rest[key] = value;
364
+ }
365
+ rest.ref = ref;
366
+ if (props.children != null) slottedChildren.push(props.children);
367
+ return react.createElement(LitComponent, rest, ...slottedChildren);
368
+ });
369
+ }
370
+ function createNamedSlot(react, name, value) {
371
+ if (value == null || value === false) return null;
372
+ return react.createElement("span", {
373
+ slot: name,
374
+ style: { display: "contents" }
375
+ }, value);
376
+ }
377
+ //#endregion
295
378
  //#region packages/web-c/output-react-wrapper/src/index.ts
296
379
  function reactWrapper(options = {}) {
297
380
  var _options$outDir, _options$stripPrefix, _options$dts, _options$index, _options$namedSlots, _options$wrapper;
@@ -302,7 +385,7 @@ function reactWrapper(options = {}) {
302
385
  dts: (_options$dts = options.dts) !== null && _options$dts !== void 0 ? _options$dts : true,
303
386
  index: (_options$index = options.index) !== null && _options$index !== void 0 ? _options$index : true,
304
387
  namedSlots: (_options$namedSlots = options.namedSlots) !== null && _options$namedSlots !== void 0 ? _options$namedSlots : "props",
305
- wrapper: (_options$wrapper = options.wrapper) !== null && _options$wrapper !== void 0 ? _options$wrapper : "minimal"
388
+ wrapper: (_options$wrapper = options.wrapper) !== null && _options$wrapper !== void 0 ? _options$wrapper : "runtime"
306
389
  };
307
390
  return {
308
391
  name: "zeus-output-react-wrapper",
@@ -345,4 +428,4 @@ function reactWrapper(options = {}) {
345
428
  };
346
429
  }
347
430
  //#endregion
348
- export { reactWrapper as default };
431
+ export { createComponent, reactWrapper as default };
@@ -0,0 +1,57 @@
1
+ /**
2
+ * output-react-wrapper v0.1.0-beta.5
3
+ * (c) 2026 baicie
4
+ * Released under the MIT License.
5
+ **/
6
+ Object.defineProperties(exports, {
7
+ __esModule: { value: true },
8
+ [Symbol.toStringTag]: { value: "Module" }
9
+ });
10
+ let _lit_react = require("@lit/react");
11
+ //#region packages/web-c/output-react-wrapper/src/runtime/createComponent.ts
12
+ function createComponent(options) {
13
+ var _customElements$get;
14
+ const { defineCustomElement, react, tagName, transformTag, elementClass, events = {}, slots = [], displayName } = options;
15
+ const finalTagName = transformTag ? transformTag(tagName) : tagName;
16
+ defineCustomElement === null || defineCustomElement === void 0 || defineCustomElement();
17
+ const LitComponent = (0, _lit_react.createComponent)({
18
+ react,
19
+ tagName: finalTagName,
20
+ elementClass: elementClass !== null && elementClass !== void 0 ? elementClass : typeof customElements === "undefined" ? HTMLElement : (_customElements$get = customElements.get(finalTagName)) !== null && _customElements$get !== void 0 ? _customElements$get : HTMLElement,
21
+ events,
22
+ displayName
23
+ });
24
+ if (!slots.length) return LitComponent;
25
+ const slotSet = new Set(slots);
26
+ return react.forwardRef((inputProps, ref) => {
27
+ const rest = {};
28
+ const slottedChildren = [];
29
+ if (inputProps == null) {
30
+ rest.ref = ref;
31
+ return react.createElement(LitComponent, rest);
32
+ }
33
+ const props = inputProps;
34
+ for (const key in props) {
35
+ if (!Object.prototype.hasOwnProperty.call(props, key)) continue;
36
+ const value = props[key];
37
+ if (slotSet.has(key)) {
38
+ const child = createNamedSlot(react, key, value);
39
+ if (child != null) slottedChildren.push(child);
40
+ continue;
41
+ }
42
+ rest[key] = value;
43
+ }
44
+ rest.ref = ref;
45
+ if (props.children != null) slottedChildren.push(props.children);
46
+ return react.createElement(LitComponent, rest, ...slottedChildren);
47
+ });
48
+ }
49
+ function createNamedSlot(react, name, value) {
50
+ if (value == null || value === false) return null;
51
+ return react.createElement("span", {
52
+ slot: name,
53
+ style: { display: "contents" }
54
+ }, value);
55
+ }
56
+ //#endregion
57
+ exports.createComponent = createComponent;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * output-react-wrapper v0.1.0-beta.5
3
+ * (c) 2026 baicie
4
+ * Released under the MIT License.
5
+ **/
6
+ Object.defineProperties(exports, {
7
+ __esModule: { value: true },
8
+ [Symbol.toStringTag]: { value: "Module" }
9
+ });
10
+ let _lit_react = require("@lit/react");
11
+ //#region packages/web-c/output-react-wrapper/src/runtime/createComponent.ts
12
+ function createComponent(options) {
13
+ var _customElements$get;
14
+ const { defineCustomElement, react, tagName, transformTag, elementClass, events = {}, slots = [], displayName } = options;
15
+ const finalTagName = transformTag ? transformTag(tagName) : tagName;
16
+ defineCustomElement === null || defineCustomElement === void 0 || defineCustomElement();
17
+ const LitComponent = (0, _lit_react.createComponent)({
18
+ react,
19
+ tagName: finalTagName,
20
+ elementClass: elementClass !== null && elementClass !== void 0 ? elementClass : typeof customElements === "undefined" ? HTMLElement : (_customElements$get = customElements.get(finalTagName)) !== null && _customElements$get !== void 0 ? _customElements$get : HTMLElement,
21
+ events,
22
+ displayName
23
+ });
24
+ if (!slots.length) return LitComponent;
25
+ const slotSet = new Set(slots);
26
+ return react.forwardRef((inputProps, ref) => {
27
+ const rest = {};
28
+ const slottedChildren = [];
29
+ if (inputProps == null) {
30
+ rest.ref = ref;
31
+ return react.createElement(LitComponent, rest);
32
+ }
33
+ const props = inputProps;
34
+ for (const key in props) {
35
+ if (!Object.prototype.hasOwnProperty.call(props, key)) continue;
36
+ const value = props[key];
37
+ if (slotSet.has(key)) {
38
+ const child = createNamedSlot(react, key, value);
39
+ if (child != null) slottedChildren.push(child);
40
+ continue;
41
+ }
42
+ rest[key] = value;
43
+ }
44
+ rest.ref = ref;
45
+ if (props.children != null) slottedChildren.push(props.children);
46
+ return react.createElement(LitComponent, rest, ...slottedChildren);
47
+ });
48
+ }
49
+ function createNamedSlot(react, name, value) {
50
+ if (value == null || value === false) return null;
51
+ return react.createElement("span", {
52
+ slot: name,
53
+ style: { display: "contents" }
54
+ }, value);
55
+ }
56
+ //#endregion
57
+ exports.createComponent = createComponent;
@@ -0,0 +1,39 @@
1
+ export type EventName<T extends Event = Event> = string & {
2
+ __eventType: T;
3
+ };
4
+ type EventNames = Record<string, EventName | string>;
5
+ type ElementProps<I extends HTMLElement> = Partial<Omit<I, keyof HTMLElement>>;
6
+ type ReactRef<I extends HTMLElement> = ((instance: I | null) => void) | {
7
+ current: I | null;
8
+ } | null;
9
+ export interface ReactModule {
10
+ createElement: (...args: unknown[]) => unknown;
11
+ forwardRef: (...args: unknown[]) => unknown;
12
+ }
13
+ type EventListeners<E extends EventNames> = {
14
+ [K in keyof E]?: E[K] extends EventName<infer T> ? (event: T) => void : (event: Event) => void;
15
+ };
16
+ type ComponentProps<I extends HTMLElement, E extends EventNames> = {
17
+ children?: unknown;
18
+ className?: string;
19
+ ref?: ReactRef<I>;
20
+ style?: unknown;
21
+ } & {
22
+ [key: string]: unknown;
23
+ } & EventListeners<E> & ElementProps<I>;
24
+ export type ZeusReactComponent<I extends HTMLElement, E extends EventNames = {}> = (props: ComponentProps<I, E>) => unknown;
25
+ export interface ZeusReactCreateComponentOptions<I extends HTMLElement, E extends EventNames> {
26
+ tagName: string;
27
+ react: ReactModule;
28
+ defineCustomElement?: () => void;
29
+ elementClass?: {
30
+ new (): I;
31
+ };
32
+ events?: E;
33
+ slots?: string[];
34
+ displayName?: string;
35
+ transformTag?: (tagName: string) => string;
36
+ }
37
+ export declare function createComponent<I extends HTMLElement, E extends EventNames = {}>(options: ZeusReactCreateComponentOptions<I, E>): ZeusReactComponent<I, E>;
38
+
39
+
@@ -0,0 +1,53 @@
1
+ /**
2
+ * output-react-wrapper v0.1.0-beta.5
3
+ * (c) 2026 baicie
4
+ * Released under the MIT License.
5
+ **/
6
+ import { createComponent as createComponent$1 } from "@lit/react";
7
+ //#region packages/web-c/output-react-wrapper/src/runtime/createComponent.ts
8
+ function createComponent(options) {
9
+ var _customElements$get;
10
+ const { defineCustomElement, react, tagName, transformTag, elementClass, events = {}, slots = [], displayName } = options;
11
+ const finalTagName = transformTag ? transformTag(tagName) : tagName;
12
+ defineCustomElement === null || defineCustomElement === void 0 || defineCustomElement();
13
+ const LitComponent = createComponent$1({
14
+ react,
15
+ tagName: finalTagName,
16
+ elementClass: elementClass !== null && elementClass !== void 0 ? elementClass : typeof customElements === "undefined" ? HTMLElement : (_customElements$get = customElements.get(finalTagName)) !== null && _customElements$get !== void 0 ? _customElements$get : HTMLElement,
17
+ events,
18
+ displayName
19
+ });
20
+ if (!slots.length) return LitComponent;
21
+ const slotSet = new Set(slots);
22
+ return react.forwardRef((inputProps, ref) => {
23
+ const rest = {};
24
+ const slottedChildren = [];
25
+ if (inputProps == null) {
26
+ rest.ref = ref;
27
+ return react.createElement(LitComponent, rest);
28
+ }
29
+ const props = inputProps;
30
+ for (const key in props) {
31
+ if (!Object.prototype.hasOwnProperty.call(props, key)) continue;
32
+ const value = props[key];
33
+ if (slotSet.has(key)) {
34
+ const child = createNamedSlot(react, key, value);
35
+ if (child != null) slottedChildren.push(child);
36
+ continue;
37
+ }
38
+ rest[key] = value;
39
+ }
40
+ rest.ref = ref;
41
+ if (props.children != null) slottedChildren.push(props.children);
42
+ return react.createElement(LitComponent, rest, ...slottedChildren);
43
+ });
44
+ }
45
+ function createNamedSlot(react, name, value) {
46
+ if (value == null || value === false) return null;
47
+ return react.createElement("span", {
48
+ slot: name,
49
+ style: { display: "contents" }
50
+ }, value);
51
+ }
52
+ //#endregion
53
+ export { createComponent };
@@ -0,0 +1,53 @@
1
+ /**
2
+ * output-react-wrapper v0.1.0-beta.5
3
+ * (c) 2026 baicie
4
+ * Released under the MIT License.
5
+ **/
6
+ import { createComponent as createComponent$1 } from "@lit/react";
7
+ //#region packages/web-c/output-react-wrapper/src/runtime/createComponent.ts
8
+ function createComponent(options) {
9
+ var _customElements$get;
10
+ const { defineCustomElement, react, tagName, transformTag, elementClass, events = {}, slots = [], displayName } = options;
11
+ const finalTagName = transformTag ? transformTag(tagName) : tagName;
12
+ defineCustomElement === null || defineCustomElement === void 0 || defineCustomElement();
13
+ const LitComponent = createComponent$1({
14
+ react,
15
+ tagName: finalTagName,
16
+ elementClass: elementClass !== null && elementClass !== void 0 ? elementClass : typeof customElements === "undefined" ? HTMLElement : (_customElements$get = customElements.get(finalTagName)) !== null && _customElements$get !== void 0 ? _customElements$get : HTMLElement,
17
+ events,
18
+ displayName
19
+ });
20
+ if (!slots.length) return LitComponent;
21
+ const slotSet = new Set(slots);
22
+ return react.forwardRef((inputProps, ref) => {
23
+ const rest = {};
24
+ const slottedChildren = [];
25
+ if (inputProps == null) {
26
+ rest.ref = ref;
27
+ return react.createElement(LitComponent, rest);
28
+ }
29
+ const props = inputProps;
30
+ for (const key in props) {
31
+ if (!Object.prototype.hasOwnProperty.call(props, key)) continue;
32
+ const value = props[key];
33
+ if (slotSet.has(key)) {
34
+ const child = createNamedSlot(react, key, value);
35
+ if (child != null) slottedChildren.push(child);
36
+ continue;
37
+ }
38
+ rest[key] = value;
39
+ }
40
+ rest.ref = ref;
41
+ if (props.children != null) slottedChildren.push(props.children);
42
+ return react.createElement(LitComponent, rest, ...slottedChildren);
43
+ });
44
+ }
45
+ function createNamedSlot(react, name, value) {
46
+ if (value == null || value === false) return null;
47
+ return react.createElement("span", {
48
+ slot: name,
49
+ style: { display: "contents" }
50
+ }, value);
51
+ }
52
+ //#endregion
53
+ export { createComponent };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeus-js/output-react-wrapper",
3
- "version": "0.1.0-beta.4",
3
+ "version": "0.1.0-beta.5",
4
4
  "description": "Zeus React wrapper output plugin",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -21,6 +21,11 @@
21
21
  "development": "./dist/output-react-wrapper.cjs.js",
22
22
  "default": "./index.js"
23
23
  }
24
+ },
25
+ "./runtime": {
26
+ "types": "./dist/runtime/index.d.ts",
27
+ "import": "./dist/runtime/index.js",
28
+ "require": "./dist/runtime/index.cjs.js"
24
29
  }
25
30
  },
26
31
  "sideEffects": false,
@@ -33,17 +38,28 @@
33
38
  "formats": [
34
39
  "esm-bundler",
35
40
  "cjs"
41
+ ],
42
+ "additionalEntries": [
43
+ {
44
+ "entry": "runtime/index.ts",
45
+ "output": "dist/runtime/index.js"
46
+ }
36
47
  ]
37
48
  },
38
49
  "dependencies": {
39
- "@zeus-js/bundler-plugin": "0.1.0-beta.4",
40
- "@zeus-js/component-analyzer": "0.1.0-beta.4",
41
- "@zeus-js/component-dts": "0.1.0-beta.4"
50
+ "@lit/react": "^1.0.8",
51
+ "@zeus-js/component-analyzer": "0.1.0-beta.5",
52
+ "@zeus-js/bundler-plugin": "0.1.0-beta.5",
53
+ "@zeus-js/component-dts": "0.1.0-beta.5"
42
54
  },
43
55
  "peerDependencies": {
56
+ "@types/react": "17 || 18 || 19",
44
57
  "react": ">=18"
45
58
  },
46
59
  "peerDependenciesMeta": {
60
+ "@types/react": {
61
+ "optional": true
62
+ },
47
63
  "react": {
48
64
  "optional": true
49
65
  }