Skip to content

Commit

Permalink
types
Browse files Browse the repository at this point in the history
  • Loading branch information
atellmer committed Nov 25, 2022
1 parent 3b4f3c8 commit 540508f
Show file tree
Hide file tree
Showing 31 changed files with 295 additions and 25 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@
],
"@typescript-eslint/no-var-requires": [
"off"
],
"@typescript-eslint/no-empty-interface": [
"off"
]
}
}
}
2 changes: 1 addition & 1 deletion packages/core/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ npm-debug.log
.DS_Store
Thumbs.db
yarn-error.log
/umd

3 changes: 3 additions & 0 deletions packages/core/before-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const shell = require('shelljs');

shell.rm('-rf', 'types/*');
5 changes: 0 additions & 5 deletions packages/core/index.d.ts

This file was deleted.

8 changes: 5 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{
"name": "@dark-engine/core",
"version": "0.9.7",
"version": "0.9.7-beta.1",
"description": "Dark is lightweight (10 Kb gzipped) component-and-hook-based UI rendering engine for javascript apps without dependencies and written in TypeScript 💫",
"author": "AlexPlex",
"license": "MIT",
"main": "./index.js",
"typings": "./types/index.d.ts",
"scripts": {
"build": "npm run build:types && npm run build:dev && npm run build:prod && npm run format",
"build": "npm run before-build && npm run build:types && npm run build:dev && npm run build:prod && npm run format",
"build:dev": "webpack --config webpack.config --env development",
"build:prod": "webpack --config webpack.config --env production",
"build:types": "npx tsc -d --emitDeclarationOnly --skipLibCheck --declarationDir types",
"format": "npx prettier --write ./**/*.{js,ts}"
"format": "npx prettier --write ./**/*.{js,ts}",
"before-build": "node ./before-build.js"
},
"repository": {
"type": "git",
Expand All @@ -27,6 +28,7 @@
],
"devDependencies": {
"@types/requestidlecallback": "^0.3.1",
"shelljs": "^0.8.5",
"ts-loader": "9.3.1",
"typescript": "4.7.4",
"webpack": "5.73.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"./**/*.ts"
],
"exclude": [
"src/**/*.spec.ts"
"./**/*.spec.ts"
]
}
81 changes: 80 additions & 1 deletion packages/core/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,17 @@ ansi-styles@^4.1.0:
dependencies:
color-convert "^2.0.1"

balanced-match@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"

brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
dependencies:
balanced-match "^1.0.0"
concat-map "0.0.1"

braces@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
Expand Down Expand Up @@ -293,6 +304,10 @@ commander@^7.0.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7"

[email protected]:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"

cross-spawn@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
Expand Down Expand Up @@ -374,6 +389,10 @@ find-up@^4.0.0:
locate-path "^5.0.0"
path-exists "^4.0.0"

fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"

function-bind@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
Expand All @@ -382,6 +401,17 @@ glob-to-regexp@^0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e"

glob@^7.0.0:
version "7.2.3"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b"
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.1.1"
once "^1.3.0"
path-is-absolute "^1.0.0"

graceful-fs@^4.1.2, graceful-fs@^4.2.4, graceful-fs@^4.2.9:
version "4.2.10"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c"
Expand All @@ -403,6 +433,21 @@ import-local@^3.0.2:
pkg-dir "^4.2.0"
resolve-cwd "^3.0.0"

inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
dependencies:
once "^1.3.0"
wrappy "1"

inherits@2:
version "2.0.4"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"

interpret@^1.0.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.4.0.tgz#665ab8bc4da27a774a40584e812e3e0fa45b1a1e"

interpret@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/interpret/-/interpret-2.2.0.tgz#1a78a0b5965c40a5416d007ad6f50ad27c417df9"
Expand Down Expand Up @@ -488,6 +533,12 @@ mime-types@^2.1.27:
dependencies:
mime-db "1.52.0"

minimatch@^3.1.1:
version "3.1.2"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
dependencies:
brace-expansion "^1.1.7"

