Skip to content

Commit

Permalink
Merge pull request #54 from atellmer/feature/jsx-import
Browse files Browse the repository at this point in the history
jsx-runtime
  • Loading branch information
atellmer authored Apr 11, 2024
2 parents 80fb352 + 0d6330c commit 383a2d0
Show file tree
Hide file tree
Showing 154 changed files with 235 additions and 267 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ This project was written in my free time as a hobby. I challenged myself: can I
## Usage

```tsx
import { h, Fragment, component, useState } from '@dark-engine/core';
import { component, useState } from '@dark-engine/core';
import { createRoot } from '@dark-engine/platform-browser';

const App = component(() => {
Expand Down
2 changes: 1 addition & 1 deletion examples/1k-components/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { interpolateViridis } from 'd3-scale-chromatic';

import { h, component, useState, useEffect, useMemo, useUpdate, Flag, TagVirtualNode } from '@dark-engine/core';
import { component, useState, useEffect, useMemo, useUpdate, Flag, TagVirtualNode } from '@dark-engine/core';
import { createRoot } from '@dark-engine/platform-browser';

const Demo = component(() => {
Expand Down
2 changes: 0 additions & 2 deletions examples/animated-grid/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import {
type Ref,
type Component,
type StandardComponentProps,
h,
Fragment,
component,
useEffect,
useLayoutEffect,
Expand Down
2 changes: 1 addition & 1 deletion examples/concurrent-tabs/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, type DarkElement, Fragment, component, memo, useState, useTransition } from '@dark-engine/core';
import { type DarkElement, component, memo, useState, useTransition } from '@dark-engine/core';
import { createRoot } from '@dark-engine/platform-browser';

const AboutTab = component(() => {
Expand Down
2 changes: 1 addition & 1 deletion examples/deferred-search/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, Fragment, component, useState, useMemo, useDeferredValue } from '@dark-engine/core';
import { component, useState, useMemo, useDeferredValue } from '@dark-engine/core';
import { type DarkJSX, type SyntheticEvent, createRoot } from '@dark-engine/platform-browser';
import { styled } from '@dark-engine/styled';

Expand Down
2 changes: 1 addition & 1 deletion examples/desktop/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { QIcon, Direction } from '@nodegui/nodegui';
import { h, Fragment, component, useState } from '@dark-engine/core';
import { component, useState } from '@dark-engine/core';
import {
type PushButtonSignals,
Window,
Expand Down
1 change: 0 additions & 1 deletion examples/desktop/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { h } from '@dark-engine/core';
import { render } from '@dark-engine/platform-desktop';

import App from './app';
Expand Down
2 changes: 1 addition & 1 deletion examples/hmr-web/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, Fragment, component } from '@dark-engine/core';
import { component } from '@dark-engine/core';

import { Counter } from './counter';

Expand Down
2 changes: 1 addition & 1 deletion examples/hmr-web/counter.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, Fragment, component, useState } from '@dark-engine/core';
import { component, useState } from '@dark-engine/core';

const Counter = component(() => {
const [count, setCount] = useState(0);
Expand Down
2 changes: 1 addition & 1 deletion examples/hmr-web/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, hot } from '@dark-engine/core';
import { hot } from '@dark-engine/core';
import { createRoot } from '@dark-engine/platform-browser';

import { App } from './app';
Expand Down
4 changes: 2 additions & 2 deletions examples/html-inputs.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, Fragment, component, useState } from '@dark-engine/core';
import { component, useState } from '@dark-engine/core';
import { createRoot } from '@dark-engine/platform-browser';

const App = component(() => {
Expand Down Expand Up @@ -49,7 +49,7 @@ const App = component(() => {
<hr />
<div>
<div>readonly input</div>
<input value='hello' readOnly />
<input value='hello' readonly />
</div>
<hr />
<div>
Expand Down
2 changes: 1 addition & 1 deletion examples/nativescript/src/components/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, Fragment, component } from '@dark-engine/core';
import { component } from '@dark-engine/core';
import { View, Text } from '@dark-engine/platform-native';
import { NavigationContainer, TabNavigator } from '@dark-engine/native-navigation';

Expand Down
2 changes: 1 addition & 1 deletion examples/nativescript/src/components/button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, component } from '@dark-engine/core';
import { component } from '@dark-engine/core';
import { TouchableOpacity, Text } from '@dark-engine/platform-native';

type ButtonProps = {
Expand Down
2 changes: 1 addition & 1 deletion examples/nativescript/src/components/card.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, component, useAtom } from '@dark-engine/core';
import { component, useAtom } from '@dark-engine/core';
import { View, Text } from '@dark-engine/platform-native';

import { Button } from './button';
Expand Down
2 changes: 1 addition & 1 deletion examples/nativescript/src/components/contacts.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, component } from '@dark-engine/core';
import { component } from '@dark-engine/core';
import { ListView, StackLayout, View, Text } from '@dark-engine/platform-native';

const contacts = Array(1000)
Expand Down
2 changes: 1 addition & 1 deletion examples/nativescript/src/components/home.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, component } from '@dark-engine/core';
import { component } from '@dark-engine/core';
import { View, ScrollView } from '@dark-engine/platform-native';

import { Card } from './card';
Expand Down
2 changes: 1 addition & 1 deletion examples/nativescript/src/components/settings.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, component } from '@dark-engine/core';
import { component } from '@dark-engine/core';
import { View, Text, Switch } from '@dark-engine/platform-native';

const features = Array(4)
Expand Down
8 changes: 5 additions & 3 deletions examples/nativescript/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
"ES7",
"dom"
],
"jsx": "react",
"jsxFactory": "h",
"jsxFragmentFactory": "Fragment",
"jsx": "react-jsx",
"jsxImportSource": "@dark-engine/core",
"baseUrl": ".",
"paths": {
"@nativescript/core": [
Expand All @@ -24,6 +23,9 @@
"@dark-engine/core": [
"../../packages/core/src/index"
],
"@dark-engine/core/*": [
"../../packages/core/src/*"
],
"@dark-engine/platform-native": [
"../../packages/platform-native/src/index"
],
Expand Down
2 changes: 1 addition & 1 deletion examples/render-props.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, Fragment, component, useState, useEffect, type DarkElement } from '@dark-engine/core';
import { component, useState, useEffect, type DarkElement } from '@dark-engine/core';
import { createRoot } from '@dark-engine/platform-browser';

type TimerProps = {
Expand Down
2 changes: 1 addition & 1 deletion examples/router/about.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, component } from '@dark-engine/core';
import { component } from '@dark-engine/core';

const About = component(() => {
return (
Expand Down
2 changes: 1 addition & 1 deletion examples/router/contacts.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, component } from '@dark-engine/core';
import { component } from '@dark-engine/core';

const Contacts = component(() => {
return (
Expand Down
2 changes: 1 addition & 1 deletion examples/router/home.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type DarkElement, h, component } from '@dark-engine/core';
import { type DarkElement, component } from '@dark-engine/core';

const Home = component<{ slot: DarkElement }>(({ slot }) => {
return (
Expand Down
2 changes: 1 addition & 1 deletion examples/router/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, Fragment, component, lazy, Suspense, type DarkElement } from '@dark-engine/core';
import { component, lazy, Suspense, type DarkElement } from '@dark-engine/core';
import { createRoot } from '@dark-engine/platform-browser';
import { type Routes, Router, RouterLink, useLocation } from '@dark-engine/web-router';
import { createGlobalStyle, keyframes } from '@dark-engine/styled';
Expand Down
1 change: 0 additions & 1 deletion examples/server-side-rendering/backend/bootstrap.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { h } from '@dark-engine/core';
import { renderToStream } from '@dark-engine/platform-server';
import { ServerStyleSheet } from '@dark-engine/styled/server';

Expand Down
3 changes: 3 additions & 0 deletions examples/server-side-rendering/backend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"@dark-engine/core": [
"../../../packages/core/src/index"
],
"@dark-engine/core/*": [
"../../../packages/core/src/*"
],
"@dark-engine/platform-browser": [
"../../../packages/platform-browser/src/index"
],
Expand Down
1 change: 0 additions & 1 deletion examples/server-side-rendering/frontend/bootstrap.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { h } from '@dark-engine/core';
import { hydrateRoot, createRoot } from '@dark-engine/platform-browser';

import { App } from './components/app';
Expand Down
2 changes: 1 addition & 1 deletion examples/server-side-rendering/frontend/components/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, component, Fragment, Suspense, lazy, useMemo, useEffect } from '@dark-engine/core';
import { component, Suspense, lazy, useMemo, useEffect } from '@dark-engine/core';
import { type Routes, Router, RouterLink } from '@dark-engine/web-router';
import { DataClient, DataClientProvider, InMemoryCache } from '@dark-engine/data';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, component } from '@dark-engine/core';
import { component } from '@dark-engine/core';

import { AnimationFade } from './ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, component } from '@dark-engine/core';
import { component } from '@dark-engine/core';

import { AnimationFade } from './ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type DarkElement, h, component } from '@dark-engine/core';
import { type DarkElement, component } from '@dark-engine/core';

type PageProps = {
title: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, component } from '@dark-engine/core';
import { component } from '@dark-engine/core';
import { useMatch, useHistory } from '@dark-engine/web-router';

import { type Product } from '../../contract';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, component } from '@dark-engine/core';
import { component } from '@dark-engine/core';

import { AnimationFade } from './ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, component } from '@dark-engine/core';
import { component } from '@dark-engine/core';

import { AnimationFade } from './ui';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type DarkElement, h, component } from '@dark-engine/core';
import { type DarkElement, component } from '@dark-engine/core';
import { RouterLink, useMatch, useParams } from '@dark-engine/web-router';

import { useProduct } from '../hooks';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, component } from '@dark-engine/core';
import { component } from '@dark-engine/core';
import { useMatch, useHistory, useParams } from '@dark-engine/web-router';

import { type Product } from '../../contract';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, component, useRef, useEffect } from '@dark-engine/core';
import { component, useRef, useEffect } from '@dark-engine/core';
import { type SyntheticEvent } from '@dark-engine/platform-browser';

import { type Product } from '../../contract';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type DarkElement, h, component } from '@dark-engine/core';
import { type DarkElement, component } from '@dark-engine/core';
import { RouterLink, useMatch, useLocation } from '@dark-engine/web-router';
import { styled } from '@dark-engine/styled';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, component } from '@dark-engine/core';
import { component } from '@dark-engine/core';
import { useMatch, useHistory, useParams } from '@dark-engine/web-router';

import { useProduct, useRemoveProductMutation } from '../hooks';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type DarkElement, h, component } from '@dark-engine/core';
import { type DarkElement, component } from '@dark-engine/core';
import { RouterLink, useMatch } from '@dark-engine/web-router';

import { AnimationFade, Menu, Sticky } from './ui';
Expand Down
2 changes: 1 addition & 1 deletion examples/server-side-rendering/frontend/components/ui.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, component } from '@dark-engine/core';
import { component } from '@dark-engine/core';
import { createGlobalStyle, styled, keyframes, css } from '@dark-engine/styled';
import { type DarkJSX } from '@dark-engine/platform-browser';

Expand Down
3 changes: 3 additions & 0 deletions examples/server-side-rendering/frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"@dark-engine/core": [
"../../../packages/core/src/index"
],
"@dark-engine/core/*": [
"../../../packages/core/src/*"
],
"@dark-engine/platform-browser": [
"../../../packages/platform-browser/src/index"
],
Expand Down
14 changes: 7 additions & 7 deletions examples/server-side-rendering/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
"workbox-webpack-plugin": "^7.0.0"
},
"_moduleAliases": {
"@dark-engine/core": "../../packages/core/src/index",
"@dark-engine/platform-browser": "../../packages/platform-browser/src/index",
"@dark-engine/platform-server": "../../packages/platform-server/src/index",
"@dark-engine/web-router": "../../packages/web-router/src/index",
"@dark-engine/animations": "../../packages/animations/src/index",
"@dark-engine/styled": "../../packages/styled/src/index",
"@dark-engine/core": "../../packages/core/src",
"@dark-engine/platform-browser": "../../packages/platform-browser/src",
"@dark-engine/platform-server": "../../packages/platform-server/src",
"@dark-engine/web-router": "../../packages/web-router/src",
"@dark-engine/animations": "../../packages/animations/src",
"@dark-engine/styled": "../../packages/styled/src",
"@dark-engine/styled/server": "../../packages/styled/src/server",
"@dark-engine/data": "../../packages/data/src/index"
"@dark-engine/data": "../../packages/data/src"
}
}
5 changes: 2 additions & 3 deletions examples/server-side-rendering/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
"noImplicitAny": false,
"removeComments": true,
"esModuleInterop": true,
"jsx": "react",
"jsxFactory": "h",
"jsxFragmentFactory": "Fragment",
"jsx": "react-jsx",
"jsxImportSource": "@dark-engine/core",
"typeRoots": ["node_modules/@types"]
}
}
12 changes: 1 addition & 11 deletions examples/sierpinski-triangle/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
import {
h,
Text,
component,
memo,
useState,
useEffect,
Fragment,
DarkElement,
startTransition,
} from '@dark-engine/core';
import { Text, component, memo, useState, useEffect, DarkElement, startTransition } from '@dark-engine/core';
import { createRoot } from '@dark-engine/platform-browser';
import { useStyle } from '@dark-engine/styled';

Expand Down
2 changes: 1 addition & 1 deletion examples/spring-draggable-list/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, component, useMemo, useLayoutEffect } from '@dark-engine/core';
import { component, useMemo, useLayoutEffect } from '@dark-engine/core';
import { createRoot, type SyntheticEvent } from '@dark-engine/platform-browser';
import {
type SpringValue,
Expand Down
2 changes: 1 addition & 1 deletion examples/spring-masonry-grid/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, Fragment, component, useEffect, useLayoutEffect, useState, useMemo, useRef } from '@dark-engine/core';
import { component, useEffect, useLayoutEffect, useState, useMemo, useRef } from '@dark-engine/core';
import { createRoot } from '@dark-engine/platform-browser';
import { SpringValue, Animated, useTransition } from '@dark-engine/animations';

Expand Down
2 changes: 1 addition & 1 deletion examples/spring-menu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, Fragment, component, useState } from '@dark-engine/core';
import { component, useState } from '@dark-engine/core';
import { createRoot } from '@dark-engine/platform-browser';
import { type SpringValue, Animated, useTransition, useSpring, useChain, preset } from '@dark-engine/animations';

Expand Down
2 changes: 1 addition & 1 deletion examples/spring-slider/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, Fragment, component, useState } from '@dark-engine/core';
import { component, useState } from '@dark-engine/core';
import { type DarkJSX, createRoot } from '@dark-engine/platform-browser';
import { styled } from '@dark-engine/styled';
import { SpringValue, Animated, useTransition } from '@dark-engine/animations';
Expand Down
2 changes: 1 addition & 1 deletion examples/spring-snake/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, Fragment, component, useEffect, useState } from '@dark-engine/core';
import { component, useEffect, useState } from '@dark-engine/core';
import { createRoot } from '@dark-engine/platform-browser';
import { styled } from '@dark-engine/styled';
import { type SpringValue, Animated, useTrail, preset } from '@dark-engine/animations';
Expand Down
2 changes: 1 addition & 1 deletion examples/spring-toast/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, Fragment, component, useState } from '@dark-engine/core';
import { component, useState } from '@dark-engine/core';
import { createRoot } from '@dark-engine/platform-browser';
import { styled } from '@dark-engine/styled';
import { type SpringValue, Animated, useSpring } from '@dark-engine/animations';
Expand Down
2 changes: 1 addition & 1 deletion examples/svg.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, component } from '@dark-engine/core';
import { component } from '@dark-engine/core';
import { createRoot } from '@dark-engine/platform-browser';
import { styled } from '@dark-engine/styled';

Expand Down
2 changes: 0 additions & 2 deletions examples/theme-context/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import {
type DarkElement,
h,
Fragment,
component,
createContext,
useContext,
Expand Down
3 changes: 1 addition & 2 deletions packages/animations/src/animated/animated.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/** @jsx h */
import { h, Fragment, component, useState } from '@dark-engine/core';
import { component, useState } from '@dark-engine/core';
import { dom, createBrowserEnv, replacer } from '@test-utils';

import { type SpringApi } from '../use-springs';
Expand Down
Loading

0 comments on commit 383a2d0

Please sign in to comment.