@typstream/universe 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ikram Hasan
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/NOTICE ADDED
@@ -0,0 +1,20 @@
1
+ Third-party notices for @typstream/universe
2
+
3
+ vendor/ holds Typst Universe packages, each tarball exactly as packages.typst.org serves it. They are not part of
4
+ typstream and keep their own licenses: each tarball contains its license file (LICENSE, or LICENSE.txt for
5
+ physica), which applies to that package. The source of each is the tarball itself and the repository named below.
6
+
7
+ * alchemist 0.2.0: MIT, by Robotechnic (https://github.com/Typsium/alchemist)
8
+ * cetz 0.3.4: LGPL-3.0-or-later, by Johannes Wolf, fenjalien (https://github.com/cetz-package/cetz)
9
+ * cetz 0.5.2: LGPL-3.0-or-later, by Johannes Wolf, fenjalien (https://github.com/cetz-package/cetz)
10
+ * cetz 0.5.3: LGPL-3.0-or-later, by Johannes Wolf, fenjalien (https://github.com/cetz-package/cetz)
11
+ * cetz-plot 0.1.4: LGPL-3.0-or-later, by Johannes Wolf, fenjalien (https://github.com/cetz-package/cetz-plot)
12
+ * chemformula 0.1.3: MIT, by pacaunt (https://github.com/pacaunt/chemformula)
13
+ * fletcher 0.5.8: MIT, by Joseph Wilson (Jollywatt) (https://github.com/Jollywatt/typst-fletcher)
14
+ * oxifmt 0.2.1: MIT-0, by PgBiel (https://github.com/PgBiel/typst-oxifmt)
15
+ * oxifmt 1.0.0: MIT OR Apache-2.0, by PgBiel (https://github.com/PgBiel/typst-oxifmt)
16
+ * physica 0.9.8: MIT, by Leedehai (https://github.com/Leedehai/typst-physics)
17
+ * unify 0.8.1: MIT, by Christopher Hecker (https://github.com/ChHecker/unify)
18
+
19
+ cetz and cetz-plot are under the GNU Lesser General Public License, version 3 or later. They are distributed
20
+ here unmodified, in source form (Typst packages are their source).
package/README.md CHANGED
@@ -1,3 +1,49 @@
1
- # Temporary Holding Version
1
+ # @typstream/universe
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
+ The [Typst Universe](https://typst.app/universe) packages typstream allows by default, vendored with their integrity hashes. They cover diagrams, chemistry and math:
4
+
5
+ | For | Package | Import |
6
+ |---|---|---|
7
+ | Diagrams | `@preview/cetz:0.5.3` | `#import "@preview/cetz:0.5.3"` |
8
+ | Diagrams | `@preview/fletcher:0.5.8` | `#import "@preview/fletcher:0.5.8": diagram, node, edge` |
9
+ | Math | `@preview/cetz-plot:0.1.4` | `#import "@preview/cetz-plot:0.1.4": plot` |
10
+ | Math | `@preview/physica:0.9.8` | `#import "@preview/physica:0.9.8": *` |
11
+ | Math | `@preview/unify:0.8.1` | `#import "@preview/unify:0.8.1": num, qty, unit` |
12
+ | Chemistry | `@preview/chemformula:0.1.3` | `#import "@preview/chemformula:0.1.3": ch` |
13
+ | Chemistry | `@preview/alchemist:0.2.0` | `#import "@preview/alchemist:0.2.0": *` |
14
+
15
+ Their dependencies come too, pinned as the packages pin them: cetz 0.5.2 and 0.3.4 and oxifmt 1.0.0 and 0.2.1.
16
+
17
+ ```ts
18
+ import { universe, UNIVERSE_PACKAGES } from "@typstream/universe";
19
+
20
+ // As a plugin: the engine's allowlist (engine.packages) and prompt rules (prompt.rules).
21
+ <Typstream source={text} plugins={[universe]} />;
22
+ // Or engine-wide:
23
+ createEngine({ spawn: engineWorker(), initialize: { packages: [...UNIVERSE_PACKAGES] } });
24
+ ```
25
+
26
+ `typstream`'s `<Typstream>` adds the plugin by default (`packages={false}` turns it off).
27
+
28
+ - **Tarballs.** `vendor/` holds the `.tar.gz` files exactly as packages.typst.org serves them. Each `url` is a `new URL("../vendor/…", import.meta.url)`, which bundlers emit as an asset. The engine fetches one from your origin only when a document imports it, and keeps it in Cache Storage after that.
29
+ - **Integrity.** `integrity` is the SHA-256 of the uncompressed tar, so it holds even when a server sends the `.gz` with `Content-Encoding: gzip` (Vite's dev server does) and the browser hands over the tar.
30
+ - **CeTZ needs Typst's wasm plugins.** It calls its `cetz-core` plugin for geometry, so the engine keeps plugin support.
31
+ - **HTML target.** With `@typstream/html-compat`, CeTZ canvases become inline SVG. fletcher diagrams stay empty in HTML (a known gap, listed in html-compat's README) and render in paged output.
32
+
33
+ ## Licenses
34
+
35
+ The plugin's own code is MIT. The vendored packages keep their licenses: each tarball carries its own, unmodified,
36
+ and `NOTICE` lists every package with its license and authors.
37
+ - **LGPL-3.0-or-later:** cetz and cetz-plot.
38
+ - **MIT:** fletcher, physica, unify, chemformula and alchemist.
39
+ - **oxifmt:** MIT OR Apache-2.0 (1.0.0) and MIT-0 (0.2.1).
40
+
41
+ An app that can't ship LGPL code can leave this plugin out and pass its own allowlist.
42
+
43
+ ## Updating
44
+
45
+ Adding or updating a package:
46
+
47
+ 1. `node scripts/vendor.mjs name:version` downloads it and prints its integrity.
48
+ 2. Add it to `src/index.ts` with its dependencies. The tests list any imported package that is missing.
49
+ 3. `node scripts/vendor.mjs --check` compares every tarball with upstream.
@@ -0,0 +1,49 @@
1
+ import { PackageSpec } from '@typstream/core';
2
+
3
+ /** What a document imports a package for. @public */
4
+ type UniverseTopic = "diagrams" | "math" | "chemistry";
5
+ /**
6
+ * A vendored Typst Universe package: a {@link @typstream/core#PackageSpec} with
7
+ * its tarball's URL and integrity (of the uncompressed tar) always set.
8
+ * @public
9
+ */
10
+ interface UniversePackage extends PackageSpec {
11
+ /** The vendored `.tar.gz`, next to this package's JS: bundlers emit it as an asset. */
12
+ url: string;
13
+ /** `sha256-…` of the uncompressed tar. */
14
+ integrity: string;
15
+ /** Set on the packages documents import; unset on those that only come in as another's dependency. */
16
+ topic?: UniverseTopic;
17
+ /** One line for the prompt: what it's for and how it's called. */
18
+ summary?: string;
19
+ }
20
+ /**
21
+ * Every vendored package, dependencies included. Each `new URL` is a literal so
22
+ * bundlers can see it.
23
+ * @public
24
+ */
25
+ declare const UNIVERSE_PACKAGES: readonly UniversePackage[];
26
+ /**
27
+ * The vendored packages as a typstream plugin: the engine's package allowlist
28
+ * (`engine.packages`) and prompt rules naming what the model may import.
29
+ * `typstream`'s `<Typstream>` adds it by default.
30
+ * @public
31
+ */
32
+ declare const universe: {
33
+ key: string;
34
+ engine: {
35
+ packages: {
36
+ namespace: string;
37
+ name: string;
38
+ version: string;
39
+ url: string;
40
+ integrity: string;
41
+ imports: readonly string[] | undefined;
42
+ }[];
43
+ };
44
+ prompt: {
45
+ rules: string[];
46
+ };
47
+ };
48
+
49
+ export { UNIVERSE_PACKAGES, type UniversePackage, type UniverseTopic, universe };
package/dist/index.js ADDED
@@ -0,0 +1,136 @@
1
+ // src/index.ts
2
+ import { definePlugin } from "@typstream/core";
3
+ var preview = (name, version, url, integrity, imports, use) => ({ namespace: "preview", name, version, url: url.href, integrity, imports, ...use });
4
+ var UNIVERSE_PACKAGES = [
5
+ preview(
6
+ "cetz",
7
+ "0.5.3",
8
+ new URL("../vendor/cetz-0.5.3.tar.gz", import.meta.url),
9
+ "sha256-7uRpaPfYuRjZ0EkPoOM2gkZlOASeDzSguTSJWUx+PVo=",
10
+ ["@preview/oxifmt:1.0.0"],
11
+ {
12
+ topic: "diagrams",
13
+ // #24: models call Typst's `polygon` and `ellipse` in a canvas, where `cetz.draw` shadows them.
14
+ summary: "drawings: `#cetz.canvas({ import cetz.draw: *; line((0, 0), (4, 0), (2, 3), close: true); circle((6, 1), radius: (2, 1)); rect((9, 0), (11, 2)); content((2, -0.5), [4 cm]) })`. In a canvas these replace Typst's shapes: a polygon is `line(.., close: true)`, an ellipse a `circle` with two radii"
15
+ }
16
+ ),
17
+ preview(
18
+ "fletcher",
19
+ "0.5.8",
20
+ new URL("../vendor/fletcher-0.5.8.tar.gz", import.meta.url),
21
+ "sha256-vtCQZc1kBvcTg4tcVXGaNsHxtiqCQEq3JVbegOy5rXw=",
22
+ ["@preview/cetz:0.3.4"],
23
+ {
24
+ topic: "diagrams",
25
+ summary: 'flowcharts, state and commutative diagrams; import `diagram, node, edge`: `#diagram(node((0, 0), [A]), edge("-|>"), node((1, 0), [B]))`'
26
+ }
27
+ ),
28
+ preview(
29
+ "cetz-plot",
30
+ "0.1.4",
31
+ new URL("../vendor/cetz-plot-0.1.4.tar.gz", import.meta.url),
32
+ "sha256-I/KwwAqNhHnJ9ghzhtfoWY6ZYIfOzPMktulXDX2CMc0=",
33
+ ["@preview/cetz:0.5.2"],
34
+ {
35
+ topic: "math",
36
+ summary: "function graphs and charts in a CeTZ canvas; import `plot`: `#cetz.canvas(plot.plot(size: (6, 4), { plot.add(domain: (-2, 2), x => x * x) }))`"
37
+ }
38
+ ),
39
+ preview(
40
+ "physica",
41
+ "0.9.8",
42
+ new URL("../vendor/physica-0.9.8.tar.gz", import.meta.url),
43
+ "sha256-gLyLUm7L9oiszlLGmleQxWZRE4LWGZnWaGgQacVQBQs=",
44
+ [],
45
+ {
46
+ topic: "math",
47
+ summary: "calculus and physics notation in math; import `*`: `$dv(f, x)$`, `$pdv(u, x, y)$`, `$vb(F)$`"
48
+ }
49
+ ),
50
+ preview(
51
+ "unify",
52
+ "0.8.1",
53
+ new URL("../vendor/unify-0.8.1.tar.gz", import.meta.url),
54
+ "sha256-m5t0SW3fByFSrqtdTqvD87gky+/ZphP4wY6a3cVm9T8=",
55
+ [],
56
+ {
57
+ topic: "math",
58
+ summary: 'numbers and SI units; import `num, qty, unit`: `#qty("9.81", "m/s^2")`, `#num("1.2e5")`, `#unit("kg m s^-2")`'
59
+ }
60
+ ),
61
+ preview(
62
+ "chemformula",
63
+ "0.1.3",
64
+ new URL("../vendor/chemformula-0.1.3.tar.gz", import.meta.url),
65
+ "sha256-g9dEimwQXuFvLIk70BB78v5DHwZVqkyI66yIJk/kUMw=",
66
+ [],
67
+ {
68
+ topic: "chemistry",
69
+ summary: 'formulas and equations, mhchem-style; import `ch`: `#ch("2H2 + O2 -> 2H2O")`, `#ch("CuSO4*5H2O")`; arrow labels are math, so quote words: `->["heat"]`'
70
+ }
71
+ ),
72
+ preview(
73
+ "alchemist",
74
+ "0.2.0",
75
+ new URL("../vendor/alchemist-0.2.0.tar.gz", import.meta.url),
76
+ "sha256-wp9SMhMi3ZJtK/nDi5cRrE8xBJQ4NsGhDz+G82kBUMg=",
77
+ ["@preview/cetz:0.5.2"],
78
+ {
79
+ topic: "chemistry",
80
+ summary: 'structural formulas; import `*`: `#skeletize({ fragment("H_3C"); single(); fragment("OH") })`'
81
+ }
82
+ ),
83
+ // Dependencies, pinned exactly by the packages above.
84
+ preview(
85
+ "cetz",
86
+ "0.5.2",
87
+ new URL("../vendor/cetz-0.5.2.tar.gz", import.meta.url),
88
+ "sha256-1HwM5S7MWYfEKdi/jA5hf/er+oCJ5G8OAmJFqTO94NI=",
89
+ ["@preview/oxifmt:1.0.0"]
90
+ ),
91
+ preview(
92
+ "cetz",
93
+ "0.3.4",
94
+ new URL("../vendor/cetz-0.3.4.tar.gz", import.meta.url),
95
+ "sha256-HBkbw1TTedKFYNU/UE0Rxm/XIFvzanWHS37qp12rXK8=",
96
+ ["@preview/oxifmt:0.2.1"]
97
+ ),
98
+ preview(
99
+ "oxifmt",
100
+ "1.0.0",
101
+ new URL("../vendor/oxifmt-1.0.0.tar.gz", import.meta.url),
102
+ "sha256-XS/0bduus8C6ZZTZ999XCbC5z8JILO0EbFryxrztj0o=",
103
+ []
104
+ ),
105
+ preview(
106
+ "oxifmt",
107
+ "0.2.1",
108
+ new URL("../vendor/oxifmt-0.2.1.tar.gz", import.meta.url),
109
+ "sha256-SHrUfkIQznu2YJIMfuGQDBLgkHTQefibSdMwJ/oG78k=",
110
+ []
111
+ )
112
+ ];
113
+ var spec = (p) => `@${p.namespace}/${p.name}:${p.version}`;
114
+ var universe = definePlugin({
115
+ key: "universe",
116
+ engine: {
117
+ packages: UNIVERSE_PACKAGES.map(({ namespace, name, version, url, integrity, imports }) => ({
118
+ namespace,
119
+ name,
120
+ version,
121
+ url,
122
+ integrity,
123
+ imports
124
+ }))
125
+ },
126
+ prompt: {
127
+ rules: [
128
+ "Typst packages: import only these, at exactly these versions. Anything else fails to compile.",
129
+ ...UNIVERSE_PACKAGES.filter((p) => p.topic).map((p) => `\`#import "${spec(p)}"\` (${p.topic}): ${p.summary}`)
130
+ ]
131
+ }
132
+ });
133
+ export {
134
+ UNIVERSE_PACKAGES,
135
+ universe
136
+ };
package/package.json CHANGED
@@ -1,6 +1,49 @@
1
1
  {
2
2
  "name": "@typstream/universe",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "description": "The Typst Universe packages typstream allows by default (CeTZ, fletcher, cetz-plot, physica, unify, chemformula, alchemist), vendored with integrity hashes, as an engine allowlist plugin.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/ikramhasan/typstream.git",
9
+ "directory": "packages/universe"
10
+ },
11
+ "homepage": "https://typstream.vercel.app/docs/reference/universe",
12
+ "bugs": "https://github.com/ikramhasan/typstream/issues",
13
+ "keywords": [
14
+ "typst",
15
+ "typst-packages",
16
+ "cetz"
17
+ ],
18
+ "type": "module",
19
+ "sideEffects": false,
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "default": "./dist/index.js"
24
+ }
25
+ },
26
+ "files": [
27
+ "dist",
28
+ "vendor",
29
+ "NOTICE"
30
+ ],
31
+ "publishConfig": {
32
+ "access": "public",
33
+ "provenance": true
34
+ },
35
+ "dependencies": {
36
+ "@typstream/core": "0.1.1"
37
+ },
38
+ "scripts": {
39
+ "build": "tsup",
40
+ "test": "vitest run --project node",
41
+ "test:paged": "vitest run --project paged",
42
+ "test:docx": "vitest run --project docx",
43
+ "vendor": "node scripts/vendor.mjs",
44
+ "check-types": "tsc -p tsconfig.json",
45
+ "check:api": "api-extractor run",
46
+ "api:update": "api-extractor run --local",
47
+ "check:package": "publint --strict --pack npm && attw --pack . --profile esm-only"
48
+ }
6
49
  }
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file