@bun-native/solid 0.0.0-bootstrap.0 → 0.33.0
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/LICENSE +21 -0
- package/README.md +5 -0
- package/bun-native-source.json +43 -0
- package/package.json +36 -1
- package/src/index.ts +30 -0
- package/src/jsx.ts +67 -0
- package/src/mount.ts +43 -0
- package/src/renderer.ts +33 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bunly contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# @bun-native/solid
|
|
2
|
+
|
|
3
|
+
SolidJS renderer for Bun Native desktop windows.
|
|
4
|
+
|
|
5
|
+
Part of [Bun Native](https://github.com/0xPlayerOne/bun-native), an experimental developer preview. Version 0.33.0 was built from [fa8bef754122](https://github.com/0xPlayerOne/bun-native/tree/fa8bef754122621d4235eb06e30bb1085b4f7b1e) and published from GitHub Actions with npm provenance. Use the Bun revision pinned in that commit's toolchain.json. Start with the [getting-started guide](https://github.com/0xPlayerOne/bun-native/blob/fa8bef754122621d4235eb06e30bb1085b4f7b1e/docs/getting-started.md); `bun-native host install` fetches the matching release host. The license notice is in LICENSE.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"commit": "fa8bef754122621d4235eb06e30bb1085b4f7b1e",
|
|
4
|
+
"tree": "f805e2eb19a4e10fc29d1dc827cf5bc617b5773b",
|
|
5
|
+
"files": {
|
|
6
|
+
"package.json": {
|
|
7
|
+
"bytes": 2164,
|
|
8
|
+
"sha256": "db50b6f81f25c113a46f8c9b038bc548a92effaeb4ad9562e5e95044baa7b66f"
|
|
9
|
+
},
|
|
10
|
+
"packages/solid/package.json": {
|
|
11
|
+
"bytes": 310,
|
|
12
|
+
"sha256": "5da76ecbbb9ba781fc827191b33a42b25ddcfd8ba1838c0256f82ea1c6838b84"
|
|
13
|
+
},
|
|
14
|
+
"packages/solid/src/index.ts": {
|
|
15
|
+
"bytes": 695,
|
|
16
|
+
"sha256": "88fe2cfc3d59011bb756bb86bfb040e6280feabd1edb33b7cdeecfc524652250"
|
|
17
|
+
},
|
|
18
|
+
"packages/solid/src/jsx.ts": {
|
|
19
|
+
"bytes": 2731,
|
|
20
|
+
"sha256": "0ea5386e11e9df63541c381d4794fe0edc0e8269158fa3ac6b6739d12f16c729"
|
|
21
|
+
},
|
|
22
|
+
"packages/solid/src/mount.ts": {
|
|
23
|
+
"bytes": 1323,
|
|
24
|
+
"sha256": "411fa124f9ef0a3aab4333ec6fe8aee57bc8ba4032565e2c1cb361d9d89c3ab2"
|
|
25
|
+
},
|
|
26
|
+
"packages/solid/src/renderer.ts": {
|
|
27
|
+
"bytes": 1292,
|
|
28
|
+
"sha256": "2d1682b885c1dee1953ba09fdf28bf524945654f7c460840c113cc7b00213ab1"
|
|
29
|
+
},
|
|
30
|
+
"LICENSE": {
|
|
31
|
+
"bytes": 1075,
|
|
32
|
+
"sha256": "86673fb485f12fa9aaa3941dfccc9f69a7f8322f8141d0d5c73db4323de10ac5"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"toolchain": {
|
|
36
|
+
"bytes": 3012,
|
|
37
|
+
"sha256": "00c3f707aae8abe9ca75cd2e162f5e1c7c34362a03675da39afead60d856066a"
|
|
38
|
+
},
|
|
39
|
+
"dependencyLock": {
|
|
40
|
+
"bytes": 28357,
|
|
41
|
+
"sha256": "65e3dbd01be4a1889367690faf1a9c3f08fb31d22dbd273d9bb9f39dd6baa6fb"
|
|
42
|
+
}
|
|
43
|
+
}
|
package/package.json
CHANGED
|
@@ -1 +1,36 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"name": "@bun-native/solid",
|
|
3
|
+
"version": "0.33.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"files": [
|
|
7
|
+
"src",
|
|
8
|
+
"LICENSE",
|
|
9
|
+
"README.md",
|
|
10
|
+
"bun-native-source.json"
|
|
11
|
+
],
|
|
12
|
+
"engines": {
|
|
13
|
+
"bun": "1.4.4-canary.1"
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": "./src/index.ts",
|
|
17
|
+
"./jsx-runtime": "./src/jsx.ts"
|
|
18
|
+
},
|
|
19
|
+
"description": "SolidJS renderer for Bun Native desktop windows.",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@bun-native/core": "0.33.0",
|
|
22
|
+
"solid-js": "1.9.18",
|
|
23
|
+
"@bun-native/renderer": "0.33.0"
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/0xPlayerOne/bun-native.git",
|
|
28
|
+
"directory": "packages/solid"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/0xPlayerOne/bun-native#readme",
|
|
31
|
+
"bugs": "https://github.com/0xPlayerOne/bun-native/issues",
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public",
|
|
34
|
+
"provenance": true
|
|
35
|
+
}
|
|
36
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { renderer } from './renderer.ts'
|
|
2
|
+
|
|
3
|
+
export { render } from './mount.ts'
|
|
4
|
+
export type { RenderOptions, RenderRoot } from './mount.ts'
|
|
5
|
+
export {
|
|
6
|
+
focusNode,
|
|
7
|
+
inputState,
|
|
8
|
+
registerDropTarget,
|
|
9
|
+
scrollNodeIntoView,
|
|
10
|
+
scrollNodeTo,
|
|
11
|
+
} from '@bun-native/renderer'
|
|
12
|
+
export type { RendererNode as SolidNode } from '@bun-native/renderer'
|
|
13
|
+
export type { JSX } from './jsx.ts'
|
|
14
|
+
|
|
15
|
+
// This is the helper contract emitted by Solid's official universal JSX compiler.
|
|
16
|
+
export const {
|
|
17
|
+
effect,
|
|
18
|
+
memo,
|
|
19
|
+
createComponent,
|
|
20
|
+
createElement,
|
|
21
|
+
createTextNode,
|
|
22
|
+
insertNode,
|
|
23
|
+
insert,
|
|
24
|
+
spread,
|
|
25
|
+
setProp,
|
|
26
|
+
mergeProps,
|
|
27
|
+
use,
|
|
28
|
+
} = renderer
|
|
29
|
+
|
|
30
|
+
export { For, Show, Switch, Match, Index, ErrorBoundary } from 'solid-js'
|
package/src/jsx.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Element as NativeElement, InputState } from '@bun-native/core'
|
|
2
|
+
import type { EventHandlers, RendererNode as SolidNode } from '@bun-native/renderer'
|
|
3
|
+
|
|
4
|
+
export namespace JSX {
|
|
5
|
+
export type Element = SolidNode | string | number | boolean | null | undefined | Element[]
|
|
6
|
+
export interface ElementChildrenAttribute {
|
|
7
|
+
children: unknown
|
|
8
|
+
}
|
|
9
|
+
type Base<Kind extends NativeElement['kind']> = EventHandlers & {
|
|
10
|
+
style?: Extract<NativeElement, { kind: Kind }>['style']
|
|
11
|
+
ref?: (node: SolidNode) => void
|
|
12
|
+
}
|
|
13
|
+
type TextContent = { text?: string; children?: Element }
|
|
14
|
+
export interface IntrinsicElements {
|
|
15
|
+
/**
|
|
16
|
+
* Requires `accessibility_lists_v1` for the accessible members. A list's
|
|
17
|
+
* `accessibleSetSize` counts every item, mounted or not; an item's
|
|
18
|
+
* `accessiblePosition` is its 1-based place in that full set.
|
|
19
|
+
*/
|
|
20
|
+
box: Base<'box'> & { children?: Element } & {
|
|
21
|
+
accessibleRole?: 'list' | 'list_item'
|
|
22
|
+
/** Only with `accessibleRole`. */
|
|
23
|
+
accessibleLabel?: string
|
|
24
|
+
/** Only on a `list`. */
|
|
25
|
+
accessibleSetSize?: number
|
|
26
|
+
/** Only on a `list_item`; 1-based. */
|
|
27
|
+
accessiblePosition?: number
|
|
28
|
+
/** Only on a `list_item`. */
|
|
29
|
+
accessibleSelected?: boolean
|
|
30
|
+
}
|
|
31
|
+
text: Base<'text'> &
|
|
32
|
+
TextContent & {
|
|
33
|
+
/** Requires `accessibility_lists_v1`: announce the text when it appears and changes. */
|
|
34
|
+
accessibleLive?: 'polite' | 'assertive'
|
|
35
|
+
}
|
|
36
|
+
button: Base<'button'> & TextContent & { disabled?: boolean }
|
|
37
|
+
input: Base<'input'> & {
|
|
38
|
+
value?: string | InputState
|
|
39
|
+
placeholder?: string
|
|
40
|
+
/** Requires the host's `input_states_v1` capability. */
|
|
41
|
+
disabled?: boolean
|
|
42
|
+
/** Requires the host's `input_states_v1` capability. */
|
|
43
|
+
readOnly?: boolean
|
|
44
|
+
}
|
|
45
|
+
/** At most two pane children; the host owns the divider drag and keyboard steps. */
|
|
46
|
+
split: Base<'split'> & {
|
|
47
|
+
children?: Element
|
|
48
|
+
ratio?: number
|
|
49
|
+
min_size?: number
|
|
50
|
+
/** Requires `accessibility_v1`: the divider's accessible name. */
|
|
51
|
+
accessibleLabel?: string
|
|
52
|
+
}
|
|
53
|
+
/** Painted above the ordinary tree; only window-anchored overlays may be modal. */
|
|
54
|
+
overlay: Base<'overlay'> & {
|
|
55
|
+
children?: Element
|
|
56
|
+
/** Requires `overlay_keyboard_v1`: focus the first enabled control on open. */
|
|
57
|
+
autofocus?: boolean
|
|
58
|
+
/** Requires `overlay_keyboard_v1`: `menu` adds arrow-key roving focus and type-ahead. */
|
|
59
|
+
navigation?: 'tab' | 'menu'
|
|
60
|
+
/** Requires `accessibility_v1`: the dialog's accessible name. */
|
|
61
|
+
accessibleLabel?: string
|
|
62
|
+
} & (
|
|
63
|
+
| { anchor?: 'window'; modal?: boolean; surface?: 'layer' }
|
|
64
|
+
| { anchor: 'parent'; modal?: false; surface?: 'layer' | 'window' }
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
}
|
package/src/mount.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { NativeStateError, type NativeWindow } from '@bun-native/core'
|
|
2
|
+
import { createRenderRoot, type RenderOptions, type RenderRoot } from '@bun-native/renderer'
|
|
3
|
+
import { createMemo, createRoot, createSignal } from 'solid-js'
|
|
4
|
+
import type { JSX } from './jsx.ts'
|
|
5
|
+
import { renderer } from './renderer.ts'
|
|
6
|
+
|
|
7
|
+
export type { RenderOptions, RenderRoot } from '@bun-native/renderer'
|
|
8
|
+
|
|
9
|
+
function assertReactiveRuntime(): void {
|
|
10
|
+
let observed = -1
|
|
11
|
+
createRoot((dispose) => {
|
|
12
|
+
const [value, set] = createSignal(0)
|
|
13
|
+
const derived = createMemo(value)
|
|
14
|
+
set(1)
|
|
15
|
+
observed = derived()
|
|
16
|
+
dispose()
|
|
17
|
+
})
|
|
18
|
+
if (observed !== 1)
|
|
19
|
+
throw new Error(
|
|
20
|
+
'Solid native rendering requires Bun --conditions=browser (reactive Solid exports)'
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Mount one Solid owner into an independently disposable native container. */
|
|
25
|
+
export function render(
|
|
26
|
+
component: () => JSX.Element,
|
|
27
|
+
window: NativeWindow,
|
|
28
|
+
options: RenderOptions = {}
|
|
29
|
+
): RenderRoot {
|
|
30
|
+
if (typeof component !== 'function')
|
|
31
|
+
throw new NativeStateError('invalid_state', 'Solid render requires a component function')
|
|
32
|
+
assertReactiveRuntime()
|
|
33
|
+
return createRenderRoot(
|
|
34
|
+
window,
|
|
35
|
+
({ container, onCleanup }) => {
|
|
36
|
+
createRoot((dispose) => {
|
|
37
|
+
onCleanup(dispose)
|
|
38
|
+
renderer.insert(container, component())
|
|
39
|
+
})
|
|
40
|
+
},
|
|
41
|
+
options
|
|
42
|
+
)
|
|
43
|
+
}
|
package/src/renderer.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createRenderer } from 'solid-js/universal'
|
|
2
|
+
import {
|
|
3
|
+
asNode,
|
|
4
|
+
createElement,
|
|
5
|
+
createTextNode,
|
|
6
|
+
firstChild,
|
|
7
|
+
insertNode,
|
|
8
|
+
nextSibling,
|
|
9
|
+
removeNode,
|
|
10
|
+
replaceText,
|
|
11
|
+
setProperty,
|
|
12
|
+
type ElementTag,
|
|
13
|
+
type PropertyName,
|
|
14
|
+
type RendererNode,
|
|
15
|
+
} from '@bun-native/renderer'
|
|
16
|
+
|
|
17
|
+
export const renderer = createRenderer<RendererNode>({
|
|
18
|
+
// The compiler hands over JSX tags and names as strings; the renderer rejects
|
|
19
|
+
// any it does not know with an UnsupportedFeatureError.
|
|
20
|
+
createElement: (tag) => createElement(tag as ElementTag),
|
|
21
|
+
createTextNode,
|
|
22
|
+
isTextNode: (node) => asNode(node).kind === 'text-node',
|
|
23
|
+
replaceText: (node, value) => replaceText(asNode(node), value),
|
|
24
|
+
setProperty: (node, name, value) => setProperty(asNode(node), name as PropertyName, value),
|
|
25
|
+
// The official universal JSX compiler uses null to delimit a trailing
|
|
26
|
+
// dynamic region. Both absent forms append; every real anchor stays owned.
|
|
27
|
+
insertNode: (parent, node, anchor) =>
|
|
28
|
+
insertNode(asNode(parent), asNode(node), anchor == null ? undefined : asNode(anchor)),
|
|
29
|
+
removeNode: (parent, node) => removeNode(asNode(parent), asNode(node)),
|
|
30
|
+
getParentNode: (node) => asNode(node).parent,
|
|
31
|
+
getFirstChild: (node) => firstChild(asNode(node)),
|
|
32
|
+
getNextSibling: (node) => nextSibling(asNode(node)),
|
|
33
|
+
})
|