Skip to content

Commit

Permalink
v0.0.34. fix control flow exports from bluefish-js
Browse files Browse the repository at this point in the history
  • Loading branch information
joshpoll committed Sep 28, 2024
1 parent 730ecb8 commit ff7e4d5
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 71 deletions.
2 changes: 1 addition & 1 deletion packages/bluefish-js/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules
dist
/public/App.ts
public/App.ts
5 changes: 3 additions & 2 deletions packages/bluefish-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bluefish-js",
"version": "0.0.33",
"version": "0.0.34",
"description": "A JS diagramming library",
"type": "module",
"files": [
Expand All @@ -18,7 +18,8 @@
"scripts": {
"build": "vite build",
"dev": "vite",
"serve": "vite preview"
"serve": "vite preview",
"publish": "pnpm publish"
},
"license": "MIT",
"devDependencies": {
Expand Down
11 changes: 0 additions & 11 deletions packages/bluefish-js/public/App.ts

This file was deleted.

120 changes: 65 additions & 55 deletions packages/bluefish-js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,70 +42,80 @@ export type HyperScriptReturn = () => ExpandableNode | ExpandableNode[];
export type Child = JSX.Element | HyperScriptReturn;

/* control flow components */
export function For<T extends readonly any[], U extends Child>(props: {
each: T | undefined | null | false;
fallback?: Child;
children: (item: T[number], index: Accessor<number>) => U;
}): HyperScriptReturn {
return h(ForJSX, props, props.children);
export function For<T extends readonly any[], U extends Child>(
props: {
each: T | undefined | null | false;
fallback?: Child;
},
children: (item: T[number], index: Accessor<number>) => U
): HyperScriptReturn {
return h(ForJSX, props, children);
}

export function Index<T extends readonly any[], U extends Child>(props: {
each: T | undefined | null | false;
fallback?: Child;
children: (item: Accessor<T[number]>, index: number) => U;
}): HyperScriptReturn {
return h(IndexJSX, props, props.children);
export function Index<T extends readonly any[], U extends Child>(
props: {
each: T | undefined | null | false;
fallback?: Child;
},
children: (item: Accessor<T[number]>, index: number) => U
): HyperScriptReturn {
return h(IndexJSX, props, children);
}

type RequiredParameter<T> = T extends () => unknown ? never : T;
export function Show<T, TRenderFunction extends (item: Accessor<NonNullable<T>>) => Child>(props: {
when: T | undefined | null | false;
keyed?: false;
fallback?: Child;
children: Child | RequiredParameter<TRenderFunction>;
}): HyperScriptReturn;
export function Show<T, TRenderFunction extends (item: NonNullable<T>) => Child>(props: {
when: T | undefined | null | false;
keyed: true;
fallback?: Child;
children: Child | RequiredParameter<TRenderFunction>;
}): HyperScriptReturn;
export function Show<T, TRenderFunction extends (item: NonNullable<T> | Accessor<NonNullable<T>>) => Child>(props: {
when: T | undefined | null | false;
keyed?: boolean;
fallback?: Child;
children: Child | RequiredParameter<TRenderFunction>;
}): HyperScriptReturn {
return h(ShowJSX, props, props.children);
export function Show<T, TRenderFunction extends (item: Accessor<NonNullable<T>>) => Child>(
props: {
when: T | undefined | null | false;
keyed?: false;
fallback?: Child;
},
children: Child | RequiredParameter<TRenderFunction>
): HyperScriptReturn;
export function Show<T, TRenderFunction extends (item: NonNullable<T>) => Child>(
props: {
when: T | undefined | null | false;
keyed: true;
fallback?: Child;
},
children: Child | RequiredParameter<TRenderFunction>
): HyperScriptReturn;
export function Show<T, TRenderFunction extends (item: NonNullable<T> | Accessor<NonNullable<T>>) => Child>(
props: {
when: T | undefined | null | false;
keyed?: boolean;
fallback?: Child;
},
children: Child | RequiredParameter<TRenderFunction>
): HyperScriptReturn {
return h(ShowJSX, props, children);
}

export function Switch(props: { fallback?: Child; children: Child }): HyperScriptReturn {
return h(SwitchJSX, props, props.children);
export function Switch(props: { fallback?: Child }, children: Child): HyperScriptReturn {
return h(SwitchJSX, props, children);
}

export type MatchProps<T> = {
when: T | undefined | null | false;
keyed?: boolean;
children: Child | ((item: NonNullable<T> | Accessor<NonNullable<T>>) => Child);
};

export function Match<T, TRenderFunction extends (item: Accessor<NonNullable<T>>) => Child>(props: {
when: T | undefined | null | false;
keyed?: false;
children: Child | RequiredParameter<TRenderFunction>;
}): HyperScriptReturn;
export function Match<T, TRenderFunction extends (item: NonNullable<T>) => Child>(props: {
when: T | undefined | null | false;
keyed: true;
children: Child | RequiredParameter<TRenderFunction>;
}): HyperScriptReturn;
export function Match<T, TRenderFunction extends (item: NonNullable<T> | Accessor<NonNullable<T>>) => Child>(props: {
when: T | undefined | null | false;
keyed?: boolean;
children: Child | RequiredParameter<TRenderFunction>;
}): HyperScriptReturn {
return h(MatchJSX, props, props.children);
export function Match<T, TRenderFunction extends (item: Accessor<NonNullable<T>>) => Child>(
props: {
when: T | undefined | null | false;
keyed?: false;
},
children: Child | RequiredParameter<TRenderFunction>
): HyperScriptReturn;
export function Match<T, TRenderFunction extends (item: NonNullable<T>) => Child>(
props: {
when: T | undefined | null | false;
keyed: true;
},
children: Child | RequiredParameter<TRenderFunction>
): HyperScriptReturn;
export function Match<T, TRenderFunction extends (item: NonNullable<T> | Accessor<NonNullable<T>>) => Child>(
props: {
when: T | undefined | null | false;
keyed?: boolean;
},
children: Child | RequiredParameter<TRenderFunction>
): HyperScriptReturn {
return h(MatchJSX, props, children);
}

/* bluefish components */
Expand Down
3 changes: 2 additions & 1 deletion packages/bluefish-solid/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bluefish-solid",
"version": "0.0.33",
"version": "0.0.34",
"description": "A SolidJS diagramming library",
"type": "module",
"files": [
Expand All @@ -19,6 +19,7 @@
"start": "vite",
"dev": "vite",
"build": "vite build",
"publish": "pnpm publish",
"tsc": "npx tsc --skipLibCheck -p ./tsconfig.build.json",
"serve": "vite preview",
"storybook": "storybook dev -p 6006",
Expand Down
5 changes: 4 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
"build": {
"dependsOn": ["^build"],
"inputs": ["$TURBO_DEFAULT$", ".env*"],
"outputs": [".next/**", "!.next/cache/**"]
"outputs": [".next/**", "!.next/cache/**", "dist/**"]
},
"publish": {
"dependsOn": ["build"]
},
"docs:build": {
"dependsOn": ["^docs:build"],
Expand Down

0 comments on commit ff7e4d5

Please sign in to comment.