@starbeam/preact
Advanced tools
Comparing version 0.8.10-unstable.0b31af0 to 0.8.10-unstable.229fe05
117
CHANGELOG.md
@@ -1,117 +0,2 @@ | ||
# @starbeam/preact | ||
# Changelog | ||
## 0.8.9 | ||
### Patch Changes | ||
- e459bf2: Fix CJS builds | ||
- Updated dependencies [e459bf2] | ||
- @starbeam/preact-utils@0.8.9 | ||
- @starbeam/core-utils@0.8.9 | ||
- @starbeam/debug@0.8.9 | ||
- @starbeam/timeline@0.8.9 | ||
- @starbeam/universal@0.8.9 | ||
- @starbeam/verify@0.8.9 | ||
## 0.8.8 | ||
### Patch Changes | ||
- 2a1f728: Improve @starbeam/react | ||
- Updated dependencies [2a1f728] | ||
- @starbeam/preact-utils@0.8.8 | ||
- @starbeam/core-utils@0.8.8 | ||
- @starbeam/debug@0.8.8 | ||
- @starbeam/timeline@0.8.8 | ||
- @starbeam/universal@0.8.8 | ||
- @starbeam/verify@0.8.8 | ||
## 0.8.7 | ||
### Patch Changes | ||
- 14f961b: Fixes #75 | ||
- Updated dependencies [14f961b] | ||
- @starbeam/preact-utils@0.8.7 | ||
- @starbeam/core-utils@0.8.7 | ||
- @starbeam/debug@0.8.7 | ||
- @starbeam/timeline@0.8.7 | ||
- @starbeam/universal@0.8.7 | ||
- @starbeam/verify@0.8.7 | ||
## 0.8.7 | ||
### Patch Changes | ||
- ded6421: Add /setup to preact | ||
- Updated dependencies [ded6421] | ||
- @starbeam/preact-utils@0.8.7 | ||
- @starbeam/core-utils@0.8.7 | ||
- @starbeam/debug@0.8.7 | ||
- @starbeam/timeline@0.8.7 | ||
- @starbeam/universal@0.8.7 | ||
- @starbeam/verify@0.8.7 | ||
## 0.8.6 | ||
### Patch Changes | ||
- 6502cc7: Remove errant import | ||
- Updated dependencies [6502cc7] | ||
- @starbeam/preact-utils@0.8.6 | ||
- @starbeam/core-utils@0.8.6 | ||
- @starbeam/debug@0.8.6 | ||
- @starbeam/timeline@0.8.6 | ||
- @starbeam/universal@0.8.6 | ||
- @starbeam/verify@0.8.6 | ||
## 0.8.5 | ||
### Patch Changes | ||
- de755c6: Improve type inference | ||
- Updated dependencies [de755c6] | ||
- @starbeam/universal@0.8.5 | ||
- @starbeam/preact-utils@0.8.5 | ||
- @starbeam/core-utils@0.8.5 | ||
- @starbeam/debug@0.8.5 | ||
- @starbeam/timeline@0.8.5 | ||
- @starbeam/verify@0.8.5 | ||
## 0.8.4 | ||
### Patch Changes | ||
- 3bf1221: Prepare for Starbeam 0.8.4 | ||
- Updated dependencies [3bf1221] | ||
- @starbeam/timeline@0.8.4 | ||
- @starbeam/universal@0.8.4 | ||
- @starbeam/preact-utils@0.8.4 | ||
- @starbeam/core-utils@0.8.4 | ||
- @starbeam/debug@0.8.4 | ||
- @starbeam/verify@0.8.4 | ||
## 0.8.1 | ||
### Patch Changes | ||
- Updated dependencies [a781c84] | ||
- @starbeam/debug@0.8.1 | ||
- @starbeam/timeline@0.8.1 | ||
- @starbeam/universal@0.8.1 | ||
## 0.8.0 | ||
### Minor Changes | ||
- 1a553c5: Prepare for 0.8 | ||
### Patch Changes | ||
- Updated dependencies [1a553c5] | ||
- @starbeam/preact-utils@0.8.0 | ||
- @starbeam/debug@0.8.0 | ||
- @starbeam/core-utils@0.8.0 | ||
- @starbeam/timeline@0.8.0 | ||
- @starbeam/universal@0.8.0 | ||
- @starbeam/verify@0.8.0 |
@@ -47,3 +47,3 @@ import { DEBUG, StartTrackingFrame, isReactive } from '@starbeam/reactive'; | ||
const frame = ComponentFrame.#frames.get(component); | ||
verify(frame, isPresent, expected.when("in Preact's _diff hook").as("a tracking frame")); | ||
verify?.(frame, isPresent, expected?.when("in Preact's _diff hook").as("a tracking frame")); | ||
const end = frame.#end(subscription); | ||
@@ -78,3 +78,3 @@ ComponentFrame.#stack.pop(); | ||
#end(subscription) { | ||
verify(this.#active, isPresent, expected.when("in preact's _diff hook").as("an active tracking frame")); | ||
verify?.(this.#active, isPresent, expected?.when("in preact's _diff hook").as("an active tracking frame")); | ||
const frame = this.#frame = this.#active.done(); | ||
@@ -81,0 +81,0 @@ RUNTIME.update(this.#tag); |
@@ -47,3 +47,3 @@ import { DEBUG, StartTrackingFrame, isReactive } from '@starbeam/reactive'; | ||
const frame = ComponentFrame.#frames.get(component); | ||
verify(frame, isPresent, expected.when("in Preact's _diff hook").as("a tracking frame")); | ||
verify?.(frame, isPresent, expected?.when("in Preact's _diff hook").as("a tracking frame")); | ||
const end = frame.#end(subscription); | ||
@@ -78,3 +78,3 @@ ComponentFrame.#stack.pop(); | ||
#end(subscription) { | ||
verify(this.#active, isPresent, expected.when("in preact's _diff hook").as("an active tracking frame")); | ||
verify?.(this.#active, isPresent, expected?.when("in preact's _diff hook").as("an active tracking frame")); | ||
const frame = this.#frame = this.#active.done(); | ||
@@ -81,0 +81,0 @@ RUNTIME.update(this.#tag); |
@@ -1,213 +0,237 @@ | ||
import { DEBUG, StartTrackingFrame, isReactive } from '@starbeam/reactive'; | ||
import { Cell } from '@starbeam/universal'; | ||
import { useMemo, useRef, useState, useEffect, useLayoutEffect } from 'preact/hooks'; | ||
import { Plugin } from '@starbeam/preact-utils'; | ||
import { RUNTIME, render, CONTEXT } from '@starbeam/runtime'; | ||
import { finalize } from '@starbeam/shared'; | ||
import { getLast } from '@starbeam/core-utils'; | ||
import { initializeFormulaTag } from '@starbeam/tags'; | ||
import { verify, isPresent, expected } from '@starbeam/verify'; | ||
import { managerSetupReactive, managerSetupResource, managerSetupService, managerCreateLifecycle } from '@starbeam/renderer'; | ||
function create(e) { | ||
return useMemo(e, []); | ||
} | ||
import { DEBUG, StartTrackingFrame, isReactive } from "@starbeam/reactive"; | ||
import { Cell } from "@starbeam/universal"; | ||
import { | ||
useMemo, | ||
useRef, | ||
useState, | ||
useEffect, | ||
useLayoutEffect, | ||
} from "preact/hooks"; | ||
import { Plugin } from "@starbeam/preact-utils"; | ||
import { RUNTIME, render, CONTEXT } from "@starbeam/runtime"; | ||
import { finalize } from "@starbeam/shared"; | ||
import { getLast } from "@starbeam/core-utils"; | ||
import { initializeFormulaTag } from "@starbeam/tags"; | ||
import { | ||
managerSetupReactive, | ||
managerSetupResource, | ||
managerSetupService, | ||
managerCreateLifecycle, | ||
} from "@starbeam/renderer"; | ||
function createCell(t, o) { | ||
let a = DEBUG?.Desc("cell", o, "createCell"); | ||
return create(()=>Cell(t, { | ||
description: a | ||
})); | ||
let a = DEBUG?.e("cell", o, "createCell"); | ||
return useMemo(() => Cell(t, { description: a }), []); | ||
} | ||
class ComponentFrame { | ||
static #t = new WeakMap(); | ||
static #e = []; | ||
static start(t, e) { | ||
let a = ComponentFrame.#t.get(t); | ||
a || (a = new ComponentFrame(null, null, null, e), ComponentFrame.#t.set(t, a)), ComponentFrame.#e.push(t), a.#a(); | ||
} | ||
static isRenderingComponent(t) { | ||
let e = ComponentFrame.#t.get(t); | ||
return !!e && null !== e.#r; | ||
} | ||
static get current() { | ||
let e = getLast(ComponentFrame.#e); | ||
if (!e) throw Error("You are attempting to use a feature of Starbeam that depends on the current component, but no component is currently active."); | ||
return e; | ||
} | ||
static end(t, e) { | ||
let a = ComponentFrame.#t.get(t); | ||
verify(a, isPresent, expected.when("in Preact's _diff hook").as("a tracking frame")); | ||
let r = a.#n(e); | ||
return ComponentFrame.#e.pop(), r; | ||
} | ||
static unmount(t) { | ||
let e = ComponentFrame.#t.get(t); | ||
e && e.#s(); | ||
} | ||
#r; | ||
#i; | ||
#o; | ||
#m; | ||
constructor(t, a, r, n){ | ||
this.#i = t, this.#r = a; | ||
let i = initializeFormulaTag(DEBUG?.Desc("formula", n), ()=>this.#i?.children() ?? new Set()); | ||
this.#o = i, this.#m = r; | ||
} | ||
#a() { | ||
this.#i ? this.#r = this.#i.update() : this.#r = StartTrackingFrame(); | ||
} | ||
#n(t) { | ||
verify(this.#r, isPresent, expected.when("in preact's _diff hook").as("an active tracking frame")); | ||
let e = this.#i = this.#r.done(); | ||
return RUNTIME.update(this.#o), this.#r = null, t && (this.#m = render(this.#o, t)), e; | ||
} | ||
#s() { | ||
this.#m && (this.#m(), this.#m = null); | ||
} | ||
static #t = new WeakMap(); | ||
static #e = []; | ||
static start(t, e) { | ||
let a = ComponentFrame.#t.get(t); | ||
a || | ||
((a = new ComponentFrame(null, null, null, e)), | ||
ComponentFrame.#t.set(t, a)), | ||
ComponentFrame.#e.push(t), | ||
a.#a(); | ||
} | ||
static t(t) { | ||
let e = ComponentFrame.#t.get(t); | ||
return !!e && null !== e.#r; | ||
} | ||
static get e() { | ||
let e = getLast(ComponentFrame.#e); | ||
if (!e) | ||
throw Error( | ||
"You are attempting to use a feature of Starbeam that depends on the current component, but no component is currently active.", | ||
); | ||
return e; | ||
} | ||
static end(t, e) { | ||
let r = ComponentFrame.#t.get(t).#n(e); | ||
return ComponentFrame.#e.pop(), r; | ||
} | ||
static unmount(t) { | ||
let e = ComponentFrame.#t.get(t); | ||
e && e.#s(); | ||
} | ||
#r; | ||
#i; | ||
#o; | ||
#m; | ||
constructor(t, a, r, n) { | ||
(this.#i = t), (this.#r = a); | ||
let i = initializeFormulaTag( | ||
DEBUG?.r("formula", n), | ||
() => this.#i?.children() ?? new Set(), | ||
); | ||
(this.#o = i), (this.#m = r); | ||
} | ||
#a() { | ||
this.#i ? (this.#r = this.#i.update()) : (this.#r = StartTrackingFrame()); | ||
} | ||
#n(t) { | ||
let e = (this.#i = this.#r.done()); | ||
return ( | ||
RUNTIME.update(this.#o), | ||
(this.#r = null), | ||
t && (this.#m = render(this.#o, t)), | ||
e | ||
); | ||
} | ||
#s() { | ||
this.#m && (this.#m(), (this.#m = null)); | ||
} | ||
} | ||
const STARBEAM = Symbol(); | ||
function getCurrentComponent() { | ||
return ComponentFrame.current; | ||
} | ||
const install = Plugin((s)=>{ | ||
s.root((t, e)=>{ | ||
a.current = e; | ||
}), s.vnode((t)=>{ | ||
t.processChildren((t)=>isReactive(t) ? String(t.read()) : t); | ||
}), s.component.willRender((e)=>{ | ||
var n; | ||
a.current && (a.claim(e), e.context[STARBEAM] = e), CONTEXT.app = getRoot(e), ComponentFrame.start(e, DEBUG?.Desc("formula", "string" == typeof (n = e.fn) ? n : n.name, "preact.componentWillRender")); | ||
}), s.component.didRender((t)=>{ | ||
ComponentFrame.isRenderingComponent(t) && ComponentFrame.end(t, ()=>{ | ||
t.notify(); | ||
const install = Plugin((s) => { | ||
s.root((t, e) => { | ||
a.t = e; | ||
}), | ||
s.e((t) => { | ||
t.r((t) => (isReactive(t) ? String(t.read()) : t)); | ||
}), | ||
s.component.n((e) => { | ||
var n; | ||
a.t && (a.o(e), (e.context[STARBEAM] = e)), | ||
(CONTEXT.app = e.context[STARBEAM]), | ||
ComponentFrame.start( | ||
e, | ||
DEBUG?.s( | ||
"formula", | ||
"string" == typeof (n = e.a) ? n : n.name, | ||
"preact.componentWillRender", | ||
), | ||
); | ||
}), | ||
s.component.i((t) => { | ||
ComponentFrame.m(t) && | ||
ComponentFrame.end(t, () => { | ||
t.notify(); | ||
}); | ||
}), s.component.beforePaint((t)=>{ | ||
t.run("prePaint"); | ||
}), s.component.afterPaint((t)=>{ | ||
t.run("postPaint"); | ||
}), s.component.unmount((t)=>{ | ||
ComponentFrame.unmount(t), finalize(t); | ||
}), | ||
s.component.p((t) => { | ||
t.c("prePaint"); | ||
}), | ||
s.component.u((t) => { | ||
t.c("postPaint"); | ||
}), | ||
s.component.unmount((t) => { | ||
ComponentFrame.unmount(t), finalize(t); | ||
}); | ||
}); | ||
function getRoot(t) { | ||
return t.context[STARBEAM]; | ||
} | ||
class s { | ||
#t = new WeakMap(); | ||
#e = new WeakSet(); | ||
#r; | ||
claim(t) { | ||
if (!this.#r) throw Error("UNEXPECTED: No current root element"); | ||
return this.set(this.#r, t), this.#r = void 0, t; | ||
} | ||
set current(t) { | ||
this.#r = t; | ||
} | ||
get current() { | ||
return this.#r; | ||
} | ||
hasComponent(t) { | ||
return this.#e.has(t); | ||
} | ||
hasElement(t) { | ||
return this.#t.has(t); | ||
} | ||
get(t) { | ||
return this.#t.get(t); | ||
} | ||
set(t, e) { | ||
this.#t.set(t, e), this.#e.add(e); | ||
} | ||
} | ||
let a = new s(); | ||
let a = new (class { | ||
#t = new WeakMap(); | ||
#e = new WeakSet(); | ||
#r; | ||
o(t) { | ||
if (!this.#r) throw Error("UNEXPECTED: No current root element"); | ||
return this.set(this.#r, t), (this.#r = void 0), t; | ||
} | ||
set t(t) { | ||
this.#r = t; | ||
} | ||
get t() { | ||
return this.#r; | ||
} | ||
h(t) { | ||
return this.#e.has(t); | ||
} | ||
l(t) { | ||
return this.#t.has(t); | ||
} | ||
get(t) { | ||
return this.#t.get(t); | ||
} | ||
set(t, e) { | ||
this.#t.set(t, e), this.#e.add(e); | ||
} | ||
})(); | ||
const MANAGER = { | ||
getComponent: ()=>getCurrentComponent(), | ||
setupValue: (e, o)=>useMemo(o, []), | ||
setupRef: (e, o)=>{ | ||
let t = useRef(o); | ||
return t.current = o, t; | ||
e: () => ComponentFrame.t, | ||
o: (e, o) => useMemo(o, []), | ||
t: (e, o) => { | ||
let t = useRef(o); | ||
return (t.r = o), t; | ||
}, | ||
d: () => { | ||
let [, e] = useState({}); | ||
return () => { | ||
e({}); | ||
}; | ||
}, | ||
i: () => { | ||
let [o, t] = useState({}), | ||
r = new Set(); | ||
return ( | ||
useEffect(() => { | ||
for (let e of r) e(); | ||
}, [o]), | ||
{ | ||
n: () => { | ||
t({}); | ||
}, | ||
u: (e) => { | ||
r.add(e); | ||
}, | ||
} | ||
); | ||
}, | ||
l: { | ||
c: (e, t) => { | ||
useLayoutEffect(t); | ||
}, | ||
createNotifier: ()=>{ | ||
let [, e] = useState({}); | ||
return ()=>void e({}); | ||
p: (o, t) => { | ||
useEffect(t); | ||
}, | ||
createScheduler: ()=>{ | ||
let [o, t] = useState({}), r = new Set(); | ||
return useEffect(()=>{ | ||
for (let e of r)e(); | ||
}, [ | ||
o | ||
]), { | ||
schedule: ()=>void t({}), | ||
onSchedule: (e)=>void r.add(e) | ||
}; | ||
s: (o, t) => { | ||
useEffect(t); | ||
}, | ||
on: { | ||
layout: (e, t)=>void useLayoutEffect(t), | ||
idle: (o, t)=>void useEffect(t), | ||
mounted: (o, t)=>void useEffect(t) | ||
} | ||
}, | ||
}; | ||
function setupReactive(t) { | ||
return DEBUG?.markEntryPoint([ | ||
"function:call", | ||
"setupReactive" | ||
]), managerSetupReactive(MANAGER, t); | ||
return ( | ||
DEBUG?.e(["function:call", "setupReactive"]), | ||
managerSetupReactive(MANAGER, t) | ||
); | ||
} | ||
function useReactive(t, /** | ||
* Preact currently doesn't support deps, but when we support deps, you will | ||
* need to pass `[]` when there are no dependencies. | ||
*/ r) { | ||
return DEBUG?.markEntryPoint([ | ||
"function:call", | ||
"useReactive" | ||
]), setupReactive(t).read(); | ||
function useReactive(t) { | ||
return DEBUG?.e(["function:call", "useReactive"]), setupReactive(t).read(); | ||
} | ||
function setupResource(t) { | ||
return DEBUG?.markEntryPoint([ | ||
"function:call", | ||
"setupResource" | ||
]), managerSetupResource(MANAGER, t); | ||
return ( | ||
DEBUG?.e(["function:call", "setupResource"]), | ||
managerSetupResource(MANAGER, t) | ||
); | ||
} | ||
function setupSync(t) { | ||
DEBUG?.markEntryPoint([ | ||
"function:call", | ||
"setupSync" | ||
]), managerSetupResource(MANAGER, t); | ||
DEBUG?.e(["function:call", "setupSync"]), managerSetupResource(MANAGER, t); | ||
} | ||
function useResource(t, /** | ||
* Preact currently doesn't support deps, but when we support deps, you will | ||
* need to pass `[]` when there are no dependencies. | ||
*/ r) { | ||
return DEBUG?.markEntryPoint([ | ||
"function:call", | ||
"useResource" | ||
]), setupResource(t); | ||
function useResource(t) { | ||
return DEBUG?.e(["function:call", "useResource"]), setupResource(t); | ||
} | ||
function setupService(t) { | ||
return DEBUG?.markEntryPoint([ | ||
"function:call", | ||
"setupResource" | ||
]), managerSetupService(MANAGER, t); | ||
return ( | ||
DEBUG?.e(["function:call", "setupResource"]), | ||
managerSetupService(MANAGER, t) | ||
); | ||
} | ||
function useService(t) { | ||
return DEBUG?.markEntryPoint([ | ||
"function:call", | ||
"useResource" | ||
]), setupService(t); | ||
return DEBUG?.e(["function:call", "useResource"]), setupService(t); | ||
} | ||
function setup(r) { | ||
DEBUG?.markEntryPoint([ | ||
"function:call", | ||
"setup" | ||
]); | ||
let n = managerCreateLifecycle(MANAGER); | ||
return useMemo(()=>r(n), []); | ||
DEBUG?.e(["function:call", "setup"]); | ||
let n = managerCreateLifecycle(MANAGER); | ||
return useMemo(() => r(n), []); | ||
} | ||
export { createCell, install, setup, setupReactive, setupResource, setupService, setupSync, useReactive, useResource, useService }; | ||
export { | ||
createCell, | ||
install, | ||
setup, | ||
setupReactive, | ||
setupResource, | ||
setupService, | ||
setupSync, | ||
useReactive, | ||
useResource, | ||
useService, | ||
}; | ||
//# sourceMappingURL=index.production.js.map |
@@ -35,3 +35,3 @@ import { options } from 'preact'; | ||
const frame = ComponentFrame.#frames.get(component); | ||
verify(frame, isPresent, expected.when("in Preact's _diff hook").as("a tracking frame")); | ||
verify?.(frame, isPresent, expected?.when("in Preact's _diff hook").as("a tracking frame")); | ||
const end = frame.#end(subscription); | ||
@@ -66,3 +66,3 @@ ComponentFrame.#stack.pop(); | ||
#end(subscription) { | ||
verify(this.#active, isPresent, expected.when("in preact's _diff hook").as("an active tracking frame")); | ||
verify?.(this.#active, isPresent, expected?.when("in preact's _diff hook").as("an active tracking frame")); | ||
const frame = this.#frame = this.#active.done(); | ||
@@ -69,0 +69,0 @@ RUNTIME.update(this.#tag); |
@@ -35,3 +35,3 @@ import { options } from 'preact'; | ||
const frame = ComponentFrame.#frames.get(component); | ||
verify(frame, isPresent, expected.when("in Preact's _diff hook").as("a tracking frame")); | ||
verify?.(frame, isPresent, expected?.when("in Preact's _diff hook").as("a tracking frame")); | ||
const end = frame.#end(subscription); | ||
@@ -66,3 +66,3 @@ ComponentFrame.#stack.pop(); | ||
#end(subscription) { | ||
verify(this.#active, isPresent, expected.when("in preact's _diff hook").as("an active tracking frame")); | ||
verify?.(this.#active, isPresent, expected?.when("in preact's _diff hook").as("an active tracking frame")); | ||
const frame = this.#frame = this.#active.done(); | ||
@@ -69,0 +69,0 @@ RUNTIME.update(this.#tag); |
@@ -1,112 +0,132 @@ | ||
import { options } from 'preact'; | ||
import { Plugin } from '@starbeam/preact-utils'; | ||
import { DEBUG, StartTrackingFrame, isReactive } from '@starbeam/reactive'; | ||
import { RUNTIME, render, CONTEXT } from '@starbeam/runtime'; | ||
import { finalize } from '@starbeam/shared'; | ||
import { getLast } from '@starbeam/core-utils'; | ||
import { initializeFormulaTag } from '@starbeam/tags'; | ||
import { verify, isPresent, expected } from '@starbeam/verify'; | ||
import { options } from "preact"; | ||
import { Plugin } from "@starbeam/preact-utils"; | ||
import { DEBUG, StartTrackingFrame, isReactive } from "@starbeam/reactive"; | ||
import { RUNTIME, render, CONTEXT } from "@starbeam/runtime"; | ||
import { finalize } from "@starbeam/shared"; | ||
import { getLast } from "@starbeam/core-utils"; | ||
import { initializeFormulaTag } from "@starbeam/tags"; | ||
class ComponentFrame { | ||
static #t = new WeakMap(); | ||
static #e = []; | ||
static start(t, e) { | ||
let a = ComponentFrame.#t.get(t); | ||
a || (a = new ComponentFrame(null, null, null, e), ComponentFrame.#t.set(t, a)), ComponentFrame.#e.push(t), a.#a(); | ||
} | ||
static isRenderingComponent(t) { | ||
let e = ComponentFrame.#t.get(t); | ||
return !!e && null !== e.#r; | ||
} | ||
static get current() { | ||
let e = getLast(ComponentFrame.#e); | ||
if (!e) throw Error("You are attempting to use a feature of Starbeam that depends on the current component, but no component is currently active."); | ||
return e; | ||
} | ||
static end(t, e) { | ||
let a = ComponentFrame.#t.get(t); | ||
verify(a, isPresent, expected.when("in Preact's _diff hook").as("a tracking frame")); | ||
let r = a.#n(e); | ||
return ComponentFrame.#e.pop(), r; | ||
} | ||
static unmount(t) { | ||
let e = ComponentFrame.#t.get(t); | ||
e && e.#s(); | ||
} | ||
#r; | ||
#i; | ||
#o; | ||
#m; | ||
constructor(t, a, r, n){ | ||
this.#i = t, this.#r = a; | ||
let i = initializeFormulaTag(DEBUG?.Desc("formula", n), ()=>this.#i?.children() ?? new Set()); | ||
this.#o = i, this.#m = r; | ||
} | ||
#a() { | ||
this.#i ? this.#r = this.#i.update() : this.#r = StartTrackingFrame(); | ||
} | ||
#n(t) { | ||
verify(this.#r, isPresent, expected.when("in preact's _diff hook").as("an active tracking frame")); | ||
let e = this.#i = this.#r.done(); | ||
return RUNTIME.update(this.#o), this.#r = null, t && (this.#m = render(this.#o, t)), e; | ||
} | ||
#s() { | ||
this.#m && (this.#m(), this.#m = null); | ||
} | ||
static #t = new WeakMap(); | ||
static #e = []; | ||
static start(t, e) { | ||
let a = ComponentFrame.#t.get(t); | ||
a || | ||
((a = new ComponentFrame(null, null, null, e)), | ||
ComponentFrame.#t.set(t, a)), | ||
ComponentFrame.#e.push(t), | ||
a.#a(); | ||
} | ||
static t(t) { | ||
let e = ComponentFrame.#t.get(t); | ||
return !!e && null !== e.#r; | ||
} | ||
static get e() { | ||
let e = getLast(ComponentFrame.#e); | ||
if (!e) | ||
throw Error( | ||
"You are attempting to use a feature of Starbeam that depends on the current component, but no component is currently active.", | ||
); | ||
return e; | ||
} | ||
static end(t, e) { | ||
let r = ComponentFrame.#t.get(t).#n(e); | ||
return ComponentFrame.#e.pop(), r; | ||
} | ||
static unmount(t) { | ||
let e = ComponentFrame.#t.get(t); | ||
e && e.#s(); | ||
} | ||
#r; | ||
#i; | ||
#o; | ||
#m; | ||
constructor(t, a, r, n) { | ||
(this.#i = t), (this.#r = a); | ||
let i = initializeFormulaTag( | ||
DEBUG?.r("formula", n), | ||
() => this.#i?.children() ?? new Set(), | ||
); | ||
(this.#o = i), (this.#m = r); | ||
} | ||
#a() { | ||
this.#i ? (this.#r = this.#i.update()) : (this.#r = StartTrackingFrame()); | ||
} | ||
#n(t) { | ||
let e = (this.#i = this.#r.done()); | ||
return ( | ||
RUNTIME.update(this.#o), | ||
(this.#r = null), | ||
t && (this.#m = render(this.#o, t)), | ||
e | ||
); | ||
} | ||
#s() { | ||
this.#m && (this.#m(), (this.#m = null)); | ||
} | ||
} | ||
const STARBEAM = Symbol(); | ||
const install = Plugin((s)=>{ | ||
s.root((t, e)=>{ | ||
a.current = e; | ||
}), s.vnode((t)=>{ | ||
t.processChildren((t)=>isReactive(t) ? String(t.read()) : t); | ||
}), s.component.willRender((e)=>{ | ||
const STARBEAM = Symbol(), | ||
install = Plugin((s) => { | ||
s.root((t, e) => { | ||
a.t = e; | ||
}), | ||
s.e((t) => { | ||
t.r((t) => (isReactive(t) ? String(t.read()) : t)); | ||
}), | ||
s.component.n((e) => { | ||
var n; | ||
a.current && (a.claim(e), e.context[STARBEAM] = e), CONTEXT.app = getRoot(e), ComponentFrame.start(e, DEBUG?.Desc("formula", "string" == typeof (n = e.fn) ? n : n.name, "preact.componentWillRender")); | ||
}), s.component.didRender((t)=>{ | ||
ComponentFrame.isRenderingComponent(t) && ComponentFrame.end(t, ()=>{ | ||
a.t && (a.o(e), (e.context[STARBEAM] = e)), | ||
(CONTEXT.app = e.context[STARBEAM]), | ||
ComponentFrame.start( | ||
e, | ||
DEBUG?.s( | ||
"formula", | ||
"string" == typeof (n = e.a) ? n : n.name, | ||
"preact.componentWillRender", | ||
), | ||
); | ||
}), | ||
s.component.i((t) => { | ||
ComponentFrame.m(t) && | ||
ComponentFrame.end(t, () => { | ||
t.notify(); | ||
}); | ||
}), s.component.beforePaint((t)=>{ | ||
t.run("prePaint"); | ||
}), s.component.afterPaint((t)=>{ | ||
t.run("postPaint"); | ||
}), s.component.unmount((t)=>{ | ||
}); | ||
}), | ||
s.component.p((t) => { | ||
t.c("prePaint"); | ||
}), | ||
s.component.u((t) => { | ||
t.c("postPaint"); | ||
}), | ||
s.component.unmount((t) => { | ||
ComponentFrame.unmount(t), finalize(t); | ||
}); | ||
}); | ||
function getRoot(t) { | ||
return t.context[STARBEAM]; | ||
} | ||
class s { | ||
#t = new WeakMap(); | ||
#e = new WeakSet(); | ||
#r; | ||
claim(t) { | ||
if (!this.#r) throw Error("UNEXPECTED: No current root element"); | ||
return this.set(this.#r, t), this.#r = void 0, t; | ||
} | ||
set current(t) { | ||
this.#r = t; | ||
} | ||
get current() { | ||
return this.#r; | ||
} | ||
hasComponent(t) { | ||
return this.#e.has(t); | ||
} | ||
hasElement(t) { | ||
return this.#t.has(t); | ||
} | ||
get(t) { | ||
return this.#t.get(t); | ||
} | ||
set(t, e) { | ||
this.#t.set(t, e), this.#e.add(e); | ||
} | ||
} | ||
let a = new s(); | ||
}); | ||
}); | ||
let a = new (class { | ||
#t = new WeakMap(); | ||
#e = new WeakSet(); | ||
#r; | ||
o(t) { | ||
if (!this.#r) throw Error("UNEXPECTED: No current root element"); | ||
return this.set(this.#r, t), (this.#r = void 0), t; | ||
} | ||
set t(t) { | ||
this.#r = t; | ||
} | ||
get t() { | ||
return this.#r; | ||
} | ||
h(t) { | ||
return this.#e.has(t); | ||
} | ||
l(t) { | ||
return this.#t.has(t); | ||
} | ||
get(t) { | ||
return this.#t.get(t); | ||
} | ||
set(t, e) { | ||
this.#t.set(t, e), this.#e.add(e); | ||
} | ||
})(); | ||
install(options); | ||
//# sourceMappingURL=setup.production.js.map |
{ | ||
"name": "@starbeam/preact", | ||
"type": "module", | ||
"version": "0.8.10-unstable.0b31af0", | ||
"version": "0.8.10-unstable.229fe05", | ||
"main": "dist/index.cjs", | ||
@@ -21,20 +21,20 @@ "types": "dist/index.d.ts", | ||
"@preact/signals": "^1.1.5", | ||
"@starbeam/core-utils": "0.8.10-unstable.0b31af0", | ||
"@starbeam/debug": "0.8.10-unstable.0b31af0", | ||
"@starbeam/interfaces": "0.8.10-unstable.0b31af0", | ||
"@starbeam/preact-utils": "0.8.10-unstable.0b31af0", | ||
"@starbeam/reactive": "0.8.10-unstable.0b31af0", | ||
"@starbeam/renderer": "0.8.10-unstable.0b31af0", | ||
"@starbeam/resource": "0.0.1-unstable.0b31af0", | ||
"@starbeam/runtime": "0.8.10-unstable.0b31af0", | ||
"@starbeam/service": "0.0.1-unstable.0b31af0", | ||
"@starbeam/shared": "1.3.8-unstable.0b31af0", | ||
"@starbeam/tags": "0.0.1-unstable.0b31af0", | ||
"@starbeam/universal": "0.8.10-unstable.0b31af0", | ||
"@starbeam/verify": "0.8.10-unstable.0b31af0" | ||
"@starbeam/core-utils": "0.8.10-unstable.229fe05", | ||
"@starbeam/debug": "0.8.10-unstable.229fe05", | ||
"@starbeam/interfaces": "0.8.10-unstable.229fe05", | ||
"@starbeam/preact-utils": "0.8.10-unstable.229fe05", | ||
"@starbeam/reactive": "0.8.10-unstable.229fe05", | ||
"@starbeam/renderer": "0.8.10-unstable.229fe05", | ||
"@starbeam/resource": "0.0.1-unstable.229fe05", | ||
"@starbeam/runtime": "0.8.10-unstable.229fe05", | ||
"@starbeam/service": "0.0.1-unstable.229fe05", | ||
"@starbeam/shared": "1.3.8-unstable.229fe05", | ||
"@starbeam/tags": "0.0.1-unstable.229fe05", | ||
"@starbeam/universal": "0.8.10-unstable.229fe05", | ||
"@starbeam/verify": "0.8.10-unstable.229fe05" | ||
}, | ||
"devDependencies": { | ||
"@starbeam-dev/compile": "^1.0.2", | ||
"@starbeam-dev/eslint-plugin": "^1.0.4", | ||
"rollup": "^4.0.2" | ||
"@starbeam-dev/eslint-plugin": "^1.0.6", | ||
"rollup": "^4.0.2", | ||
"@starbeam-dev/compile": "1.2.0" | ||
}, | ||
@@ -41,0 +41,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
156185
1257
+ Added@domtree/any@0.9.4-unstable.229fe05(transitive)
+ Added@domtree/browser@0.9.4-unstable.229fe05(transitive)
+ Added@domtree/interface@0.9.4-unstable.229fe05(transitive)
+ Added@domtree/minimal@0.9.4-unstable.229fe05(transitive)
+ Added@starbeam/core-utils@0.8.10-unstable.229fe05(transitive)
+ Added@starbeam/debug@0.8.10-unstable.229fe05(transitive)
+ Added@starbeam/interfaces@0.8.10-unstable.229fe05(transitive)
+ Added@starbeam/preact-utils@0.8.10-unstable.229fe05(transitive)
+ Added@starbeam/reactive@0.8.10-unstable.229fe05(transitive)
+ Added@starbeam/renderer@0.8.10-unstable.229fe05(transitive)
+ Added@starbeam/resource@0.0.1-unstable.229fe05(transitive)
+ Added@starbeam/runtime@0.8.10-unstable.229fe05(transitive)
+ Added@starbeam/service@0.0.1-unstable.229fe05(transitive)
+ Added@starbeam/shared@1.3.8-unstable.229fe05(transitive)
+ Added@starbeam/tags@0.0.1-unstable.229fe05(transitive)
+ Added@starbeam/universal@0.8.10-unstable.229fe05(transitive)
+ Added@starbeam/verify@0.8.10-unstable.229fe05(transitive)
- Removed@domtree/any@0.9.3(transitive)
- Removed@domtree/browser@0.9.3(transitive)
- Removed@domtree/interface@0.9.3(transitive)
- Removed@domtree/minimal@0.9.3(transitive)
- Removed@starbeam/core-utils@0.8.10-unstable.0b31af0(transitive)
- Removed@starbeam/debug@0.8.10-unstable.0b31af0(transitive)
- Removed@starbeam/interfaces@0.8.10-unstable.0b31af0(transitive)
- Removed@starbeam/preact-utils@0.8.10-unstable.0b31af0(transitive)
- Removed@starbeam/reactive@0.8.10-unstable.0b31af0(transitive)
- Removed@starbeam/renderer@0.8.10-unstable.0b31af0(transitive)
- Removed@starbeam/resource@0.0.1-unstable.0b31af0(transitive)
- Removed@starbeam/runtime@0.8.10-unstable.0b31af0(transitive)
- Removed@starbeam/service@0.0.1-unstable.0b31af0(transitive)
- Removed@starbeam/shared@1.3.8-unstable.0b31af0(transitive)
- Removed@starbeam/tags@0.0.1-unstable.0b31af0(transitive)
- Removed@starbeam/universal@0.8.10-unstable.0b31af0(transitive)
- Removed@starbeam/verify@0.8.10-unstable.0b31af0(transitive)