Skip to content

Commit 648ebcb

Browse files
committed
NFR,WIP: Prefer AsyncIterable over AsyncIterator where both are acceptable in dynamic nodes / attributes.
This mitigates some of the issues created by async protocol errors where a single iterator could end up being doubly referenced. It also goes some way to rendering multi() as obsolete.
1 parent 01ac8ce commit 648ebcb

14 files changed

Lines changed: 34 additions & 29 deletions

module/dist/ai-ui.cjs

Lines changed: 4 additions & 3 deletions
Large diffs are not rendered by default.

module/dist/ai-ui.js

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

module/dist/ai-ui.min.cjs

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

module/dist/ai-ui.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

module/dist/ai-ui.min.mjs

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

module/dist/ai-ui.mjs

Lines changed: 4 additions & 3 deletions
Large diffs are not rendered by default.

module/esm/ai-ui.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export const tag = function (_1, _2, _3) {
9797
set(a) {
9898
if (isAsyncIter(a)) {
9999
const ai = asyncIterator(a);
100-
const step = () => ai.next().then(({ done, value }) => { assignProps(this, value); done || step(); }, ex => console.warn(ex));
100+
const step = () => ai.next().then(({ done, value }) => { assignProps(this, value); done || step(); }).catch(ex => console.warn(ex));
101101
step();
102102
}
103103
else

module/esm/iterators.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export interface QueueIteratableIterator<T> extends AsyncIterableIterator<T>, As
2727
export interface AsyncExtraIterable<T> extends AsyncIterable<T>, AsyncIterableHelpers {
2828
}
2929
export declare function isAsyncIter<T = unknown>(o: any | AsyncIterable<T> | AsyncIterator<T>): o is AsyncIterable<T> | AsyncIterator<T>;
30-
export type AsyncProvider<T> = AsyncIterator<T> | AsyncIterable<T>;
30+
export type AsyncProvider<T> = AsyncIterator<T> | AsyncIterable<T> | AsyncIterableIterator<T>;
3131
export declare function asyncIterator<T>(o: AsyncProvider<T>): AsyncIterator<T, any, any>;
3232
type AsyncIterableHelpers = typeof asyncExtras;
3333
export declare const asyncExtras: {

module/esm/iterators.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ export function isAsyncIter(o) {
1212
return isAsyncIterable(o) || isAsyncIterator(o);
1313
}
1414
export function asyncIterator(o) {
15-
if (isAsyncIterator(o))
16-
return o;
1715
if (isAsyncIterable(o))
1816
return o[Symbol.asyncIterator]();
17+
if (isAsyncIterator(o))
18+
return o;
1919
throw new Error("Not an async provider");
2020
}
2121
export const asyncExtras = {

module/esm/jsx-runtime.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { ChildTags, TagCreatorFunction } from "./ai-ui.js";
2-
declare const AIUIJSX: <N extends ((Node | keyof HTMLElementTagNameMap | TagCreatorFunction<any>) | /*elided*/ any)>(name: N, attrs: any, ...children: ChildTags[]) => N extends /*elided*/ any ? Node[] : Node;
1+
import { ChildTags } from "./ai-ui.js";
2+
declare const AIUIJSX: <N extends ((Node | keyof HTMLElementTagNameMap | import("./tags.js").TagCreatorFunction<any>) | /*elided*/ any)>(name: N, attrs: any, ...children: ChildTags[]) => N extends /*elided*/ any ? Node[] : Node;
33
export declare const jsx: <T extends {
44
children?: ChildTags[];
55
}>(tagName: Parameters<typeof AIUIJSX>[0], attrs: T) => Node | Node[];
66
export declare const jsxs: <T extends {
77
children?: ChildTags[];
88
}>(tagName: Parameters<typeof AIUIJSX>[0], attrs: T) => Node | Node[];
9-
export declare const Fragment: <N extends ((Node | keyof HTMLElementTagNameMap | TagCreatorFunction<any>) | /*elided*/ any)>(name: N, attrs: any, ...children: ChildTags[]) => N extends /*elided*/ any ? Node[] : Node;
9+
export declare const Fragment: <N extends ((Node | keyof HTMLElementTagNameMap | import("./tags.js").TagCreatorFunction<any>) | /*elided*/ any)>(name: N, attrs: any, ...children: ChildTags[]) => N extends /*elided*/ any ? Node[] : Node;
1010
declare global {
1111
var React: unknown;
1212
namespace JSX {
@@ -16,6 +16,6 @@ declare global {
1616
}
1717
}
1818
declare const _default: {
19-
AIUIJSX: <N extends ((Node | keyof HTMLElementTagNameMap | TagCreatorFunction<any>) | /*elided*/ any)>(name: N, attrs: any, ...children: ChildTags[]) => N extends /*elided*/ any ? Node[] : Node;
19+
AIUIJSX: <N extends ((Node | keyof HTMLElementTagNameMap | import("./tags.js").TagCreatorFunction<any>) | /*elided*/ any)>(name: N, attrs: any, ...children: ChildTags[]) => N extends /*elided*/ any ? Node[] : Node;
2020
};
2121
export default _default;

0 commit comments

Comments
 (0)