neo-async@^2.6.2:
version "2.6.2"
resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f"
Expand All @@ -496,6 +547,12 @@ node-releases@^2.0.5:
version "2.0.6"
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.6.tgz#8a7088c63a55e493845683ebf3c828d8c51c5503"

once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
dependencies:
wrappy "1"

p-limit@^2.2.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1"
Expand All @@ -516,6 +573,10 @@ path-exists@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3"

path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"

path-key@^3.1.0:
version "3.1.1"
resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375"
Expand Down Expand Up @@ -548,6 +609,12 @@ randombytes@^2.1.0:
dependencies:
safe-buffer "^5.1.0"

rechoir@^0.6.2:
version "0.6.2"
resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384"
dependencies:
resolve "^1.1.6"

rechoir@^0.7.0:
version "0.7.1"
resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.7.1.tgz#9478a96a1ca135b5e88fc027f03ee92d6c645686"
Expand All @@ -564,7 +631,7 @@ resolve-from@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69"

resolve@^1.9.0:
resolve@^1.1.6, resolve@^1.9.0:
version "1.22.1"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.1.tgz#27cb2ebb53f91abb49470a928bba7558066ac177"
dependencies:
Expand Down Expand Up @@ -612,6 +679,14 @@ shebang-regex@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172"

shelljs@^0.8.5:
version "0.8.5"
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.5.tgz#de055408d8361bed66c669d2f000538ced8ee20c"
dependencies:
glob "^7.0.0"
interpret "^1.0.0"
rechoir "^0.6.2"

source-map-support@~0.5.20:
version "0.5.21"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f"
Expand Down Expand Up @@ -768,6 +843,10 @@ wildcard@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/wildcard/-/wildcard-2.0.0.tgz#a77d20e5200c6faaac979e4b3aadc7b3dd7f8fec"

wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"

yallist@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
1 change: 1 addition & 0 deletions packages/platform-browser/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/umd
5 changes: 5 additions & 0 deletions packages/platform-browser/after-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const shell = require('shelljs');

shell.rm('-rf', 'types/core');
shell.cp('-R', ' types/platform-browser/src/*', 'types');
shell.rm('-rf', ' types/platform-browser');
3 changes: 3 additions & 0 deletions packages/platform-browser/before-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const shell = require('shelljs');

shell.rm('-rf', 'types/*');
5 changes: 0 additions & 5 deletions packages/platform-browser/index.d.ts

This file was deleted.

