@ai-matrx/code-runtime 0.1.4
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/CHANGELOG.md +50 -0
- package/LICENSE +21 -0
- package/README.md +31 -0
- package/dist/execute.cjs +890 -0
- package/dist/execute.cjs.map +1 -0
- package/dist/execute.d.cts +11 -0
- package/dist/execute.d.ts +11 -0
- package/dist/execute.js +858 -0
- package/dist/execute.js.map +1 -0
- package/dist/gate-lists.json +105 -0
- package/dist/gate.cjs +291 -0
- package/dist/gate.cjs.map +1 -0
- package/dist/gate.d.cts +49 -0
- package/dist/gate.d.ts +49 -0
- package/dist/gate.js +268 -0
- package/dist/gate.js.map +1 -0
- package/dist/index.cjs +1196 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +87 -0
- package/dist/index.d.ts +87 -0
- package/dist/index.js +1164 -0
- package/dist/index.js.map +1 -0
- package/dist/scope-lrQkC0jP.d.cts +205 -0
- package/dist/scope-lrQkC0jP.d.ts +205 -0
- package/dist/scope.cjs +597 -0
- package/dist/scope.cjs.map +1 -0
- package/dist/scope.d.cts +2 -0
- package/dist/scope.d.ts +2 -0
- package/dist/scope.js +565 -0
- package/dist/scope.js.map +1 -0
- package/dist/transform.cjs +140 -0
- package/dist/transform.cjs.map +1 -0
- package/dist/transform.d.cts +12 -0
- package/dist/transform.d.ts +12 -0
- package/dist/transform.js +117 -0
- package/dist/transform.js.map +1 -0
- package/dist/types-DL6oTcV_.d.cts +50 -0
- package/dist/types-DL6oTcV_.d.ts +50 -0
- package/package.json +137 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Changelog — @ai-matrx/code-runtime
|
|
2
|
+
|
|
3
|
+
## 0.1.4
|
|
4
|
+
|
|
5
|
+
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
6
|
+
`git diff npm/code-runtime/vnull..npm/code-runtime/v0.1.4 -- apps/shared/code-runtime`).
|
|
7
|
+
No source changes intended and no consumer action required.
|
|
8
|
+
|
|
9
|
+
## 0.1.3
|
|
10
|
+
|
|
11
|
+
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
12
|
+
`git diff npm/code-runtime/vnull..npm/code-runtime/v0.1.3 -- apps/shared/code-runtime`).
|
|
13
|
+
No source changes intended and no consumer action required.
|
|
14
|
+
|
|
15
|
+
## 0.1.2
|
|
16
|
+
|
|
17
|
+
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
18
|
+
`git diff npm/code-runtime/vnull..npm/code-runtime/v0.1.2 -- apps/shared/code-runtime`).
|
|
19
|
+
No source changes intended and no consumer action required.
|
|
20
|
+
|
|
21
|
+
## 0.1.1
|
|
22
|
+
|
|
23
|
+
Automatic changed-only republish (docs/metadata drift since the last tag — see
|
|
24
|
+
`git diff npm/code-runtime/vnull..npm/code-runtime/v0.1.1 -- apps/shared/code-runtime`).
|
|
25
|
+
No source changes intended and no consumer action required.
|
|
26
|
+
|
|
27
|
+
## 0.1.0 — 2026-10-06
|
|
28
|
+
|
|
29
|
+
First release (Applets AP-5, CONTRACTS §7). Absorbs matrx-frontend's six in-browser compile
|
|
30
|
+
paths, its two scope registries and the source gate.
|
|
31
|
+
|
|
32
|
+
- `compile(files, entry, scope)`: multi-file TSX with relative imports (CommonJS linking,
|
|
33
|
+
non-strict to match stored bodies), default export or last top-level PascalCase binding.
|
|
34
|
+
- `/transform` (Babel, pure) and `/execute` (no Babel) for the sandbox frame's split.
|
|
35
|
+
- ONE scope registry (`listScopeEntries()`); package-owned modules for react, lucide-react,
|
|
36
|
+
`@ai-matrx/icons`, `@ai-matrx/design-system` (+ `/controls`), `@/lib/utils`, the legacy
|
|
37
|
+
`@/components/ui/*` aliases and recharts; host-owned entries via `provideScopeModules`.
|
|
38
|
+
- Named stand-ins + the unresolved list on every result + `onUnresolved(origin, list)`.
|
|
39
|
+
- `gate(files) → Finding[]` with file and line; `gate-lists.json` exported.
|
|
40
|
+
- `createCompileCache()` per (id, version); `kindComponentCompiler()` for content-ir-react's port.
|
|
41
|
+
|
|
42
|
+
### Consumer action
|
|
43
|
+
|
|
44
|
+
- matrx-frontend: provide host modules once at boot of the compile chunk
|
|
45
|
+
(`provideScopeModules({...})` for MarkdownStream + aliases, kind-kit, CopyButtons,
|
|
46
|
+
CopyForAiButton, `@/applets`, `@/components/ui/*`, and the heavy libraries), replace every
|
|
47
|
+
call of `compileSlotComponent`, `compileReactComponent`, `transformKindComponentBody` /
|
|
48
|
+
`executeKindBody` and `componentSourceGate` with this package, and delete the originals.
|
|
49
|
+
|
|
50
|
+
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AI Matrix Engine
|
|
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
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @ai-matrx/code-runtime
|
|
2
|
+
|
|
3
|
+
Compile stored TSX — one file or many — into a React component, against one documented import
|
|
4
|
+
scope, with a visible, reported stand-in for anything the scope cannot supply.
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
import { compile, gate } from "@ai-matrx/code-runtime";
|
|
8
|
+
|
|
9
|
+
const files = {
|
|
10
|
+
"App.tsx": `import { Form } from "./Form"; export default () => <Form />;`,
|
|
11
|
+
"Form.tsx": `import { Button } from "@ai-matrx/design-system/controls";
|
|
12
|
+
export const Form = () => <Button>Save</Button>;`,
|
|
13
|
+
};
|
|
14
|
+
if (gate(files).some((f) => f.severity === "refuse")) throw new Error("refused");
|
|
15
|
+
const r = compile(files, "App.tsx", { entries: ["react", "@ai-matrx/design-system/controls"], shadowDangerousGlobals: true });
|
|
16
|
+
if (r.ok) render(<r.Component />); else show(r.error.message);
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
- **Scope**: `listScopeEntries()` is the whole registry. Package-owned entries work anywhere
|
|
20
|
+
(Next.js, Vite). Host-owned ones (Markdown, kind-kit, copy buttons, Applet parts, heavy
|
|
21
|
+
libraries) are supplied once: `provideScopeModules({ "@/components/MarkdownStream": () => mod })`.
|
|
22
|
+
Async entries (recharts) need `await prepareScope(spec)` or `compileAsync`.
|
|
23
|
+
- **Sandbox split**: the parent runs `@ai-matrx/code-runtime/transform` (`transformFiles`) and
|
|
24
|
+
posts the JSON graph; the frame runs `@ai-matrx/code-runtime/execute` (`executeGraph`), no Babel.
|
|
25
|
+
- **Gate**: `@ai-matrx/code-runtime/gate` is pure (servers, write paths). The lists ship as
|
|
26
|
+
`@ai-matrx/code-runtime/gate-lists.json`.
|
|
27
|
+
- **Kinds**: inject `kindComponentCompiler()` into `@ai-matrx/content-ir-react`'s
|
|
28
|
+
`createDbKindComponentCache({ compile })`.
|
|
29
|
+
|
|
30
|
+
Not a security boundary: the dangerous-global stubs shadow bare identifiers only. Isolation is
|
|
31
|
+
the sandbox frame.
|