@field/cascade 0.3.1 → 0.5.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/AGENTS.md +32 -9
- package/ARCHITECTURE.md +75 -13
- package/CHANGELOG.md +98 -1
- package/CONTRIBUTING.md +104 -0
- package/DESIGN.md +24 -15
- package/README.md +121 -14
- package/dist/assets/{CodeEditor-D22fVi-4.js → CodeEditor-dOrU3aQg.js} +7 -7
- package/dist/assets/{CodePanel-DPNEYfcR.js → CodePanel-Bqy85qen.js} +2 -2
- package/dist/assets/{CustomNodeDialog-DeHCAvgb.js → CustomNodeDialog-DkZlOgjs.js} +1 -1
- package/dist/assets/{ProjectSettings-DWpVtWEx.js → ProjectSettings-D192mr6g.js} +2 -2
- package/dist/assets/{SettingsDialog-za00IS3L.js → SettingsDialog-BTeeIE3T.js} +1 -1
- package/dist/assets/{VersionHistoryDialog-DTMGhI0_.js → VersionHistoryDialog-TZQKkn3Y.js} +1 -1
- package/dist/assets/{core-JsyKMO1k.js → core-DwbcGL0o.js} +2 -2
- package/dist/assets/{cssMode-emdRheFK.js → cssMode-Dcjn356x.js} +1 -1
- package/dist/assets/definitions-C_SY6Bhg.js +1 -0
- package/dist/assets/{editor.api-xHX-fMSo.js → editor.api-D7Q83606.js} +1 -1
- package/dist/assets/{freemarker2-C3M8_Gs3.js → freemarker2-DCCiHlV6.js} +1 -1
- package/dist/assets/geo-CT-wtvaE.js +1 -0
- package/dist/assets/{handlebars-CBMurtFk.js → handlebars-BCxC8xu1.js} +1 -1
- package/dist/assets/{html-xbLQwknw.js → html-COwepzSd.js} +1 -1
- package/dist/assets/{htmlMode-2wKdDTon.js → htmlMode-Dpg7H0rx.js} +1 -1
- package/dist/assets/{image-i1j6nWKe.js → image-CMfMMxlC.js} +3 -3
- package/dist/assets/index-De1cIZ9N.js +212 -0
- package/dist/assets/index-ilgbOu6G.css +1 -0
- package/dist/assets/{javascript-DJaOo_2I.js → javascript-CSwWxfLr.js} +1 -1
- package/dist/assets/{jsonMode-Bheas8_0.js → jsonMode-BXRriTpj.js} +1 -1
- package/dist/assets/{liquid-BCj_BGbM.js → liquid-Cmkfyogc.js} +1 -1
- package/dist/assets/{lspLanguageFeatures-BfIsx_xz.js → lspLanguageFeatures-xH9JbZGO.js} +1 -1
- package/dist/assets/{mdx-DwiQDiVO.js → mdx-BzrNjNvK.js} +1 -1
- package/dist/assets/nodeTypeUtils-BDJsc2Ks.js +1 -0
- package/dist/assets/pop-BdKEHslJ.js +1 -0
- package/dist/assets/{python-BjrB5nqj.js → python-D4E9jbx7.js} +1 -1
- package/dist/assets/{razor-CfoBmGDs.js → razor-B3x9cIEM.js} +1 -1
- package/dist/assets/{tsMode-BcEoMSxp.js → tsMode-dhQYPNMZ.js} +1 -1
- package/dist/assets/{typescript-DIg7TEmQ.js → typescript-CITkDxAE.js} +1 -1
- package/dist/assets/{workers-vXYuwtPw.js → workers-BQvF9bbO.js} +1 -1
- package/dist/assets/{xml-DexLQIQy.js → xml-DvHlU3A8.js} +1 -1
- package/dist/assets/{yaml-DUnD_1dE.js → yaml-uznsLgs8.js} +1 -1
- package/dist/cli/index.js +16465 -12096
- package/dist/cli/runtime/gpu.ts +71 -0
- package/dist/cli/runtime/io.ts +31 -25
- package/dist/contracts/camera.d.ts +70 -0
- package/dist/contracts/camera.js +27 -0
- package/dist/contracts/capabilities.d.ts +6 -6
- package/dist/contracts/definition.d.ts +62 -4
- package/dist/contracts/index.d.ts +4 -0
- package/dist/contracts/index.js +4 -0
- package/dist/contracts/particles.d.ts +54 -0
- package/dist/contracts/particles.js +167 -0
- package/dist/contracts/scene.d.ts +129 -0
- package/dist/contracts/scene.js +73 -0
- package/dist/contracts/schema.js +26 -3
- package/dist/contracts/series.d.ts +75 -0
- package/dist/contracts/series.js +2 -0
- package/dist/contracts/validate.js +23 -5
- package/dist/contracts/values.d.ts +4 -2
- package/dist/contracts/values.js +10 -0
- package/dist/gpu.d.ts +17 -0
- package/dist/gpu.js +61 -1
- package/dist/index.html +3 -3
- package/dist/io.d.ts +4 -16
- package/dist/io.js +26 -8
- package/dist/player/app.js +810 -0
- package/dist/player/embed.d.ts +4 -0
- package/dist/player/embed.js +77 -0
- package/dist/player/types.d.ts +35 -0
- package/dist/runtime/builtins/core/camera.d.ts +252 -0
- package/dist/runtime/builtins/core/camera.js +149 -0
- package/dist/runtime/builtins/core/index.d.ts +4 -2
- package/dist/runtime/builtins/core/index.js +8 -2
- package/dist/runtime/builtins/core/structural.d.ts +168 -0
- package/dist/runtime/builtins/core/structural.js +175 -0
- package/dist/runtime/builtins/core/time.d.ts +165 -0
- package/dist/runtime/builtins/core/time.js +110 -0
- package/dist/runtime/builtins/geo/definitions.d.ts +247 -0
- package/dist/runtime/builtins/geo/definitions.js +70 -0
- package/dist/runtime/builtins/geo/index.d.ts +2 -1
- package/dist/runtime/builtins/geo/index.js +3 -1
- package/dist/runtime/builtins/geo/render.d.ts +87 -0
- package/dist/runtime/builtins/geo/render.js +87 -0
- package/dist/runtime/builtins/geo/svgExport.d.ts +11 -0
- package/dist/runtime/builtins/geo/svgExport.js +10 -0
- package/dist/runtime/builtins/index.d.ts +5 -2
- package/dist/runtime/builtins/index.js +13 -3
- package/dist/runtime/builtins/pop/definitions.d.ts +2120 -0
- package/dist/runtime/builtins/pop/definitions.js +815 -0
- package/dist/runtime/builtins/pop/index.d.ts +2 -0
- package/dist/runtime/builtins/pop/index.js +2 -0
- package/dist/runtime/builtins/scene/definitions.d.ts +356 -0
- package/dist/runtime/builtins/scene/definitions.js +224 -0
- package/dist/runtime/builtins/scene/index.d.ts +2 -0
- package/dist/runtime/builtins/scene/index.js +2 -0
- package/dist/runtime/camera/index.d.ts +60 -0
- package/dist/runtime/camera/index.js +234 -0
- package/dist/runtime/definition/architecture.js +36 -1
- package/dist/runtime/geometry/render.d.ts +109 -0
- package/dist/runtime/geometry/render.js +145 -0
- package/dist/runtime/geometry/svg.d.ts +29 -0
- package/dist/runtime/geometry/svg.js +11 -5
- package/dist/runtime/gpu.d.ts +33 -0
- package/dist/runtime/gpu.js +218 -0
- package/dist/runtime/index.d.ts +4 -0
- package/dist/runtime/index.js +4 -0
- package/dist/runtime/pop/cache.d.ts +27 -0
- package/dist/runtime/pop/cache.js +123 -0
- package/dist/runtime/pop/forces.d.ts +202 -0
- package/dist/runtime/pop/forces.js +519 -0
- package/dist/runtime/pop/index.d.ts +5 -0
- package/dist/runtime/pop/index.js +5 -0
- package/dist/runtime/pop/state.d.ts +136 -0
- package/dist/runtime/pop/state.js +283 -0
- package/dist/runtime/pop/trail.d.ts +62 -0
- package/dist/runtime/pop/trail.js +142 -0
- package/dist/runtime/runtime.js +284 -9
- package/dist/runtime/scene/index.d.ts +50 -0
- package/dist/runtime/scene/index.js +94 -0
- package/dist/runtime/series/index.d.ts +41 -0
- package/dist/runtime/series/index.js +167 -0
- package/dist/runtime/types.d.ts +1 -1
- package/dist/studio/panel.d.ts +68 -1
- package/doc/HEADLESS_GPU.md +160 -0
- package/doc/NODE_REFERENCE.md +408 -1
- package/doc/PROJECT_AUTHORING.md +118 -20
- package/doc/WEB_PLAYER.md +131 -0
- package/package.json +25 -3
- package/dist/assets/geo-BAR6lQp5.js +0 -1
- package/dist/assets/index-BDV5xGBZ.css +0 -1
- package/dist/assets/index-CMcH8AgP.js +0 -212
- package/dist/assets/nodeTypeUtils-BBA1JqHx.js +0 -1
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# Browser player
|
|
2
|
+
|
|
3
|
+
The player runs a compatible graph in a browser without Studio or a Cascade
|
|
4
|
+
server. Available in Cascade 0.5+. Install `@field/cascade@latest`, or build the
|
|
5
|
+
checkout when developing Cascade itself.
|
|
6
|
+
|
|
7
|
+
## Build and launch
|
|
8
|
+
|
|
9
|
+
From a project containing `index.cascade`:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
cascade build index.cascade --out web-player
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The output directory must not already exist. It contains `index.html`,
|
|
16
|
+
`player.html`, `app.js`, `embed.js`, and any included assets. Serve that directory
|
|
17
|
+
with an ordinary static HTTP server or hosting service, then open `index.html`.
|
|
18
|
+
Do not open it through `file://`: browser module and asset loading requires HTTP.
|
|
19
|
+
No application backend is required. WebGPU needs a supported browser/device and
|
|
20
|
+
a secure context such as HTTPS or localhost.
|
|
21
|
+
|
|
22
|
+
Graph definitions are inspected and compiled at build time, not executed.
|
|
23
|
+
The build rejects unsupported server capabilities, server transport imports,
|
|
24
|
+
Node dependencies and dynamic node modules. It does not publish or upload files.
|
|
25
|
+
|
|
26
|
+
## Embed
|
|
27
|
+
|
|
28
|
+
For a simple embed, including across origins:
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<iframe src="/artwork/player.html" title="Generative artwork"
|
|
32
|
+
style="width:100%;height:600px;border:0"></iframe>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
For programmatic controls on the **same origin**:
|
|
36
|
+
|
|
37
|
+
Give the host container an explicit height, for example
|
|
38
|
+
`<div id="artwork" style="height:600px"></div>`. The iframe fills that container.
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
import { mount } from './web-player/embed.js';
|
|
42
|
+
|
|
43
|
+
const player = await mount(document.querySelector('#artwork'), {
|
|
44
|
+
frame: 1,
|
|
45
|
+
fps: 30,
|
|
46
|
+
autoplay: false,
|
|
47
|
+
output: { nodeId: 'render', port: 'image' },
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
await player.setProp('render', 'strokeWidth', 2);
|
|
51
|
+
await player.seek(48);
|
|
52
|
+
player.play();
|
|
53
|
+
// Later, when the host view is removed:
|
|
54
|
+
await player.dispose();
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The generic `mountPlayer` export from `cascade/player` accepts the same options
|
|
58
|
+
plus `url`, pointing to a built `player.html`. Each mount creates an iframe, so
|
|
59
|
+
two sketches can use the same node IDs and cache filenames without sharing data.
|
|
60
|
+
Programmatic cross-origin control is not provided; use the iframe directly.
|
|
61
|
+
|
|
62
|
+
Mount resolves after the first successful cook and display. A failed startup
|
|
63
|
+
rejects and removes the failed embed. Playback starts paused unless requested;
|
|
64
|
+
runtime failures pause playback and expose their diagnostic. Frame work is
|
|
65
|
+
serialized and playback coalesces requests instead of building a catch-up queue.
|
|
66
|
+
|
|
67
|
+
## Controls and output
|
|
68
|
+
|
|
69
|
+
`PlayerController` provides:
|
|
70
|
+
|
|
71
|
+
- `play()`, `pause()`, `seek(frame)`.
|
|
72
|
+
- `setInput(nodeId, name, value)` and `setProp(nodeId, name, value)`, which await
|
|
73
|
+
the resulting cook.
|
|
74
|
+
- `selectOutput(nodeId, port)` and `getOutput(nodeId, port)`.
|
|
75
|
+
- `downloadOutput()`, returning the selected output as a `Blob`.
|
|
76
|
+
- `resize(width, height)` for the display, without changing authored resolution.
|
|
77
|
+
- `subscribe(listener)` for `frame`, `playing` and `error` events; returns an
|
|
78
|
+
unsubscribe function.
|
|
79
|
+
- `dispose()`, which stops work and releases runtime, GPU, image and iframe resources.
|
|
80
|
+
|
|
81
|
+
Output selection defaults to the last renderable output in the run result;
|
|
82
|
+
select a node and port explicitly when a graph has several deliverables. Images/SVG and
|
|
83
|
+
geometry/scenes are displayable; scene rendering currently uses the shared CPU
|
|
84
|
+
wireframe/point renderer, not a shaded GPU renderer. Camera conventions match
|
|
85
|
+
Studio and offline rendering. For durable image retention, obtain a Blob:
|
|
86
|
+
image references returned by `getOutput` are current-frame references, not an
|
|
87
|
+
archive of every rendered frame.
|
|
88
|
+
|
|
89
|
+
## Assets and resource limits
|
|
90
|
+
|
|
91
|
+
Literal typed image/asset references in graph inputs or props are included
|
|
92
|
+
automatically. Files whose paths are computed in node code must be listed:
|
|
93
|
+
|
|
94
|
+
```sh
|
|
95
|
+
cascade build index.cascade --out web-player --asset assets/photo.png
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Repeat `--asset` for additional files. Only those files are copied, preserving
|
|
99
|
+
project-relative paths below the output's `assets/` directory. Directories,
|
|
100
|
+
hidden files, path traversal and symlinks escaping the project are rejected.
|
|
101
|
+
The builder never copies the entire project, credentials, Python environments
|
|
102
|
+
or cache directories. Review authored graph values and custom code before
|
|
103
|
+
publishing: project modules are trusted code, not a sandbox.
|
|
104
|
+
|
|
105
|
+
The player supplies one asset store for declared `assets` capabilities and
|
|
106
|
+
existing `cascade/io` imports. Reads resolve packaged files; writes stay in
|
|
107
|
+
memory and create immutable references. `mediaUrl` resolves through that store,
|
|
108
|
+
not Studio's `/api/media`. Server-only preview transformations are unsupported
|
|
109
|
+
and fail explicitly rather than returning different pixels silently.
|
|
110
|
+
|
|
111
|
+
Generated encoded assets are limited to 256 MiB and 4,096 entries per iframe.
|
|
112
|
+
After a cook, assets no longer reachable from graph outputs, authored/controller
|
|
113
|
+
values or active display leases are released. Feedback history keeps referenced
|
|
114
|
+
images alive. Exceeding the live budget fails with a diagnostic; live images
|
|
115
|
+
are not silently replaced or evicted. Disposal revokes all generated URLs.
|
|
116
|
+
|
|
117
|
+
## Host limits
|
|
118
|
+
|
|
119
|
+
| Graph requirement | Static player |
|
|
120
|
+
| --- | --- |
|
|
121
|
+
| Definition-v1 CPU nodes, core/geometry/POP/scene built-ins | Supported |
|
|
122
|
+
| Canvas drawing and compatible `cascade/io` helpers | Supported |
|
|
123
|
+
| Declared `assets` | Packaged inputs and in-memory generated outputs |
|
|
124
|
+
| Declared `gpu` | Browser WebGPU, if available; no Dawn in the browser |
|
|
125
|
+
| Python, shell, filesystem, Studio/server transport | Rejected |
|
|
126
|
+
| Dynamic modules or mixed execution styles | Rejected |
|
|
127
|
+
| Project Studio panels | Not included |
|
|
128
|
+
|
|
129
|
+
Separate heavy preprocessing from the live graph when possible: export its
|
|
130
|
+
result as an explicit asset, then build the browser-compatible graph around
|
|
131
|
+
that input. The player does not emulate server operations or carry credentials.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@field/cascade",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Visual programming for generative art",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "FIELD.IO <marcus@field.io>",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/marcuswendt/cascade.git"
|
|
10
10
|
},
|
|
11
|
-
"homepage": "https://
|
|
11
|
+
"homepage": "https://cascade.field.io",
|
|
12
12
|
"keywords": [
|
|
13
13
|
"node-graph",
|
|
14
14
|
"visual-programming",
|
|
@@ -27,11 +27,14 @@
|
|
|
27
27
|
"dist",
|
|
28
28
|
"!dist/**/*.map",
|
|
29
29
|
"CHANGELOG.md",
|
|
30
|
+
"CONTRIBUTING.md",
|
|
30
31
|
"AGENTS.md",
|
|
31
32
|
"ARCHITECTURE.md",
|
|
32
33
|
"DESIGN.md",
|
|
33
34
|
"doc/NODE_REFERENCE.md",
|
|
34
35
|
"doc/PROJECT_AUTHORING.md",
|
|
36
|
+
"doc/HEADLESS_GPU.md",
|
|
37
|
+
"doc/WEB_PLAYER.md",
|
|
35
38
|
"README.md",
|
|
36
39
|
"LICENSE"
|
|
37
40
|
],
|
|
@@ -71,6 +74,18 @@
|
|
|
71
74
|
"types": "./dist/runtime/animation/index.d.ts",
|
|
72
75
|
"default": "./dist/runtime/animation/index.js"
|
|
73
76
|
},
|
|
77
|
+
"./runtime/camera": {
|
|
78
|
+
"types": "./dist/runtime/camera/index.d.ts",
|
|
79
|
+
"default": "./dist/runtime/camera/index.js"
|
|
80
|
+
},
|
|
81
|
+
"./runtime/render": {
|
|
82
|
+
"types": "./dist/runtime/geometry/render.d.ts",
|
|
83
|
+
"default": "./dist/runtime/geometry/render.js"
|
|
84
|
+
},
|
|
85
|
+
"./runtime/scene": {
|
|
86
|
+
"types": "./dist/runtime/scene/index.d.ts",
|
|
87
|
+
"default": "./dist/runtime/scene/index.js"
|
|
88
|
+
},
|
|
74
89
|
"./runtime/definition/extract": {
|
|
75
90
|
"types": "./dist/runtime/definition/extract.d.ts",
|
|
76
91
|
"default": "./dist/runtime/definition/extract.js"
|
|
@@ -97,6 +112,10 @@
|
|
|
97
112
|
},
|
|
98
113
|
"./studio/panel": {
|
|
99
114
|
"types": "./dist/studio/panel.d.ts"
|
|
115
|
+
},
|
|
116
|
+
"./player": {
|
|
117
|
+
"types": "./dist/player/embed.d.ts",
|
|
118
|
+
"default": "./dist/player/embed.js"
|
|
100
119
|
}
|
|
101
120
|
},
|
|
102
121
|
"scripts": {
|
|
@@ -108,6 +127,7 @@
|
|
|
108
127
|
"check:packages": "npm run check --workspace @cascade/contracts && npm run build --workspace @cascade/contracts && npm run check --workspace @cascade/runtime",
|
|
109
128
|
"test:packages": "npm run test --workspace @cascade/contracts && npm run test --workspace @cascade/runtime",
|
|
110
129
|
"build:cli": "npm run build:packages && node scripts/build-cli.mjs && npm run build:node-reference",
|
|
130
|
+
"build:server": "npm --prefix server run build",
|
|
111
131
|
"prepack": "npm run build",
|
|
112
132
|
"preview": "vite preview",
|
|
113
133
|
"check": "svelte-check --tsconfig ./tsconfig.json",
|
|
@@ -115,6 +135,7 @@
|
|
|
115
135
|
"test:run": "vitest run",
|
|
116
136
|
"test:coverage": "vitest run --coverage",
|
|
117
137
|
"test:package": "node scripts/smoke-package.mjs",
|
|
138
|
+
"test:player": "node scripts/smoke-player.mjs",
|
|
118
139
|
"build:node-reference": "tsx scripts/build-node-reference.mjs"
|
|
119
140
|
},
|
|
120
141
|
"dependencies": {
|
|
@@ -148,6 +169,7 @@
|
|
|
148
169
|
"dompurify": "$dompurify"
|
|
149
170
|
},
|
|
150
171
|
"optionalDependencies": {
|
|
151
|
-
"@napi-rs/canvas": "^1.0.8"
|
|
172
|
+
"@napi-rs/canvas": "^1.0.8",
|
|
173
|
+
"webgpu": "0.6.0"
|
|
152
174
|
}
|
|
153
175
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as e,f as t,s as n,x as r}from"./index-CMcH8AgP.js";r(n,{assets:e});export{t as geoLibrary};
|