Skip to content

Commit

Permalink
Fix #93 - Improve TS definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
WebReflection committed Dec 20, 2023
1 parent ee83d44 commit 29190e0
Show file tree
Hide file tree
Showing 20 changed files with 121 additions and 99 deletions.
2 changes: 1 addition & 1 deletion esm/index.js
Expand Up @@ -2,7 +2,7 @@

import { Hole } from './rabbit.js';
import { attr } from './handler.js';
import render from './render-hole.js';
import render from './render/hole.js';

/** @typedef {import("./literals.js").Value} Value */

Expand Down
10 changes: 5 additions & 5 deletions esm/init.js
Expand Up @@ -38,7 +38,7 @@ export default document => (function (exports) {
/** @typedef {import("./rabbit.js").Hole} Hole */

/** @typedef {Node | Element | PersistentFragment} Target */
/** @typedef {null | undefined | string | number | boolean | Hole} Value */
/** @typedef {null | undefined | string | number | boolean | Hole | ((...args: unknown[]) => unknown)} Value */
/** @typedef {null | undefined | string | number | boolean | Node | Element | PersistentFragment} DOMValue */

/**
Expand Down Expand Up @@ -868,17 +868,17 @@ export default document => (function (exports) {
/** @type {(template: TemplateStringsArray, ...values:Value[]) => Hole} A tag to render SVG content. */
const svg = tag(true);

/** @type {WeakMap<Element | DocumentFragment, import("./literals.js").Cache>} */
/** @type {WeakMap<Element | DocumentFragment, import("../literals.js").Cache>} */
const known = new WeakMap;

/**
* Render with smart updates within a generic container.
* @template T
* @param {T} where the DOM node where to render content
* @param {() => Hole | Hole} what the hole to render
* @param {(() => Hole) | Hole} what the hole to render
* @returns
*/
var renderKeyed = (where, what) => {
var keyed$1 = (where, what) => {
const info = known.get(where) || set(known, where, cache$1(empty));
const hole = typeof what === 'function' ? what() : what;
const { n } = info;
Expand Down Expand Up @@ -922,7 +922,7 @@ export default document => (function (exports) {
exports.attr = attr;
exports.html = html;
exports.htmlFor = htmlFor;
exports.render = renderKeyed;
exports.render = keyed$1;
exports.svg = svg;
exports.svgFor = svgFor;

Expand Down
2 changes: 1 addition & 1 deletion esm/keyed.js
Expand Up @@ -3,7 +3,7 @@ import { Hole, unroll } from './rabbit.js';
import { empty, set } from './utils.js';
import { html, svg } from './index.js';
import { attr } from './handler.js';
import render from './render-keyed.js';
import render from './render/keyed.js';

/** @typedef {import("./literals.js").Cache} Cache */
/** @typedef {import("./literals.js").Target} Target */
Expand Down
2 changes: 1 addition & 1 deletion esm/literals.js
Expand Up @@ -9,7 +9,7 @@ import { empty } from './utils.js';
/** @typedef {import("./rabbit.js").Hole} Hole */

/** @typedef {Node | Element | PersistentFragment} Target */
/** @typedef {null | undefined | string | number | boolean | Hole} Value */
/** @typedef {null | undefined | string | number | boolean | Hole | ((...args: unknown[]) => unknown)} Value */
/** @typedef {null | undefined | string | number | boolean | Node | Element | PersistentFragment} DOMValue */

/**
Expand Down
2 changes: 1 addition & 1 deletion esm/node.js
Expand Up @@ -2,7 +2,7 @@

import create from './creator.js';
import parser from './parser.js';
import render from './render-node.js';
import render from './render/node.js';
import { attr } from './handler.js';

/** @typedef {import("./literals.js").DOMValue} DOMValue */
Expand Down
12 changes: 6 additions & 6 deletions esm/render-hole.js → esm/render/hole.js
@@ -1,17 +1,17 @@
import { cache } from './literals.js';
import { unroll } from './rabbit.js';
import { empty, set } from './utils.js';
import { cache } from '../literals.js';
import { unroll } from '../rabbit.js';
import { empty, set } from '../utils.js';

/** @typedef {import("./rabbit.js").Hole} Hole */
/** @typedef {import("../rabbit.js").Hole} Hole */

/** @type {WeakMap<Element | DocumentFragment, import("./literals.js").Cache>} */
/** @type {WeakMap<Element | DocumentFragment, import("../literals.js").Cache>} */
const known = new WeakMap;

/**
* Render with smart updates within a generic container.
* @template T
* @param {T} where the DOM node where to render content
* @param {() => Hole | Hole} what the hole to render
* @param {(() => Hole) | Hole} what the hole to render
* @returns
*/
export default (where, what) => {
Expand Down
10 changes: 5 additions & 5 deletions esm/render-keyed.js → esm/render/keyed.js
@@ -1,15 +1,15 @@
import { cache } from './literals.js';
import { Hole, unroll } from './rabbit.js';
import { empty, set } from './utils.js';
import { cache } from '../literals.js';
import { Hole, unroll } from '../rabbit.js';
import { empty, set } from '../utils.js';

/** @type {WeakMap<Element | DocumentFragment, import("./literals.js").Cache>} */
/** @type {WeakMap<Element | DocumentFragment, import("../literals.js").Cache>} */
const known = new WeakMap;

/**
* Render with smart updates within a generic container.
* @template T
* @param {T} where the DOM node where to render content
* @param {() => Hole | Hole} what the hole to render
* @param {(() => Hole) | Hole} what the hole to render
* @returns
*/
export default (where, what) => {
Expand Down
4 changes: 2 additions & 2 deletions esm/render-node.js → esm/render/node.js
@@ -1,10 +1,10 @@
/** @typedef {import("./literals.js").Target} Target */
/** @typedef {import("../literals.js").Target} Target */

/**
* Render directly within a generic container.
* @template T
* @param {T} where the DOM node where to render content
* @param {() => Target | Target} what the node to render
* @param {(() => Target) | Target} what the node to render
* @returns
*/
export default (where, what) => {
Expand Down
134 changes: 74 additions & 60 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 29190e0

Please sign in to comment.