browser-runtime-solid 0.0.0-stage → 0.0.1

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/README.md CHANGED
@@ -1,3 +1,32 @@
1
- # Temporary Holding Version
1
+ # browser-runtime-solid
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Optional Solid JSX compiler and renderer plugin for [`browser-module-runtime`](https://www.npmjs.com/package/browser-module-runtime).
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm install browser-module-runtime@0.0.1 browser-runtime-solid@0.0.1 solid-tag@0.0.3
9
+ ```
10
+
11
+ Solid rendering also needs the Solid DOM runtime available through your host's import map or runtime module configuration.
12
+
13
+ ## Usage
14
+
15
+ ```js
16
+ import {createRuntime} from 'browser-module-runtime';
17
+ import {solid} from 'browser-runtime-solid';
18
+
19
+ const runtime = createRuntime({plugins: [solid()]});
20
+ runtime.define('/Counter.jsx', `
21
+ import {createSignal} from 'solid-js';
22
+ export default function Counter() {
23
+ const [count,setCount] = createSignal(0);
24
+ return <button onClick={() => setCount(n => n + 1)}>Count: {count()}</button>;
25
+ }
26
+ `, {type:'solid-jsx'});
27
+
28
+ const handle = await runtime.mount({module:'/Counter.jsx', target:'#app'});
29
+ // Later: await handle.dispose(); await runtime.dispose();
30
+ ```
31
+
32
+ This plugin lazily compiles JSX through `solid-tag` and mounts via `@solidjs/web.render`. It handles `type="solid-jsx"`; coherent Solid module identity is the application's responsibility. It is not an alias of `solid-tag-runtime` and does not replace that package's specialized HTML/delegation APIs.
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import type {RuntimePlugin} from 'browser-module-runtime';
2
+ export declare function solid(options?:Record<string,unknown>):RuntimePlugin;
package/package.json CHANGED
@@ -1,6 +1,45 @@
1
1
  {
2
2
  "name": "browser-runtime-solid",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": {
7
+ "types": "./index.d.ts",
8
+ "import": "./src/index.js"
9
+ }
10
+ },
11
+ "files": [
12
+ "src",
13
+ "index.d.ts",
14
+ "README.md"
15
+ ],
16
+ "peerDependenciesMeta": {
17
+ "solid-tag": {
18
+ "optional": true
19
+ },
20
+ "@solidjs/web": {
21
+ "optional": true
22
+ }
23
+ },
24
+ "engines": {
25
+ "node": ">=20"
26
+ },
27
+ "peerDependencies": {
28
+ "browser-module-runtime": "0.0.1",
29
+ "solid-tag": "0.0.3",
30
+ "@solidjs/web": "*"
31
+ },
32
+ "description": "Solid JSX compiler and renderer adapter for browser-module-runtime.",
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "keywords": [
37
+ "browser",
38
+ "esm",
39
+ "runtime",
40
+ "modules",
41
+ "compiler",
42
+ "adapter",
43
+ "solid"
44
+ ]
45
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from '../index.js';
package/src/index.js ADDED
@@ -0,0 +1,27 @@
1
+ /** Solid is optional. The generic core never imports or loads Solid. */
2
+ export function solid({compiler,render,modules={},version='0.0.3',transformOptions={}}={}) {
3
+ let transformer=compiler;
4
+ let renderFunction=render;
5
+ return {
6
+ name:'solid',version:String(version),
7
+ async configure({runtime}) {for(const [id,ns] of Object.entries(modules))runtime.defineModule(id,ns);},
8
+ compilers:[{
9
+ types:['solid-jsx'],extensions:['.jsx'],
10
+ async compile(source,{id}) {
11
+ transformer ||= await import('solid-tag');
12
+ if (typeof transformer.compile==='function')return transformer.compile(source,{id});
13
+ if(typeof transformer.transformModule!=='function')throw new TypeError('solid-tag transformer requires transformModule()');
14
+ const result=await transformer.transformModule(source,{...transformOptions,injectHtmlImport:true,htmlImportSource:'@solidjs/html'});
15
+ return {code:result.code,diagnostics:result.diagnostics||[],map:result.sourceMap};
16
+ }
17
+ }],
18
+ renderers:[{
19
+ name:'solid',types:['solid-jsx'],
20
+ async mount({component,target,props}) {
21
+ renderFunction ||= (await import('@solidjs/web')).render;
22
+ const dispose=renderFunction(()=>component(props),target);
23
+ return {dispose};
24
+ }
25
+ }]
26
+ };
27
+ }