@yaks/react 0.0.0-stage → 0.2.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/draw.ts ADDED
@@ -0,0 +1,306 @@
1
+ /** React drawing into a browser document or a tree a host paints. @module */
2
+
3
+ /* @ts-types="npm:@types/react@19.3.0" */ import type { ReactNode } from 'npm:react@19.3.0'
4
+ /* @ts-types="npm:@types/react-dom@19.3.0" */ import { flushSync, version } from 'react-dom'
5
+ import { createRoot, hydrateRoot } from './deno-client.js'
6
+
7
+ type Surface = { draw: (node: ReactNode) => void; close: () => void }
8
+ let modern = parseInt(version) >= 19
9
+ let commit = modern ? flushSync : <T>(draw: () => T) => draw()
10
+
11
+ // React DOM consults window and the iframe constructor for focus restoration.
12
+ // The in-memory document has neither a window of its own nor frame elements.
13
+ let surfaces = 0
14
+ let restore: (() => void) | undefined
15
+ let documents = new WeakMap<Document, { refs: number; close: () => void }>()
16
+
17
+ // A painted tree dispatches capture listeners under a separate event name.
18
+ let listening = new WeakSet<Element>()
19
+ let eventName = (type: string, options?: boolean | EventListenerOptions) =>
20
+ (typeof options == 'boolean' ? options : options?.capture)
21
+ ? type + 'Capture'
22
+ : type
23
+ let listen = (element: Element) => {
24
+ if (listening.has(element)) return
25
+ listening.add(element)
26
+ let add = element.addEventListener
27
+ let remove = element.removeEventListener
28
+ element.addEventListener = ((
29
+ type: string,
30
+ listener: EventListenerOrEventListenerObject | null,
31
+ options?: boolean | AddEventListenerOptions,
32
+ ) =>
33
+ listener && add.call(
34
+ element,
35
+ eventName(type, options),
36
+ listener,
37
+ options,
38
+ )) as typeof add
39
+ element.removeEventListener = ((
40
+ type: string,
41
+ listener: EventListenerOrEventListenerObject | null,
42
+ options?: boolean | EventListenerOptions,
43
+ ) =>
44
+ listener && remove.call(
45
+ element,
46
+ eventName(type, options),
47
+ listener,
48
+ options,
49
+ )) as typeof remove
50
+ }
51
+
52
+ // React sets the option properties for a controlled select. A painted tree
53
+ // reads those states from its attributes.
54
+ let controls = (doc: Document): () => void => {
55
+ let create = doc.createElement
56
+ let createNS = doc.createElementNS
57
+ let control = (element: Element, name: string) => {
58
+ listen(element)
59
+ if (!('nodeName' in element)) {
60
+ Object.defineProperty(element, 'nodeName', {
61
+ get: () => (element as Element).tagName,
62
+ })
63
+ }
64
+ if (['input', 'textarea', 'select'].includes(name)) {
65
+ let props = name == 'input' ? ['type', 'name'] : ['name']
66
+ for (let prop of props) {
67
+ if (prop in element) continue
68
+ Object.defineProperty(element, prop, {
69
+ get: () => element.getAttribute(prop) ?? '',
70
+ set: (value: string) => element.setAttribute(prop, value),
71
+ })
72
+ }
73
+ }
74
+ if (name == 'input' || name == 'textarea') {
75
+ if (!('defaultValue' in element)) {
76
+ Object.defineProperty(element, 'defaultValue', {
77
+ get: () => element.getAttribute('value') ?? '',
78
+ set: (value: string) => {
79
+ if (!element.hasAttribute('value')) {
80
+ element.setAttribute('value', value)
81
+ }
82
+ },
83
+ })
84
+ }
85
+ }
86
+ if (name == 'select' && !('options' in element)) {
87
+ let choices = () => Array.from(element.querySelectorAll('option'))
88
+ Object.defineProperties(element, {
89
+ options: { get: choices },
90
+ value: {
91
+ get: () => {
92
+ let listed = choices()
93
+ return (listed.find((option) => option.selected) ?? listed[0])
94
+ ?.value ?? ''
95
+ },
96
+ set: (value: string) => {
97
+ for (let option of choices()) {
98
+ option.selected = option.value == value
99
+ }
100
+ },
101
+ },
102
+ })
103
+ }
104
+ if (name == 'option' && !('selected' in element)) {
105
+ for (let property of ['selected', 'defaultSelected']) {
106
+ Object.defineProperty(element, property, {
107
+ get: () => element.hasAttribute('selected'),
108
+ set: (on: boolean) => {
109
+ if (!on) return element.removeAttribute('selected')
110
+ let select = element.closest<HTMLSelectElement>('select')
111
+ if (select && !select.multiple) {
112
+ for (let option of select.querySelectorAll('option[selected]')) {
113
+ option.removeAttribute('selected')
114
+ }
115
+ }
116
+ element.setAttribute('selected', '')
117
+ },
118
+ })
119
+ }
120
+ }
121
+ return element
122
+ }
123
+ doc.createElement =
124
+ ((name: string, options?: ElementCreationOptions) =>
125
+ control(create.call(doc, name, options), name)) as typeof create
126
+ doc.createElementNS = ((
127
+ namespace: string | null,
128
+ name: string,
129
+ options?: string | ElementCreationOptions,
130
+ ) =>
131
+ control(
132
+ createNS.call(doc, namespace, name, options),
133
+ name,
134
+ )) as typeof createNS
135
+ return () => {
136
+ doc.createElement = create
137
+ doc.createElementNS = createNS
138
+ }
139
+ }
140
+
141
+ let attach = (doc: Document) => {
142
+ if (!modern) return () => {}
143
+ let current = globalThis.window
144
+ if (
145
+ typeof doc.defaultView?.HTMLIFrameElement == 'function' &&
146
+ typeof current?.HTMLIFrameElement == 'function' &&
147
+ !restore
148
+ ) {
149
+ return () => {}
150
+ }
151
+ let held = doc.defaultView ? undefined : documents.get(doc)
152
+ if (!doc.defaultView) {
153
+ if (!held) documents.set(doc, held = { refs: 0, close: controls(doc) })
154
+ held.refs++
155
+ }
156
+ let release = () => {
157
+ if (held && --held.refs == 0) {
158
+ held.close()
159
+ documents.delete(doc)
160
+ }
161
+ }
162
+ let view = doc.defaultView
163
+ let frameClass = view && typeof view.HTMLIFrameElement != 'function'
164
+ ? Object.getOwnPropertyDescriptor(view, 'HTMLIFrameElement')
165
+ : undefined
166
+ let absent = view && typeof view.HTMLIFrameElement != 'function'
167
+ if (absent) {
168
+ Object.defineProperty(view, 'HTMLIFrameElement', {
169
+ value: class {},
170
+ configurable: true,
171
+ })
172
+ }
173
+ surfaces++
174
+ if (!restore) {
175
+ let frame = current ?? doc.defaultView ?? globalThis
176
+ let undo: (() => void)[] = []
177
+ let supply = (target: object, name: string, value: unknown) => {
178
+ if (Reflect.get(target, name) != null) return
179
+ let prior = Object.getOwnPropertyDescriptor(target, name)
180
+ Object.defineProperty(target, name, {
181
+ value,
182
+ configurable: true,
183
+ writable: true,
184
+ })
185
+ undo.push(() => {
186
+ if (prior) Object.defineProperty(target, name, prior)
187
+ else Reflect.deleteProperty(target, name)
188
+ })
189
+ }
190
+ supply(globalThis, 'window', frame)
191
+ supply(frame, 'HTMLIFrameElement', class {})
192
+ restore = () => {
193
+ for (let reset of undo.reverse()) reset()
194
+ }
195
+ }
196
+ return () => {
197
+ release()
198
+ if (view && absent) {
199
+ if (frameClass) {
200
+ Object.defineProperty(view, 'HTMLIFrameElement', frameClass)
201
+ } else Reflect.deleteProperty(view, 'HTMLIFrameElement')
202
+ }
203
+ if (--surfaces == 0) {
204
+ let release = restore
205
+ let after = (globalThis as { setImmediate?: (f: () => void) => unknown })
206
+ .setImmediate ?? setTimeout
207
+ after(() => {
208
+ if (surfaces || restore !== release) return
209
+ restore = undefined
210
+ release?.()
211
+ })
212
+ }
213
+ }
214
+ }
215
+
216
+ /** Mount a React root whose draws commit before returning, so its caller can
217
+ * measure the tree or restore selection and scroll after a draft swap. */
218
+ export let surface = (
219
+ into: Element,
220
+ fell?: (error: unknown) => void,
221
+ initial?: ReactNode,
222
+ ): Surface => {
223
+ let release = attach(into.ownerDocument)
224
+ if (modern && !into.ownerDocument.defaultView) listen(into)
225
+ let root
226
+ let committing = false
227
+ let failure: { error: unknown } | undefined
228
+ type Root = ReturnType<typeof createRoot>
229
+ type Options = { onUncaughtError: (error: unknown) => void }
230
+ let open: (into: Element, options?: Options) => Root = createRoot
231
+ let resume: (into: Element, view: ReactNode, options?: Options) => Root =
232
+ hydrateRoot
233
+ let options: Options = {
234
+ onUncaughtError(error) {
235
+ if (committing) failure = { error }
236
+ else if (fell) fell(error)
237
+ else {
238
+ queueMicrotask(() => {
239
+ throw error
240
+ })
241
+ }
242
+ },
243
+ }
244
+ try {
245
+ root = initial === undefined
246
+ ? open(into, options)
247
+ : commit(() => resume(into, initial, options))
248
+ } catch (error) {
249
+ release()
250
+ throw error
251
+ }
252
+ let closed = false
253
+ return {
254
+ draw: (node) => {
255
+ failure = undefined
256
+ committing = true
257
+ try {
258
+ commit(() => root.render(node))
259
+ } finally {
260
+ committing = false
261
+ }
262
+ if (failure) throw (failure as { error: unknown }).error
263
+ },
264
+ close: () => {
265
+ if (closed) return
266
+ closed = true
267
+ try {
268
+ root.unmount()
269
+ } finally {
270
+ release()
271
+ }
272
+ },
273
+ }
274
+ }
275
+
276
+ let roots = new WeakMap<Element, Surface>()
277
+
278
+ /** Draw a page island into its retained root. Null takes the island down. */
279
+ export let render = (view: ReactNode, into: Element): void => {
280
+ let held = roots.get(into)
281
+ if (view === null) {
282
+ held?.close()
283
+ roots.delete(into)
284
+ return
285
+ }
286
+ if (!held) roots.set(into, held = surface(into))
287
+ held.draw(view)
288
+ }
289
+
290
+ /** Attach a page island to existing HTML, retaining its root for updates. */
291
+ export let hydrate = (view: ReactNode, into: Element): void => {
292
+ if (roots.has(into)) return render(view, into)
293
+ roots.set(into, surface(into, undefined, view))
294
+ }
295
+
296
+ /** Draw a view into a tree and return what takes it down. */
297
+ export let draw = (node: ReactNode, into: Element): () => void => {
298
+ let mount = surface(into)
299
+ try {
300
+ mount.draw(node)
301
+ } catch (error) {
302
+ mount.close()
303
+ throw error
304
+ }
305
+ return mount.close
306
+ }
package/host.js ADDED
@@ -0,0 +1,21 @@
1
+ /** Draw a page from a React views module and follow its draft. @module */ /* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h } from "react";
2
+ import { surface } from "./draw.js";
3
+ import { host as followed } from "@yaks/render/host";
4
+ import { entity, Registry, Vocabulary } from "./mod.js";
5
+ export { addressed, taken } from "@yaks/render/host";
6
+ /** Bind the views module to the page's store and redraw when it changes. */ export let host = (page)=>followed(page, (root, bound, registry, view)=>{
7
+ let Entity = entity({
8
+ ...bound,
9
+ registry
10
+ });
11
+ let mount = surface(root);
12
+ return {
13
+ draw: (next, words)=>mount.draw(/*#__PURE__*/ h(Vocabulary.Provider, {
14
+ value: words
15
+ }, /*#__PURE__*/ h(Registry.Provider, {
16
+ value: next
17
+ }, view(Entity)))),
18
+ close: mount.close
19
+ };
20
+ });
21
+ //# sourceMappingURL=host.js.map
package/host.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host.js","sources":["./host.ts"],"names":[],"mappings":"AAAA,wEAAwE,GACxE,uCAAuC,GAAG,SACxC,iBAAiB,CAAC,gBAGK;AACzB,SAAS,OAAO,oBAAmB;AACnC,SAEE,QAAQ,QAAQ,iCAGmB;AACrC,SACE,MAAM,EAGN,QAAQ,EACR,UAAU,mBACK;AAEjB,SAAS,SAAS,EAAc,KAAK,iCAAsC;AAQ3E,0EAA0E,GAC1E,OAAO,IAAI,OAAO,CAAC,OACjB,SAAS,MAAM,CAAC,MAAM,OAAO,UAAU;IACrC,IAAI,SAAS,OAAO;MAAE,GAAG,KAAK;MAAE;IAAS;IACzC,IAAI,QAAQ,QAAQ;IACpB,OAAO;MACL,MAAM,CAAC,MAAM,QACX,MAAM,IAAI,eACR,EACE,WAAW,QAAQ,EACnB;UAAE,OAAO;QAAM,iBACf,EAAE,SAAS,QAAQ,EAAE;UAAE,OAAO;QAAK,GAAG,KAAK;MAGjD,OAAO,MAAM,KAAK;IACpB;EACF,GAAE"}
package/host.ts ADDED
@@ -0,0 +1,46 @@
1
+ /** Draw a page from a React views module and follow its draft. @module */
2
+ /* @ts-types="npm:@types/react@19.3.0" */ import {
3
+ createElement as h,
4
+ type FunctionComponent,
5
+ type ReactNode,
6
+ } from 'react'
7
+ import { surface } from './draw.js'
8
+ import {
9
+ type Host as PageHost,
10
+ host as followed,
11
+ type Page as PageOf,
12
+ type Views as ViewsOf,
13
+ } from '@yaks/render/host'
14
+ import {
15
+ entity,
16
+ type EntityProps,
17
+ type HostRegistry,
18
+ Registry,
19
+ Vocabulary,
20
+ } from './mod.js'
21
+
22
+ export { addressed, type Draft, taken } from '@yaks/render/host'
23
+ export type Views = ViewsOf<HostRegistry>
24
+ export type Host = PageHost<HostRegistry>
25
+ export type Page = PageOf<
26
+ HostRegistry,
27
+ (Entity: FunctionComponent<EntityProps>) => ReactNode
28
+ >
29
+
30
+ /** Bind the views module to the page's store and redraw when it changes. */
31
+ export let host = (page: Page): Promise<Host> =>
32
+ followed(page, (root, bound, registry, view) => {
33
+ let Entity = entity({ ...bound, registry })
34
+ let mount = surface(root)
35
+ return {
36
+ draw: (next, words) =>
37
+ mount.draw(
38
+ h(
39
+ Vocabulary.Provider,
40
+ { value: words },
41
+ h(Registry.Provider, { value: next }, view(Entity)),
42
+ ),
43
+ ),
44
+ close: mount.close,
45
+ }
46
+ })
package/mod.js ADDED
@@ -0,0 +1,135 @@
1
+ /** React bindings for portable and component renderers. @module */ /* @ts-types="npm:@types/react@19.3.0" */ import { createContext, createElement as h, useContext, useLayoutEffect, useState } from "react";
2
+ import { rendering, resolve, viewIn } from "@yaks/render";
3
+ import { committed } from "@yaks/render/component";
4
+ let childrenOf = (children)=>children.flat(Infinity);
5
+ let hyperscript = (bundle, ctx)=>(tag, props, ...children)=>{
6
+ let { class: named, onDblClick, ...attrs } = props ?? {};
7
+ let control = committed(attrs, bundle, ctx);
8
+ if (control !== attrs && control && (tag == 'input' || tag == 'textarea' || tag == 'select')) {
9
+ let { value, checked, ...uncontrolled } = control;
10
+ control = {
11
+ ...uncontrolled,
12
+ ...value !== undefined && {
13
+ defaultValue: value
14
+ },
15
+ ...checked !== undefined && {
16
+ defaultChecked: checked
17
+ }
18
+ };
19
+ }
20
+ props = {
21
+ ...control,
22
+ className: attrs.className ?? named,
23
+ onDoubleClick: attrs.onDoubleClick ?? onDblClick
24
+ };
25
+ return /*#__PURE__*/ h(tag, props, ...childrenOf(children));
26
+ };
27
+ export function render(registry, bundle, view, vocab, ctx = {}, props) {
28
+ let renderer = resolve(registry, bundle, view, vocab, ctx);
29
+ if (!renderer) return null;
30
+ return renderSelected(registry, renderer, bundle, vocab, ctx, props);
31
+ }
32
+ /** Build the node for a renderer the host has already selected. */ export let renderSelected = (registry, renderer, bundle, vocab, ctx, props)=>{
33
+ let context = {
34
+ ...ctx,
35
+ render: (view, overrides)=>{
36
+ let next = {
37
+ ...ctx,
38
+ ...overrides
39
+ };
40
+ return render(registry, bundle, view, vocab, next, {
41
+ ...props,
42
+ ...next,
43
+ e: props ? props.e : bundle
44
+ });
45
+ }
46
+ };
47
+ if ('Render' in renderer) {
48
+ let words = viewIn(renderer, vocab);
49
+ if (words) {
50
+ let e = props?.e;
51
+ let local = words.into.read([
52
+ bundle
53
+ ])[0];
54
+ if (e && typeof e == 'object' && e !== bundle) {
55
+ let { entity: _, ...components } = local;
56
+ let value = {
57
+ ...e
58
+ };
59
+ for (let name of Object.keys(bundle)){
60
+ if (name in value && words.into.comp(name) != name) delete value[name];
61
+ }
62
+ local = {
63
+ ...value,
64
+ ...components
65
+ };
66
+ }
67
+ let comp = context.comp;
68
+ return /*#__PURE__*/ h(renderer.Render, {
69
+ ...context,
70
+ ...props,
71
+ e: local,
72
+ vocab: words.local,
73
+ comp: comp && words.into.comp(comp),
74
+ prop: comp && context.prop ? words.into.prop(comp, context.prop) : context.prop,
75
+ onPatch: ctx.onPatch && ((patch)=>{
76
+ let [{ entity: _, ...out }] = words.out.write([
77
+ {
78
+ ...patch,
79
+ entity: bundle.entity
80
+ }
81
+ ]);
82
+ ctx.onPatch(out, bundle);
83
+ }),
84
+ render: (view, overrides)=>context.render(view, overrides && {
85
+ ...overrides,
86
+ comp: overrides.comp && words.out.comp(overrides.comp),
87
+ prop: overrides.comp && overrides.prop ? words.out.prop(overrides.comp, overrides.prop) : overrides.prop
88
+ })
89
+ });
90
+ }
91
+ // Without explicit props the public overload requires E to be Bundle.
92
+ return /*#__PURE__*/ h(renderer.Render, {
93
+ ...context,
94
+ ...props,
95
+ render: context.render,
96
+ e: props ? props.e : bundle
97
+ });
98
+ }
99
+ return rendering(renderer, context)?.(bundle, hyperscript(bundle, ctx), {
100
+ ...context,
101
+ vocab
102
+ }) ?? null;
103
+ };
104
+ /** The vocabulary the host has most recently merged into its page graph. */ export let Vocabulary = /*#__PURE__*/ createContext(undefined);
105
+ /** The registry selected by the page host for mounted entities. */ export let Registry = /*#__PURE__*/ createContext(undefined);
106
+ /**
107
+ * Bind the application once: `let Entity = entity({registry, vocab, store,
108
+ * subscribe})`, then mount `<Entity eid='a' view='Tile'/>` through React.
109
+ * A notification re-reads the store even if it mutated a bundle in place.
110
+ */ export let entity = ({ registry, vocab, store, subscribe })=>({ eid, view, ...ctx })=>{
111
+ let now = useContext(Registry) ?? registry;
112
+ let words = useContext(Vocabulary) ?? vocab;
113
+ let [, revision] = useState(0);
114
+ let refresh = ()=>revision((n)=>n + 1);
115
+ useLayoutEffect(()=>{
116
+ if (!subscribe) return;
117
+ let active = true;
118
+ let off = subscribe(eid, ()=>{
119
+ if (active) refresh();
120
+ });
121
+ // A store may move between the render read and subscribing, including
122
+ // mutating the same object. Re-read once after the listener is installed.
123
+ refresh();
124
+ return ()=>{
125
+ active = false;
126
+ off();
127
+ };
128
+ }, [
129
+ eid
130
+ ]);
131
+ let bundle = store(eid);
132
+ if (!bundle) return null;
133
+ return render(now, bundle, view, words, ctx);
134
+ };
135
+ //# sourceMappingURL=mod.js.map
package/mod.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.js","sources":["./mod.ts"],"names":[],"mappings":"AAAA,iEAAiE,GAEjE,uCAAuC,GAAG,SAExC,aAAa,EACb,iBAAiB,CAAC,EAGlB,UAAU,EACV,eAAe,EACf,QAAQ,gBACe;AACzB,SAQE,SAAS,EACT,OAAO,EAEP,MAAM,4BACwB;AAChC,SACE,SAAS,sCAK+B;AA8B1C,IAAI,aAAa,CAAI,WACnB,AAAC,SAAuB,IAAI,CAAC;AAE/B,IAAI,cAAc,CAChB,QACA,MAEF,CAAC,KAAK,OAAO,GAAG;IACd,IAAI,EAAE,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,OAAO,GAAG,SAAS,CAAC;IACvD,IAAI,UAAU,UAAU,OAAO,QAAQ;IACvC,IACE,YAAY,SAAS,WACrB,CAAC,OAAO,WAAW,OAAO,cAAc,OAAO,QAAQ,GACvD;MACA,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,cAAc,GAAG;MAC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