@alpaca-headless/dynamic-renderings-engine 1.0.4694
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 +8 -0
- package/README.md +43 -0
- package/THIRD_PARTY_LICENSES +385 -0
- package/dist/assets/esbuild.wasm +0 -0
- package/dist/assets/quickjs.wasm +0 -0
- package/dist/assets/tailwindcss/theme.css +510 -0
- package/dist/assets/tailwindcss/utilities.css +1 -0
- package/dist/compile-thread.mjs +19561 -0
- package/dist/css-policy/css-policy.d.mts +13 -0
- package/dist/css-policy/css-policy.mjs +396 -0
- package/dist/engine.mjs +463 -0
- package/dist/protocol/index.d.ts +3 -0
- package/dist/protocol/index.js +2 -0
- package/dist/protocol/protocol.d.ts +46 -0
- package/dist/protocol/protocol.js +59 -0
- package/dist/protocol/types.d.ts +113 -0
- package/dist/protocol/types.js +2 -0
- package/dist/render-thread.mjs +1915 -0
- package/dist/runtime.js +14052 -0
- package/dist/runtime.meta.json +4 -0
- package/index.d.mts +107 -0
- package/package.json +56 -0
package/index.d.mts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// Types of @alpaca-headless/dynamic-renderings-engine (the JavaScript lives in dist/engine.mjs).
|
|
2
|
+
|
|
3
|
+
export type Diagnostic = { severity: "error" | "warning"; file?: string; line?: number; column?: number; message: string };
|
|
4
|
+
|
|
5
|
+
export type CompileRequest = {
|
|
6
|
+
renderingId: string;
|
|
7
|
+
kind?: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
code: string;
|
|
10
|
+
/** The rendering's client code, imported by its code as `./client`. */
|
|
11
|
+
clientCode?: string | null;
|
|
12
|
+
/** The host's theme file. */
|
|
13
|
+
themeCss?: string;
|
|
14
|
+
/** The tenant's theme rendering: custom property declarations. */
|
|
15
|
+
themeTokens?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type CompileResult = {
|
|
19
|
+
ok: boolean;
|
|
20
|
+
/** True when the failure says nothing about the source (queue full, deadline, thread stopped): never cache it. */
|
|
21
|
+
transient?: boolean;
|
|
22
|
+
themeHash?: string;
|
|
23
|
+
compiledServer?: string;
|
|
24
|
+
/** The client code as a minified browser ES module; React comes from globalThis.__alpaca_dynamic_react. */
|
|
25
|
+
compiledClient?: string | null;
|
|
26
|
+
/** The client code as a CommonJS module for first paints in the render threads. */
|
|
27
|
+
compiledClientNode?: string | null;
|
|
28
|
+
clientExports?: string[];
|
|
29
|
+
css?: string;
|
|
30
|
+
diagnostics: Diagnostic[];
|
|
31
|
+
ms?: number;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type EngineComponent = { key: string; buildId: string; dto: unknown };
|
|
35
|
+
|
|
36
|
+
export type EngineRenderResult =
|
|
37
|
+
| { key: string; ok: true; tree: unknown[]; ms?: number }
|
|
38
|
+
| { key: string; ok: false; code: string; message: string; logs?: string[]; ms?: number };
|
|
39
|
+
|
|
40
|
+
/** A compiled rendering as the render threads run it: server code and, optionally, the first-paint module. */
|
|
41
|
+
export type EngineModuleSource = { server: string; client?: string; clientExports?: string[] };
|
|
42
|
+
|
|
43
|
+
export type RenderPageRequest = {
|
|
44
|
+
tenant: string;
|
|
45
|
+
components: EngineComponent[];
|
|
46
|
+
/** Compiled code per buildId, for builds the thread may not have loaded yet. */
|
|
47
|
+
sources?: Record<string, EngineModuleSource>;
|
|
48
|
+
deadlineMs?: number;
|
|
49
|
+
/** Run in a context of its own that is discarded afterwards. */
|
|
50
|
+
fresh?: boolean;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type EngineLimits = {
|
|
54
|
+
sourceBytes: number;
|
|
55
|
+
cssBytes: number;
|
|
56
|
+
treeBytes: number;
|
|
57
|
+
treeDepth: number;
|
|
58
|
+
treeNodes: number;
|
|
59
|
+
componentMs: number;
|
|
60
|
+
pageMs: number;
|
|
61
|
+
buildMs: number;
|
|
62
|
+
threadHeapMb: number;
|
|
63
|
+
runtimeMemoryMb: number;
|
|
64
|
+
maxThreads: number;
|
|
65
|
+
maxBuilds: number;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export type EngineOptions = {
|
|
69
|
+
limits?: Partial<EngineLimits>;
|
|
70
|
+
compileThreads?: number;
|
|
71
|
+
compileQueue?: number;
|
|
72
|
+
renderThreads?: number;
|
|
73
|
+
idleMs?: number;
|
|
74
|
+
rate?: { perSecond: number; burst: number };
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export type Engine = {
|
|
78
|
+
limits: EngineLimits;
|
|
79
|
+
compile(request: CompileRequest): Promise<CompileResult>;
|
|
80
|
+
renderPage(request: RenderPageRequest): Promise<EngineRenderResult[]>;
|
|
81
|
+
stats(): unknown;
|
|
82
|
+
close(): Promise<void>;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export function createEngine(options?: EngineOptions): Engine;
|
|
86
|
+
|
|
87
|
+
export class CompilePool {
|
|
88
|
+
constructor(options: { size?: number; compileMs: number; queueLimit?: number; heapMb?: number });
|
|
89
|
+
compile(request: CompileRequest): Promise<CompileResult>;
|
|
90
|
+
stats(): { threads: number; idle: number; queued: number };
|
|
91
|
+
close(): Promise<void>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export class RenderPool {
|
|
95
|
+
constructor(options: { limits: EngineLimits; maxThreads?: number; idleMs?: number; rate?: { perSecond: number; burst: number } });
|
|
96
|
+
renderPage(request: RenderPageRequest): Promise<EngineRenderResult[]>;
|
|
97
|
+
stats(): unknown;
|
|
98
|
+
close(): Promise<void>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export const protocol: {
|
|
102
|
+
compiledFormat: number;
|
|
103
|
+
limits: EngineLimits;
|
|
104
|
+
serverImports: readonly string[];
|
|
105
|
+
clientImports: readonly string[];
|
|
106
|
+
browserExports: Readonly<Record<string, readonly string[]>>;
|
|
107
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alpaca-headless/dynamic-renderings-engine",
|
|
3
|
+
"version": "1.0.4694",
|
|
4
|
+
"description": "Isolated dynamic component compiler and QuickJS runtime. No CMS or SDK runtime dependencies.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=22.13"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./index.d.mts",
|
|
15
|
+
"import": "./dist/engine.mjs"
|
|
16
|
+
},
|
|
17
|
+
"./package.json": "./package.json",
|
|
18
|
+
"./protocol": {
|
|
19
|
+
"types": "./dist/protocol/index.d.ts",
|
|
20
|
+
"import": "./dist/protocol/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./css-policy": {
|
|
23
|
+
"types": "./dist/css-policy/css-policy.d.mts",
|
|
24
|
+
"import": "./dist/css-policy/css-policy.mjs"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist/",
|
|
29
|
+
"index.d.mts",
|
|
30
|
+
"README.md",
|
|
31
|
+
"THIRD_PARTY_LICENSES",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build:contract": "tsc -p tsconfig.protocol.json && node scripts/copy-contract.mjs",
|
|
36
|
+
"build": "npm run build:contract && node scripts/build-runtime.mjs && node scripts/pack.mjs",
|
|
37
|
+
"build:native": "npm run build:contract && node scripts/build-runtime.mjs && node scripts/pack.mjs",
|
|
38
|
+
"test": "npm run build && node --test \"test/*.test.mjs\""
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"postcss": "^8.5.26",
|
|
42
|
+
"postcss-selector-parser": "^7.1.0",
|
|
43
|
+
"postcss-value-parser": "^4.2.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@jitl/quickjs-wasmfile-release-sync": "0.32.0",
|
|
47
|
+
"esbuild-wasm": "0.28.2",
|
|
48
|
+
"parse5": "7.3.0",
|
|
49
|
+
"quickjs-emscripten-core": "0.32.0",
|
|
50
|
+
"react": "19.2.8",
|
|
51
|
+
"react-dom": "19.2.8",
|
|
52
|
+
"tailwindcss": "4.3.3",
|
|
53
|
+
"typescript": "npm:@typescript/typescript6@6.0.2"
|
|
54
|
+
},
|
|
55
|
+
"license": "SEE LICENSE IN LICENSE"
|
|
56
|
+
}
|