@backtickjs/jsx-solid 0.3.2 → 0.5.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.
@@ -1,10 +1,10 @@
1
- import { type Client, type JsxElementOf, type JsxElementTypeOf } from "@backtickjs/core";
1
+ import { type Client, type JsxElementOf, type ServerComponent } from "@backtickjs/core";
2
2
  import type { JSX as Solid } from "solid-js";
3
3
  export declare namespace JSX {
4
4
  type FunctionMaybe<T = unknown> = Solid.FunctionMaybe<T>;
5
5
  type FunctionElement = Solid.FunctionElement;
6
6
  type Element = JsxElementOf<Solid.Element>;
7
- type ElementType = JsxElementTypeOf<Solid.Element>;
7
+ type ElementType = string | ((props: never) => Solid.Element) | ServerComponent<Solid.Element | (() => Solid.Element)>;
8
8
  type ArrayElement = Solid.ArrayElement;
9
9
  type ElementClass = Solid.ElementClass;
10
10
  type ElementAttributesProperty = Solid.ElementAttributesProperty;
@@ -1,12 +1,13 @@
1
1
  import { createJsxElement, cs, } from "@backtickjs/core";
2
- const createComponent = { "@backtickjs": "ClientImport", name: "createComponent", from: "solid-js", version: "1.9.14" };
2
+ const untrack = { "@backtickjs": "ClientImport", name: "untrack", from: "solid-js", version: "1.9.14" };
3
3
  const $module0 = {
4
- id: "25mdzlh7035ld:352:9",
5
- code: "(module, exports, require) => {\n\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.default = (($splice0, $splice1) => $splice0()(() => $splice1(), {}));\n}",
6
- map: "{\"version\":3,\"file\":\"module.jsx\",\"mappings\":\";;;mBA+VY,kCAAgB,CAAC,GAAG,EAAE,CAAC,UAAQ,EAAE,EAAE,CAAC\",\"names\":[],\"ignoreList\":[],\"sources\":[\"@backtickjs/jsx-solid/src/jsx-runtime.ts\"]}",
4
+ id: "o9e7zz7zzcul:356:9",
5
+ code: "(module, exports, require) => {\n\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.default = (($splice0, $splice1) => $splice0()(() => $splice1()));\n}",
6
+ map: "{\"version\":3,\"file\":\"module.jsx\",\"mappings\":\";;;mBAmWY,kCAAQ,CAAC,GAAG,EAAE,CAAC,UAAQ,CAAC\",\"names\":[],\"ignoreList\":[],\"sources\":[\"@backtickjs/jsx-solid/src/jsx-runtime.ts\"]}",
7
7
  dependencies: [],
8
8
  params: [{ kind: "splice", bindings: [] }, { kind: "splice", bindings: [] }],
9
- kind: "expression"
9
+ kind: "expression",
10
+ scope: "function"
10
11
  };
11
12
  /**
12
13
  * `<>` and `<Fragment>`, as `solid-js/h/jsx-runtime` types it. Always an
@@ -17,13 +18,14 @@ export function Fragment(props) {
17
18
  // The bundler writes the array as it is: a Solid array element.
18
19
  return [props.children];
19
20
  }
20
- // A component, run on the client as Solid runs one, through `createComponent`:
21
- // untracked, so what it reads while it sets up doesn't build it again where it
22
- // stands.
21
+ // A server component's element: what it answers, read untracked, as Solid runs
22
+ // a component, so what it reads while it sets up doesn't build it again where
23
+ // it stands. `untrack` rather than `createComponent`, which would make a
24
+ // computation where the answer is made at load, outside every root.
23
25
  export function jsx(type, props) {
24
26
  // Core's element, as this package types it: a stand-in for a Solid element.
25
27
  const element = createJsxElement(type, props);
26
- return cs.create($module0, [createComponent, element]);
28
+ return cs.create($module0, [untrack, element]);
27
29
  }
28
30
  export const jsxs = jsx;
29
31
  // What a development build of the JSX transform calls, as Bun does.
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-runtime.js","sourceRoot":"","sources":["../src/jsx-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,EAAE,GAIH,MAAM,kBAAkB,CAAC;;;;;;;;;;AAsU1B;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,KAA6B;IACpD,gEAAgE;IAChE,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAqC,CAAC;AAC9D,CAAC;AAED,+EAA+E;AAC/E,+EAA+E;AAC/E,UAAU;AACV,MAAM,UAAU,GAAG,CACjB,IAAqB,EACrB,KAAc;IAEd,4EAA4E;IAC5E,MAAM,OAAO,GAAG,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAA0B,CAAC;IACvE,uDAAgD;AAClD,CAAC;AAED,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,CAAC;AACxB,oEAAoE;AACpE,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAC"}
1
+ {"version":3,"file":"jsx-runtime.js","sourceRoot":"","sources":["../src/jsx-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,EAAE,GAIH,MAAM,kBAAkB,CAAC;;;;;;;;;;;AAyU1B;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,KAA6B;IACpD,gEAAgE;IAChE,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAqC,CAAC;AAC9D,CAAC;AAED,+EAA+E;AAC/E,8EAA8E;AAC9E,yEAAyE;AACzE,oEAAoE;AACpE,MAAM,UAAU,GAAG,CACjB,IAAqB,EACrB,KAAc;IAEd,4EAA4E;IAC5E,MAAM,OAAO,GAAG,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAA0B,CAAC;IACvE,+CAAoC;AACtC,CAAC;AAED,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,CAAC;AACxB,oEAAoE;AACpE,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backtickjs/jsx-solid",
3
- "version": "0.3.2",
3
+ "version": "0.5.0",
4
4
  "description": "Solid's JSX for Backtick: a JSX runtime for server components, and the compile plugin for scripts",
5
5
  "keywords": [
6
6
  "backtick",
@@ -47,16 +47,16 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@babel/core": "^7.29.7",
50
- "@backtickjs/core": "0.3.2",
50
+ "@backtickjs/core": "0.5.0",
51
51
  "babel-preset-solid": "1.9.12"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "solid-js": "^1.9.14"
55
55
  },
56
56
  "devDependencies": {
57
- "@backtickjs/prettier-plugin": "0.3.2",
58
- "@backtickjs/tsc": "0.3.2",
59
- "@backtickjs/tspatch-plugin": "0.3.2",
57
+ "@backtickjs/prettier-plugin": "0.5.0",
58
+ "@backtickjs/tsc": "0.5.0",
59
+ "@backtickjs/tspatch-plugin": "0.5.0",
60
60
  "@types/babel__core": "^7.20.5",
61
61
  "prettier": "^3.6.2",
62
62
  "solid-js": "1.9.14",
@@ -3,16 +3,19 @@ import {
3
3
  cs,
4
4
  type Client,
5
5
  type JsxElementOf,
6
- type JsxElementTypeOf,
6
+ type ServerComponent,
7
7
  } from "@backtickjs/core";
8
8
  import type { JSX as Solid } from "solid-js";
9
- import { createComponent } from "solid-js" with { backtick: "client" };
9
+ import { untrack } from "solid-js" with { backtick: "client" };
10
10
 
11
11
  export declare namespace JSX {
12
12
  export type FunctionMaybe<T = unknown> = Solid.FunctionMaybe<T>;
13
13
  export type FunctionElement = Solid.FunctionElement;
14
14
  export type Element = JsxElementOf<Solid.Element>;
15
- export type ElementType = JsxElementTypeOf<Solid.Element>;
15
+ export type ElementType =
16
+ | string
17
+ | ((props: never) => Solid.Element)
18
+ | ServerComponent<Solid.Element | (() => Solid.Element)>;
16
19
  export type ArrayElement = Solid.ArrayElement;
17
20
  export type ElementClass = Solid.ElementClass;
18
21
  export type ElementAttributesProperty = Solid.ElementAttributesProperty;
@@ -340,16 +343,17 @@ export function Fragment(props: { children?: unknown }): Client<Solid.Element> {
340
343
  return [props.children] as unknown as Client<Solid.Element>;
341
344
  }
342
345
 
343
- // A component, run on the client as Solid runs one, through `createComponent`:
344
- // untracked, so what it reads while it sets up doesn't build it again where it
345
- // stands.
346
+ // A server component's element: what it answers, read untracked, as Solid runs
347
+ // a component, so what it reads while it sets up doesn't build it again where
348
+ // it stands. `untrack` rather than `createComponent`, which would make a
349
+ // computation where the answer is made at load, outside every root.
346
350
  export function jsx(
347
351
  type: JSX.ElementType,
348
352
  props: unknown,
349
353
  ): Client<Solid.Element> {
350
354
  // Core's element, as this package types it: a stand-in for a Solid element.
351
355
  const element = createJsxElement(type, props) as Client<Solid.Element>;
352
- return cs`$createComponent(() => $element, {})`;
356
+ return cs`$untrack(() => $element)`;
353
357
  }
354
358
 
355
359
  export const jsxs = jsx;