13 changes: 9 additions & 4 deletions packages/platform-browser/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
{
"name": "@dark-engine/platform-browser",
"version": "0.9.7",
"version": "0.9.7-beta.1",
"description": "Dark is lightweight (10 Kb gzipped) component-and-hook-based UI rendering engine for javascript apps without dependencies and written in TypeScript 💫",
"author": "AlexPlex",
"license": "MIT",
"main": "./index.js",
"typings": "./index.d.ts",
"typings": "./types/index.d.ts",
"scripts": {
"build": "npm run build:dev && npm run build:prod",
"build": "npm run before-build && npm run build:types && npm run build:dev && npm run build:prod && npm run format && npm run after-build",
"build:dev": "webpack --config webpack.config --env development",
"build:prod": "webpack --config webpack.config --env production"
"build:prod": "webpack --config webpack.config --env production",
"build:types": "npx tsc -d --emitDeclarationOnly --skipLibCheck --declarationDir types",
"format": "npx prettier --write ./**/*.{js,ts}",
"after-build": "node ./after-build.js",
"before-build": "node ./before-build.js"
},
"repository": {
"type": "git",
Expand All @@ -25,6 +29,7 @@
],
"devDependencies": {
"@types/requestidlecallback": "^0.3.1",
"shelljs": "^0.8.5",
"ts-loader": "9.3.1",
"typescript": "4.7.4",
"webpack": "5.73.0",
Expand Down
4 changes: 1 addition & 3 deletions packages/platform-browser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ export const version = process.env.VERSION;

declare global {
namespace JSX {
interface IntrinsicElements {
[elemName: string]: Record<string, any>;
}
interface IntrinsicElements {}
}
}
9 changes: 9 additions & 0 deletions packages/platform-browser/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig",
"include": [
"./**/*.ts"
],
"exclude": [
"./**/*.spec.ts"
]
}
6 changes: 6 additions & 0 deletions packages/platform-browser/types/create-root/create-root.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { type DarkElement } from '@dark-engine/core';
declare function createRoot(container: Element): {
render: (element: DarkElement) => void;
unmount: () => void;
};
export { createRoot };
1 change: 1 addition & 0 deletions packages/platform-browser/types/create-root/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './create-root';
8 changes: 8 additions & 0 deletions packages/platform-browser/types/dom/dom.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { type Fiber, type VirtualNode } from '@dark-engine/core';
import type { DOMElement } from './types';
declare let trackUpdate: (nativeElement: Element) => void;
declare function createNativeElement(vNode: VirtualNode): DOMElement;
declare function applyCommit(fiber: Fiber<Element>): void;
declare function finishCommitWork(): void;
declare function setTrackUpdate(fn: typeof trackUpdate): void;
export { createNativeElement, applyCommit, finishCommitWork, setTrackUpdate };
2 changes: 2 additions & 0 deletions packages/platform-browser/types/dom/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './dom';
export * from './types';
5 changes: 5 additions & 0 deletions packages/platform-browser/types/dom/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export declare type DOMElement = HTMLElement | SVGElement | Text | Comment;
export declare type DOMFragment = {
fragment: DocumentFragment;
callback: () => void;
};
19 changes: 19 additions & 0 deletions packages/platform-browser/types/events/events.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
declare class SyntheticEvent<E extends Event, T = Element> {
type: string;
sourceEvent: E;
target: T;
private propagation;
constructor(options: Pick<SyntheticEvent<E, T>, 'sourceEvent' | 'target'>);
stopPropagation(): void;
preventDefault(): void;
getPropagation(): boolean;
}
declare type DelegateEventOptions = {
target: Element;
eventName: string;
handler: (e: Event) => void;
};
declare function delegateEvent(options: DelegateEventOptions): void;
declare const detectIsEvent: (attrName: string) => boolean;
declare const getEventName: (attrName: string) => string;
export { SyntheticEvent, delegateEvent, detectIsEvent, getEventName };
1 change: 1 addition & 0 deletions packages/platform-browser/types/events/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './events';
12 changes: 12 additions & 0 deletions packages/platform-browser/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export { render } from './render';
export { createRoot } from './create-root';
export { createPortal } from './portal';
export { useStyle } from './use-style';
export { setTrackUpdate } from './dom';
export type { SyntheticEvent } from './events';
export declare const version: string;
declare global {
namespace JSX {
interface IntrinsicElements {}
}
}
1 change: 1 addition & 0 deletions packages/platform-browser/types/portal/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './portal';
22 changes: 22 additions & 0 deletions packages/platform-browser/types/portal/portal.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { type Fiber, type DarkElement, type ComponentFactory } from '@dark-engine/core';
declare const $$portal: unique symbol;
declare function createPortal(
slot: DarkElement,
container: Element,
): ComponentFactory<
PortalProps &
import('@dark-engine/core').KeyProps &
Readonly<{
slot?: DarkElement;
}> &
import('@dark-engine/core').RefProps<unknown>,
any
>;
declare type PortalProps = {
[$$portal]: Element;
slot: DarkElement;
};
declare const detectIsPortal: (factory: unknown) => factory is ComponentFactory<any, any>;
declare const getPortalContainer: (factory: unknown) => Element | null;
declare function unmountPortal(fiber: Fiber<Element>): void;
export { createPortal, detectIsPortal, getPortalContainer, unmountPortal };
1 change: 1 addition & 0 deletions packages/platform-browser/types/render/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './render';
4 changes: 4 additions & 0 deletions packages/platform-browser/types/render/render.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { type DarkElement } from '@dark-engine/core';
declare const roots: Map<Element, number>;
declare function render(element: DarkElement, container: Element): void;
export { render, roots };
1 change: 1 addition & 0 deletions packages/platform-browser/types/scheduler/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './scheduler';
Loading

0 comments on commit 540508f

Please sign in to comment.