@twick/2d 0.15.9 → 0.15.10

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.
@@ -0,0 +1,37 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result) __defProp(target, key, result);
9
+ return result;
10
+ };
11
+
12
+ // src/lib/jsx-runtime.ts
13
+ function isClassComponent(fn) {
14
+ return !!fn.prototype?.isClass;
15
+ }
16
+ var Fragment = ({ children }) => children;
17
+ function jsx(type, config, key) {
18
+ const { ref, children, ...rest } = config;
19
+ const flatChildren = Array.isArray(children) ? children.flat() : children;
20
+ if (type === Fragment) {
21
+ return flatChildren;
22
+ }
23
+ if (isClassComponent(type)) {
24
+ const node = new type({ ...rest, children: flatChildren, key });
25
+ ref?.(node);
26
+ return node;
27
+ } else {
28
+ return type({ ...rest, ref, children: flatChildren, key });
29
+ }
30
+ }
31
+
32
+ export {
33
+ __decorateClass,
34
+ Fragment,
35
+ jsx
36
+ };
37
+ //# sourceMappingURL=chunk-XMWTT7ET.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/jsx-runtime.ts"],"sourcesContent":["import type {\n ComponentChildren,\n FunctionComponent,\n JSXProps,\n Node,\n NodeConstructor,\n} from './components';\n\nexport namespace JSX {\n export type Element = Node;\n export type ElementClass = Node;\n export interface ElementChildrenAttribute {\n children: any;\n }\n}\n\nfunction isClassComponent(\n // eslint-disable-next-line @typescript-eslint/ban-types\n fn: Function,\n): fn is new (...args: unknown[]) => unknown {\n return !!fn.prototype?.isClass;\n}\n\nexport const Fragment: FunctionComponent = ({children}) => children;\n\nexport function jsx(\n type: NodeConstructor | FunctionComponent | typeof Fragment,\n config: JSXProps,\n key?: any,\n): ComponentChildren {\n const {ref, children, ...rest} = config;\n const flatChildren = Array.isArray(children) ? children.flat() : children;\n\n if (type === Fragment) {\n return flatChildren;\n }\n\n if (isClassComponent(type)) {\n const node = new type({...rest, children: flatChildren, key});\n ref?.(node);\n return node;\n } else {\n return type({...rest, ref, children: flatChildren, key});\n }\n}\nexport {jsx as jsxs};\n"],"mappings":";;;;;;;;;;;;AAgBA,SAAS,iBAEP,IAC2C;AAC3C,SAAO,CAAC,CAAC,GAAG,WAAW;AACzB;AAEO,IAAM,WAA8B,CAAC,EAAC,SAAQ,MAAM;AAEpD,SAAS,IACd,MACA,QACA,KACmB;AACnB,QAAM,EAAC,KAAK,UAAU,GAAG,KAAI,IAAI;AACjC,QAAM,eAAe,MAAM,QAAQ,QAAQ,IAAI,SAAS,KAAK,IAAI;AAEjE,MAAI,SAAS,UAAU;AACrB,WAAO;AAAA,EACT;AAEA,MAAI,iBAAiB,IAAI,GAAG;AAC1B,UAAM,OAAO,IAAI,KAAK,EAAC,GAAG,MAAM,UAAU,cAAc,IAAG,CAAC;AAC5D,UAAM,IAAI;AACV,WAAO;AAAA,EACT,OAAO;AACL,WAAO,KAAK,EAAC,GAAG,MAAM,KAAK,UAAU,cAAc,IAAG,CAAC;AAAA,EACzD;AACF;","names":[]}