Skip to content

Commit

Permalink
Needed to add typescript to the local packages for linting / lsp / ty…
Browse files Browse the repository at this point in the history
…pe checking to work (in both terminal (cd'd, and editor))
  • Loading branch information
NullVoxPopuli committed Apr 22, 2023
1 parent 5b13f37 commit ee4d928
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
3 changes: 2 additions & 1 deletion packages/x/vanilla/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
},
"devDependencies": {
"@starbeam-dev/build-support": "workspace:*",
"rollup": "^3.20.6"
"rollup": "^3.20.6",
"typescript": "^5.0.4"
}
}
21 changes: 7 additions & 14 deletions packages/x/vanilla/src/dom.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* TODO:
* - DynamicFragment
* - Comment
* - Namespaces
* - SVG
* - Modifier
Expand All @@ -16,8 +15,8 @@
* - other compilers (html``)
*/
import type { Description, Reactive } from "@starbeam/interfaces";
import { CachedFormula, DEBUG } from "@starbeam/reactive";
import { Resource, type ResourceBlueprint,RUNTIME,use } from "@starbeam/universal";
import { CachedFormula, DEBUG, type FormulaFn } from "@starbeam/reactive";
import { Resource,type ResourceBlueprint,RUNTIME,use } from "@starbeam/universal";

import { Cursor } from "./cursor.js";

Expand Down Expand Up @@ -149,16 +148,13 @@ function placeholder(document: Document): Text {
return document.createTextNode("");
}

type Rendered = Resource;
type Rendered = FormulaFn<unknown>;

interface OutputConstructor {
create: (options: { owner: object }) => {
read: () => void;
update: () => void
};
create: (options: { owner: object }) => FormulaFn<unknown>;
}
type ContentNode = (into: Cursor) => OutputConstructor;
type AttrNode<E extends Element = Element> = (into: E) => Resource;
type AttrNode<E extends Element = Element> = (into: E) => OutputConstructor;

function poll(rendered: Rendered[] | Rendered): void {
if (Array.isArray(rendered)) {
Expand All @@ -168,10 +164,7 @@ function poll(rendered: Rendered[] | Rendered): void {
}
}

type ContentConstructor<T extends Cursor | Element> = (options: { into: T, owner: object }) => ResourceBlueprint<{
read: () => void,
update: () => void
}>;
type ContentConstructor<T extends Cursor | Element> = (options: { into: T, owner: object }) => ResourceBlueprint;

function Content<T extends Cursor | Element>(
create: ContentConstructor<T>,
Expand All @@ -181,7 +174,7 @@ function Content<T extends Cursor | Element>(
return {
create({ owner }) {
const blueprint = create({ into, owner });
const formula = CachedFormula(() => (use(blueprint, { lifetime: owner })).current, description);
const formula = CachedFormula(() => (use(blueprint, { lifetime: owner, metadata: { owner } })).current, description);

RUNTIME.onFinalize(owner, () => void RUNTIME.finalize(formula));

Expand Down
1 change: 1 addition & 0 deletions packages/x/vanilla/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@starbeamx/vanilla": "workspace:^"
},
"devDependencies": {
"typescript": "^5.0.4",
"vitest": "^0.30.1"
}
}
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

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

0 comments on commit ee4d928

Please sign in to comment.