mono-jsx 0.1.3 → 0.3.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/package.json CHANGED
@@ -1,29 +1,33 @@
1
1
  {
2
2
  "name": "mono-jsx",
3
- "version": "0.1.3",
3
+ "version": "0.3.0",
4
4
  "description": "`<html>` as a `Response`.",
5
5
  "type": "module",
6
6
  "module": "./index.mjs",
7
+ "types": "./types/index.d.ts",
7
8
  "bin": {
8
9
  "mono-jsx": "./bin/mono-jsx"
9
10
  },
10
11
  "exports": {
11
12
  ".": {
13
+ "types": "./types/index.d.ts",
14
+ "node": "./index.mjs",
12
15
  "import": "./index.mjs"
13
16
  },
14
17
  "./jsx-runtime": {
15
18
  "types": "./types/jsx-runtime.d.ts",
16
- "import": "./jsx-runtime.mjs",
17
- "node": "./jsx-runtime.mjs"
19
+ "node": "./jsx-runtime.mjs",
20
+ "import": "./jsx-runtime.mjs"
18
21
  },
19
22
  "./jsx-dev-runtime": {
20
23
  "types": "./types/jsx-runtime.d.ts",
21
- "import": "./jsx-runtime.mjs",
22
- "node": "./jsx-runtime.mjs"
24
+ "node": "./jsx-runtime.mjs",
25
+ "import": "./jsx-runtime.mjs"
23
26
  }
24
27
  },
25
28
  "scripts": {
26
- "prepublishOnly": "deno task build"
29
+ "prepublishOnly": "deno task build",
30
+ "postinstall": "node setup.mjs"
27
31
  },
28
32
  "files": [
29
33
  "*.mjs",
package/setup.mjs ADDED
@@ -0,0 +1,58 @@
1
+ // setup.ts
2
+ import { existsSync } from "node:fs";
3
+ import { readFile, writeFile } from "node:fs/promises";
4
+ import { fileURLToPath } from "node:url";
5
+ import { argv } from "node:process";
6
+ async function setup() {
7
+ if (globalThis.Deno && existsSync("deno.jsonc")) {
8
+ console.log("Please add the following options to your deno.jsonc file:");
9
+ console.log(
10
+ [
11
+ `{`,
12
+ ` "compilerOptions": {`,
13
+ ` %c"jsx": "react-jsx",`,
14
+ ` "jsxImportSource": "mono-jsx",%c`,
15
+ ` }`,
16
+ `}`
17
+ ].join("\n"),
18
+ "color:green",
19
+ ""
20
+ );
21
+ return;
22
+ }
23
+ let tsConfigFilename = globalThis.Deno ? "deno.json" : "tsconfig.json";
24
+ let tsConfig = /* @__PURE__ */ Object.create(null);
25
+ try {
26
+ const data = await readFile(tsConfigFilename, "utf8");
27
+ tsConfig = JSON.parse(data);
28
+ } catch {
29
+ }
30
+ const compilerOptions = tsConfig.compilerOptions ?? (tsConfig.compilerOptions = {});
31
+ if (compilerOptions.jsx === "react-jsx" && compilerOptions.jsxImportSource === "mono-jsx") {
32
+ console.log("%cmono-jsx already setup.", "color:grey");
33
+ return;
34
+ }
35
+ if (!globalThis.Deno) {
36
+ compilerOptions.module ??= "es2022";
37
+ compilerOptions.moduleResolution ??= "bundler";
38
+ }
39
+ compilerOptions.jsx = "react-jsx";
40
+ compilerOptions.jsxImportSource = "mono-jsx";
41
+ await writeFile(tsConfigFilename, JSON.stringify(tsConfig, null, 2));
42
+ console.log("\u2705 mono-jsx setup complete.");
43
+ }
44
+ function isMain() {
45
+ if (import.meta.main) {
46
+ return true;
47
+ }
48
+ if (import.meta.url.startsWith("file:")) {
49
+ return argv[1] === fileURLToPath(import.meta.url);
50
+ }
51
+ return false;
52
+ }
53
+ if (isMain()) {
54
+ setup();
55
+ }
56
+ export {
57
+ setup
58
+ };
package/types/css.d.ts CHANGED
@@ -6671,7 +6671,7 @@ export interface VendorLonghandProperties<TLength = (string & {}) | 0, TTime = s
6671
6671
  */
6672
6672
  msHyphens?: Property.Hyphens | undefined;
6673
6673
  /**
6674
- * The **`-ms-ime-align`** CSS property is a Microsoft extension aligning the Input Method Editor (IME) candidate window box relative to the element on which the IME composition is active. The extension is implemented in Microsoft Edge and Internet Explorer 11.
6674
+ * The **`-ms-ime-align`** CSS property is a Microsoft extension aligning the Input Method Editor (IME) candidate window box relative to the element on which the IME composition is active. The extension is implemented in Microsoft Edge and Internet Explorer 11.
6675
6675
  *
6676
6676
  * **Syntax**: `auto | after`
6677
6677
  *
package/types/html.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  /// <reference lib="dom" />
2
+ /// <reference path="./htmx.d.ts" />
2
3
 
3
4
  import type * as Aria from "./aria.d.ts";
4
5
  import type * as Mono from "./mono.d.ts";
@@ -42,7 +43,7 @@ export namespace HTML {
42
43
  | "week";
43
44
 
44
45
  /** Global HTML attributes from https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes */
45
- interface GlobalAttributes<T extends EventTarget> extends EventAttributes<T>, Aria.Attributes, Mono.BaseAttributes {
46
+ interface GlobalAttributes<T extends EventTarget> extends EventAttributes<T>, Aria.Attributes, Mono.BaseAttributes, JSX.HtmlTag {
46
47
  /** Defines a unique identifier (ID) which must be unique in the whole document. Its purpose is to identify the element when linking (using a fragment identifier), scripting, or styling (with CSS). */
47
48
  id?: string;
48
49
  /** A space-separated list of the classes of the element. Classes allow CSS and JavaScript to select and access specific elements via the [class selectors](https://developer.mozilla.org/en-US/docs/Web/CSS/Class_selectors) or functions like the method [`Document.getElementsByClassName()`](https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName). */
@@ -135,7 +136,7 @@ export namespace HTML {
135
136
 
136
137
  interface FormAttributes<T extends EventTarget> extends GlobalAttributes<T> {
137
138
  "accept-charset"?: string;
138
- action: string | (/* mono-jsx specific */ (data: FormData, event: SubmitEvent) => void | Promise<void>);
139
+ action: string | (/* mono-jsx specific */ (data: FormData, event: SubmitEvent) => unknown | Promise<unknown>);
139
140
  autoComplete?: "on" | "off";
140
141
  encType?: "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain";
141
142
  method?: "GET" | "POST" | "dialog";