Skip to content

Commit

Permalink
Update package version and export types
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsc6955 committed Jan 18, 2024
1 parent 6ffe71b commit c4e8c60
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 45 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.4.2] - 2024-01-18
### Changed
- Structure and module index to export types

## [0.4.1] - 2024-01-17
### Changed
- Exports in `package.json` to include `build/buildApp/index.js` as entry point
Expand Down
19 changes: 1 addition & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "penrose-paradox",
"version": "0.4.1",
"version": "0.4.2",
"description": "Simple vanilla JavaScript library for beginners",
"keywords": [
"penrose",
Expand All @@ -18,23 +18,6 @@
"module": "build/index.js",
"types": "build/index.d.ts",
"ts-module": "src/index.ts",
"exports": {
".": {
"import": "./build/index.js",
"require": "./build/index.js"
},
"./buildApp": "./build/buildApp/index.js"
},
"typesVersions": {
"*": {
"./": [
"build/index.d.ts"
],
"./buildApp": [
"build/buildApp/index.d.ts"
]
}
},
"license": "ISC",
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions src/core/Pubsub.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
type EventCallback = (data: any) => void;
type EventMap = { [key: string]: Set<EventCallback> };
export type EventCallback = (data: any) => void;
export type EventMap = { [key: string]: Set<EventCallback> };
/**
* PubSub class for implementing publish-subscribe pattern.
*/
Expand Down
10 changes: 5 additions & 5 deletions src/core/Router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ type RouteParams = Map<string, (string | string[])>;

// TODO: Add array support for query params

type RouterProps = {
export type RouterProps = {
queryString?: string;
params?: RouteParams;
baseUrl?: string;
};

type Route = {
export type Route = {
path: string;
component?: Function;
layout?: Function;
props?: RouterProps;
pathSegments?: string[];
};

type RouteList = Route[];
export type RouteList = Route[];

type RouterOptions = {
export type RouterOptions = {
routes?: RouteList;
baseUrl?: string;
};

type RouterMemo = {
export type RouterMemo = {
[key: string]: string;
};

Expand Down
5 changes: 1 addition & 4 deletions src/core/buildApp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import buildVirtualDOM from "./helpers/buildVirtualDOM";
import renderVirtualDOM, { targetNodeCache, setTargetNodeCache } from "./helpers/renderVirtualDOM";
import diff from "./helpers/diff";

import { ParadoxElement, ParadoxAppFunction, ParadoxVirtualElement } from "./types";

type State = any;
type StateCallback = (val: any) => void;
import { ParadoxElement, ParadoxAppFunction, ParadoxVirtualElement, State, StateCallback } from "./types";

export function addState (value: any): [State, StateCallback] {
let state = value;
Expand Down
5 changes: 4 additions & 1 deletion src/core/buildApp/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@ export type ParadoxVirtualElement = {
events?: ParadoxEvents;
} | string;

export type Patch = (node: HTMLElement) => HTMLElement | Text | undefined | ParadoxVirtualElement;
export type Patch = (node: HTMLElement) => HTMLElement | Text | undefined | ParadoxVirtualElement;

export type State = any;
export type StateCallback = (val: any) => void;
3 changes: 2 additions & 1 deletion src/core/buildElement/helpers/createElement.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type ParadoxElementCache = { [key: string]: HTMLElement };
import { ParadoxElementCache } from "../types";

const elementsCache: ParadoxElementCache = {};

/**
Expand Down
4 changes: 2 additions & 2 deletions src/core/buildElement/helpers/getText.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Object for caching processed text values
type ParadoxElementMemoizedText = { [key: string]: string };
import { ParadoxElementMemoizedText } from "../types";

const memoizedText: ParadoxElementMemoizedText = {};
// Function to retrieve or compute a formatted text value

Expand Down
3 changes: 2 additions & 1 deletion src/core/buildElement/helpers/handleEvents.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type ParadoxEventListenerWeakMap = WeakMap<HTMLElement, Map<string, EventListener>>;
import { ParadoxEventListenerWeakMap } from '../types';

// WeakMap to store event listeners for each element
const eventListeners: ParadoxEventListenerWeakMap = new WeakMap();

Expand Down
10 changes: 1 addition & 9 deletions src/core/buildElement/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@ import handleEvents from "./helpers/handleEvents";
import applyStyles from "./helpers/applyStyles";
import appendChildren from "./helpers/appendChildren";

type ParadoxElementOptions = {
id?: string;
classList?: string;
children?: ParadoxElementOptions[];
attributes?: { [key: string]: string };
events?: { [key: string]: EventListener };
text?: string;
style?: { [key: string]: string };
};
import { ParadoxElementOptions } from "./types";

/**
* Builds and returns an HTML element based on the provided tag and options.
Expand Down
15 changes: 15 additions & 0 deletions src/core/buildElement/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export type ParadoxElementOptions = {
id?: string;
classList?: string;
children?: ParadoxElementOptions[];
attributes?: { [key: string]: string };
events?: { [key: string]: EventListener };
text?: string;
style?: { [key: string]: string };
};

export type ParadoxEventListenerWeakMap = WeakMap<HTMLElement, Map<string, EventListener>>;

export type ParadoxElementMemoizedText = { [key: string]: string };

export type ParadoxElementCache = { [key: string]: HTMLElement };
12 changes: 10 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import buildElement from "./core/buildElement";
import Router from "./core/Router";
import pubsub from "./core/Pubsub";
import * as buildElementTypes from "./core/buildElement/types";
import Router, * as RouterTypes from "./core/Router";
import pubsub, * as pubsubTypes from "./core/Pubsub";
import buildApp from "./core/buildApp";
import * as types from "./core/types";

Check failure on line 6 in src/index.ts

View workflow job for this annotation

GitHub Actions / build (16.x, ubuntu-latest)

Cannot find module './core/types' or its corresponding type declarations.

/**
* Represents the Paradox object.
Expand All @@ -11,6 +13,12 @@ const Paradox = {
Router,
pubsub,
buildApp,
types: {
buildElement: buildElementTypes,
Router: RouterTypes,
pubsub: pubsubTypes,
buildApp: types,
}
};

export default Paradox;

0 comments on commit c4e8c60

Please sign in to comment.