@jesscss/plugin-js 2.0.0-alpha.1 → 2.0.0-alpha.11

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,6 +1,50 @@
1
1
  # @jesscss/plugin-js
2
2
 
3
- Jess plugin that enables JavaScript/TypeScript module imports.
3
+ **Import bridge for JavaScript/TypeScript modules in stylesheets — a seed of the
4
+ JavaScript-execution / CSS-in-JS story.**
4
5
 
5
- This package checks for a usable Deno runtime before executing non-`@jesscss/fns`
6
- modules. It is intended to be auto-loaded by `jess` when installed.
6
+ This plugin lets a stylesheet pull in JavaScript/TypeScript modules
7
+ (`.js`, `.mjs`, `.cjs`, `.ts`, `.mts`, `.cts`) the mechanism behind `@use` /
8
+ `@-from` script imports and legacy Less `@plugin` loading. When installed, it is
9
+ auto-loaded by `jess`.
10
+
11
+ ## Sandboxed execution
12
+
13
+ `plugin-js` does **not** run untrusted module code in your Node process. Before
14
+ executing anything, it checks for a usable **Deno** runtime (`deno --version`)
15
+ and runs the module in a Deno subprocess behind a permission broker:
16
+
17
+ - **read** is limited to `node_modules` (and an optional `jsReadRoot`),
18
+ - **net** is denied unless you opt in (`allowHttp`, optionally scoped to
19
+ `allowNetHosts`),
20
+ - **env / write / run / ffi / sys** are denied outright.
21
+
22
+ Values cross the boundary through a small typed bridge (dimensions, colors,
23
+ quoted strings, lists, detached rules, …). Built-in `@jesscss/fns` modules are
24
+ trusted and imported directly, without the worker. If no Deno binary is found,
25
+ the plugin fails with a clear message instead of falling back to unsandboxed
26
+ execution.
27
+
28
+ ## Why it exists — the convergence angle
29
+
30
+ One of the four tools [Jess](https://github.com/jesscss/jess) aims to converge is
31
+ **CSS-in-JS**: running real JavaScript inside stylesheets so styles can be
32
+ dynamic without leaving CSS files. This plugin — together with
33
+ [`@jesscss/plugin-node-modules`](../jess-plugin-node-modules), which resolves the
34
+ packages — is a seed of that story.
35
+
36
+ That convergence is **roadmap — being proven through the alpha, not claimed as
37
+ done.** Legacy Less `@plugin` is supported for compatibility but deprecated in
38
+ favor of `@-from` / `@-use`.
39
+
40
+ ## Status
41
+
42
+ **Alpha.** Part of Jess. Requires a Deno runtime for script execution. The
43
+ programmatic plugin/compiler API is **not yet stabilized** — the `jess` CLI is
44
+ the documented public surface for the alpha. Watch the
45
+ [docs site](https://jesscss.github.io/) for the API once it settles.
46
+
47
+ - Project overview & positioning: <https://github.com/jesscss/jess#readme>
48
+ - Docs: <https://jesscss.github.io/> (currently pre-alpha content)
49
+ - Issues: <https://github.com/jesscss/jess/issues>
50
+ - License: MIT
@@ -0,0 +1,46 @@
1
+ export type JsBridgeDeclaration = {
2
+ name: string;
3
+ value: JsBridgeValue;
4
+ };
5
+ export type JsBridgeValue = {
6
+ __jessBridge: true;
7
+ kind: 'scalar';
8
+ value: string | number | boolean;
9
+ } | {
10
+ __jessBridge: true;
11
+ kind: 'dimension';
12
+ value: number;
13
+ unit?: string;
14
+ } | {
15
+ __jessBridge: true;
16
+ kind: 'color';
17
+ rgb: [number, number, number];
18
+ alpha?: number;
19
+ } | {
20
+ __jessBridge: true;
21
+ kind: 'quoted';
22
+ value: string;
23
+ quote?: '"' | '\'';
24
+ escaped?: boolean;
25
+ } | {
26
+ __jessBridge: true;
27
+ kind: 'anonymous';
28
+ value: string;
29
+ } | {
30
+ __jessBridge: true;
31
+ kind: 'list';
32
+ items: JsBridgeValue[];
33
+ separator: ',' | '/' | ';';
34
+ } | {
35
+ __jessBridge: true;
36
+ kind: 'expression';
37
+ items: JsBridgeValue[];
38
+ } | {
39
+ __jessBridge: true;
40
+ kind: 'mixin';
41
+ rules: JsBridgeDeclaration[];
42
+ };
43
+ export declare function encodeBridgeValue(value: unknown): unknown;
44
+ export declare function decodeBridgeValue(value: unknown): unknown;
45
+ export declare function encodeBridgeArgs(args: readonly unknown[]): unknown[];
46
+ //# sourceMappingURL=bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.d.ts","sour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