@jxsuite/content-mapper 0.0.0-stage → 0.1.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Avunu LLC and Jx Suite 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 CHANGED
@@ -1,3 +1,75 @@
1
- # Temporary Holding Version
1
+ # @jxsuite/content-mapper
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
+ A TypeScript content mapper for [Jx Notation](https://jxsuite.com/docs/framework/concepts/jxn-files). It lets `tsc` and TypeScript's language server check the code inside a `.jxn` document: its script, the body of each function, each `${}` template, each `$ref` into `state` and each prop it gives a component. Errors are printed at the line and column where you wrote them, and an editor's hover, completion and rename land on your own text.
4
+
5
+ Content mappers arrive in TypeScript 7.1, which is a beta today.
6
+
7
+ ## Use
8
+
9
+ ```sh
10
+ bun add -d typescript@7.1.0-beta @jxsuite/content-mapper
11
+ ```
12
+
13
+ Add a `tsconfig.jxn.json` beside your project file:
14
+
15
+ ```json
16
+ {
17
+ "compilerOptions": {
18
+ "noEmit": true,
19
+ "strict": true,
20
+ "module": "esnext",
21
+ "moduleResolution": "bundler"
22
+ },
23
+ "contentMappers": [{ "extensions": [".jxn"], "package": "@jxsuite/content-mapper" }],
24
+ "include": ["pages", "layouts", "components", "src"]
25
+ }
26
+ ```
27
+
28
+ Then run the compiler over it:
29
+
30
+ ```sh
31
+ tsc -p tsconfig.jxn.json --runExternalCode
32
+ ```
33
+
34
+ ```text
35
+ pages/counter.jxn(15,24): error TS2339: Property 'total' does not exist on type 'State'.
36
+ ```
37
+
38
+ TypeScript starts the mapper with `node`, so Node 22.18 or newer has to be on your path.
39
+
40
+ ## What `--runExternalCode` permits
41
+
42
+ The flag is not given to one mapper. It lets `tsc` start every content mapper the `tsconfig` names that has a file to read, each as a program with your own access to the machine. Keep the mapper in a `tsconfig` of its own, as above, so the flag covers one short file. Without the flag `tsc` starts nothing and prints `TS18068`.
43
+
44
+ A language server runs a mapper only when the editor tells it the project may run external code. Until then a `.jxn` file gets no errors and no hover.
45
+
46
+ A language server looks for `tsconfig.json`, so it reads `tsconfig.jxn.json` only where the editor names that file. In VS Code that is the TypeScript extension's `js/ts.customConfigFileName` setting.
47
+
48
+ ## What is checked
49
+
50
+ - A document's client script and server script.
51
+ - Every string `body`: a function in `state`, an event handler, at the root or in a nested section.
52
+ - `State`, the type of the document's `state`, which a script names without importing and a `.ts` file can import from the document.
53
+ - The event each handler is given, typed by its binding and its element, and `state.$map`, the row of a repeated element.
54
+ - Every `${}` template an element or a `state` entry holds, checked as the JavaScript the page runs.
55
+ - Every `$ref` into `state` or a row, name by name. One on an `on` member is checked as the handler it binds.
56
+ - Every prop in an instance's `$props`, against the `state` of the `.jxn` component its tag names: one the document lists in `$elements`, or one in the project's `components` folder.
57
+
58
+ A state entry that declares a `type` is checked as that type, and a document's `$defs` are types its entries name: `#/$defs/TodoItem` is `$defs.TodoItem`, in an error and in a module that imports the document. A `.json` document, a `$defs` entry of another file and a class's methods are not read. The [Type checking](https://jxsuite.com/docs/framework/concepts/type-checking) page has the full account, with the limits of rename.
59
+
60
+ ## As a library
61
+
62
+ The package's one export is the mapper's definition, for a host that wants to run it itself:
63
+
64
+ ```ts
65
+ import { createMapper } from "@jxsuite/content-mapper";
66
+ import { runContentMapper } from "ts-content-mapper";
67
+
68
+ runContentMapper(createMapper());
69
+ ```
70
+
71
+ What a document's types are is not decided here. `@jxsuite/schema/virtual-document` writes the modules, and this package hands them to the compiler in the form its protocol takes.
72
+
73
+ ## Versioning
74
+
75
+ The package follows the monorepo's release train and depends on `@jxsuite/schema`. TypeScript is a peer dependency, `>=7.1.0-beta`.
package/bin/server.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import { run } from "../dist/server.js";
3
+
4
+ run();