@field/cascade 0.4.0 → 0.5.2

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.
Files changed (110) hide show
  1. package/AGENTS.md +18 -0
  2. package/ARCHITECTURE.md +53 -7
  3. package/CHANGELOG.md +68 -0
  4. package/CONTRIBUTING.md +33 -0
  5. package/DESIGN.md +9 -6
  6. package/README.md +80 -4
  7. package/dist/assets/{CodeEditor-BNOJIDzL.js → CodeEditor-BHej8kM9.js} +7 -7
  8. package/dist/assets/{CodePanel-2wp2G0Fj.js → CodePanel-CT3eirK8.js} +2 -2
  9. package/dist/assets/{CustomNodeDialog-DNqaVBqA.js → CustomNodeDialog-BG0m7_Rv.js} +1 -1
  10. package/dist/assets/{ProjectSettings-DcdYF2E1.js → ProjectSettings-BxoLWJG6.js} +2 -2
  11. package/dist/assets/{SettingsDialog-D2xVvyiR.js → SettingsDialog-r9PzZ22z.js} +1 -1
  12. package/dist/assets/{VersionHistoryDialog-DW288ykF.js → VersionHistoryDialog-B6zUV6Dy.js} +1 -1
  13. package/dist/assets/{core-B1y38i95.js → core-wwx5881P.js} +2 -2
  14. package/dist/assets/{cssMode-BLucnaln.js → cssMode-DY5T2Or0.js} +1 -1
  15. package/dist/assets/definitions-BgCvRHyR.js +1 -0
  16. package/dist/assets/{editor.api-B3Et3Pph.js → editor.api-mkORHEMm.js} +1 -1
  17. package/dist/assets/{freemarker2-DVlPoano.js → freemarker2-CIWlk0sw.js} +1 -1
  18. package/dist/assets/geo-CIxgs0oE.js +1 -0
  19. package/dist/assets/{handlebars-B5FZBAMR.js → handlebars-t4jbj3Br.js} +1 -1
  20. package/dist/assets/{html-FodD8KbR.js → html-Ctx7UOlY.js} +1 -1
  21. package/dist/assets/{htmlMode-CsG57VCD.js → htmlMode-BKNZxVw7.js} +1 -1
  22. package/dist/assets/{image-B3F-nq25.js → image-BCBFz0gD.js} +3 -3
  23. package/dist/assets/index-CeqTfMbr.js +212 -0
  24. package/dist/assets/{index-Y2ock1cw.css → index-ilgbOu6G.css} +1 -1
  25. package/dist/assets/{javascript-B3gonF_H.js → javascript-Da_TJBzH.js} +1 -1
  26. package/dist/assets/{jsonMode-Y3w1ahZg.js → jsonMode-Ftt5d1nV.js} +1 -1
  27. package/dist/assets/{liquid-CTpWXIYO.js → liquid-D5kWYG57.js} +1 -1
  28. package/dist/assets/{lspLanguageFeatures-CODBdKEZ.js → lspLanguageFeatures-B-93LC_L.js} +1 -1
  29. package/dist/assets/{mdx-CDAQJZIz.js → mdx-DGT3C_qs.js} +1 -1
  30. package/dist/assets/nodeTypeUtils-BDJsc2Ks.js +1 -0
  31. package/dist/assets/pop-BJGN5Ac4.js +1 -0
  32. package/dist/assets/{python-LOIlxJU-.js → python-Bz3Eew5S.js} +1 -1
  33. package/dist/assets/{razor-CllPQSHo.js → razor-CFDdKpKI.js} +1 -1
  34. package/dist/assets/{tsMode-CO28ut8t.js → tsMode-BaCINWBI.js} +1 -1
  35. package/dist/assets/{typescript-ruU9wKQ_.js → typescript-BoOWspVs.js} +1 -1
  36. package/dist/assets/{workers-Bc1Ywp4-.js → workers-dSWyDxsQ.js} +1 -1
  37. package/dist/assets/{xml-DoXP2Dh1.js → xml-eFi1_vYt.js} +1 -1
  38. package/dist/assets/{yaml-D9YPyGiJ.js → yaml-a7xrJHxm.js} +1 -1
  39. package/dist/cli/index.js +16266 -12653
  40. package/dist/cli/runtime/io.ts +31 -25
  41. package/dist/contracts/definition.d.ts +21 -2
  42. package/dist/contracts/index.d.ts +2 -0
  43. package/dist/contracts/index.js +2 -0
  44. package/dist/contracts/particles.d.ts +54 -0
  45. package/dist/contracts/particles.js +167 -0
  46. package/dist/contracts/scene.d.ts +129 -0
  47. package/dist/contracts/scene.js +73 -0
  48. package/dist/contracts/schema.js +1 -1
  49. package/dist/contracts/validate.js +4 -2
  50. package/dist/contracts/values.d.ts +3 -2
  51. package/dist/contracts/values.js +9 -0
  52. package/dist/index.html +3 -3
  53. package/dist/io.d.ts +4 -16
  54. package/dist/io.js +26 -8
  55. package/dist/player/app.js +810 -0
  56. package/dist/player/embed.d.ts +4 -0
  57. package/dist/player/embed.js +77 -0
  58. package/dist/player/types.d.ts +35 -0
  59. package/dist/runtime/builtins/core/index.d.ts +3 -2
  60. package/dist/runtime/builtins/core/index.js +6 -2
  61. package/dist/runtime/builtins/core/structural.d.ts +168 -0
  62. package/dist/runtime/builtins/core/structural.js +175 -0
  63. package/dist/runtime/builtins/core/time.d.ts +165 -0
  64. package/dist/runtime/builtins/core/time.js +110 -0
  65. package/dist/runtime/builtins/geo/definitions.d.ts +247 -0
  66. package/dist/runtime/builtins/geo/definitions.js +70 -0
  67. package/dist/runtime/builtins/geo/index.d.ts +2 -1
  68. package/dist/runtime/builtins/geo/index.js +3 -1
  69. package/dist/runtime/builtins/geo/render.d.ts +87 -0
  70. package/dist/runtime/builtins/geo/render.js +87 -0
  71. package/dist/runtime/builtins/geo/svgExport.d.ts +11 -0
  72. package/dist/runtime/builtins/geo/svgExport.js +10 -0
  73. package/dist/runtime/builtins/index.d.ts +5 -2
  74. package/dist/runtime/builtins/index.js +13 -3
  75. package/dist/runtime/builtins/pop/definitions.d.ts +2120 -0
  76. package/dist/runtime/builtins/pop/definitions.js +815 -0
  77. package/dist/runtime/builtins/pop/index.d.ts +2 -0
  78. package/dist/runtime/builtins/pop/index.js +2 -0
  79. package/dist/runtime/builtins/scene/definitions.d.ts +356 -0
  80. package/dist/runtime/builtins/scene/definitions.js +224 -0
  81. package/dist/runtime/builtins/scene/index.d.ts +2 -0
  82. package/dist/runtime/builtins/scene/index.js +2 -0
  83. package/dist/runtime/geometry/render.d.ts +109 -0
  84. package/dist/runtime/geometry/render.js +145 -0
  85. package/dist/runtime/geometry/svg.d.ts +29 -0
  86. package/dist/runtime/geometry/svg.js +11 -5
  87. package/dist/runtime/index.d.ts +1 -0
  88. package/dist/runtime/index.js +1 -0
  89. package/dist/runtime/pop/cache.d.ts +27 -0
  90. package/dist/runtime/pop/cache.js +123 -0
  91. package/dist/runtime/pop/forces.d.ts +202 -0
  92. package/dist/runtime/pop/forces.js +519 -0
  93. package/dist/runtime/pop/index.d.ts +5 -0
  94. package/dist/runtime/pop/index.js +5 -0
  95. package/dist/runtime/pop/state.d.ts +136 -0
  96. package/dist/runtime/pop/state.js +283 -0
  97. package/dist/runtime/pop/trail.d.ts +62 -0
  98. package/dist/runtime/pop/trail.js +142 -0
  99. package/dist/runtime/runtime.js +221 -3
  100. package/dist/runtime/scene/index.d.ts +50 -0
  101. package/dist/runtime/scene/index.js +94 -0
  102. package/dist/studio/panel.d.ts +68 -1
  103. package/doc/HEADLESS_GPU.md +4 -4
  104. package/doc/NODE_REFERENCE.md +372 -1
  105. package/doc/PROJECT_AUTHORING.md +16 -4
  106. package/doc/WEB_PLAYER.md +131 -0
  107. package/package.json +16 -2
  108. package/dist/assets/geo-DhyFdBXX.js +0 -1
  109. package/dist/assets/index-CC6YQw2n.js +0 -212
  110. package/dist/assets/nodeTypeUtils-BBA1JqHx.js +0 -1
package/dist/io.d.ts CHANGED
@@ -1,19 +1,5 @@
1
- /**
2
- * `cascade/io` — the runtime a BROWSER-side node imports.
3
- *
4
- * The interop rests on one rule: an image port carries a project-relative PATH,
5
- * never pixels. A Python node writes a file and emits its path; a WebGL node
6
- * reads that path as a texture, renders, writes its result back, and emits a
7
- * path of the same kind. Neither knows or cares which side produced its input,
8
- * which is what makes the two interchangeable — and it lets the heavy stages
9
- * stay in Python while the interactive ones run in the page.
10
- *
11
- * The counterpart on the server side is the project's own exec bridge
12
- * (`runStage`), which is per-project because the stages are.
13
- *
14
- * This file is compiled into any node module that imports 'cascade/io'; it is
15
- * not published to npm and has no dependencies.
16
- */
1
+ /** Shared `cascade/io` helpers. Studio uses project HTTP routes; other hosts
2
+ * install a bridge. Image ports carry paths rather than ambient pixel buffers. */
17
3
  export interface MediaOptions {
18
4
  /** Ask for a resized copy. Never upscales past the file's own resolution. */
19
5
  width?: number;
@@ -45,6 +31,8 @@ export interface IoBridge {
45
31
  read(path: string, options?: MediaOptions): Promise<Uint8Array>;
46
32
  /** Write bytes into the project cache. Returns the stored project-relative path. */
47
33
  write(path: string, data: Uint8Array): Promise<string>;
34
+ /** Host-owned display URL, valid until the host releases its stored asset. */
35
+ url?(path: string, options?: MediaOptions): string;
48
36
  }
49
37
  /** Install the local transport. Returns a disposer, so a test can take it down. */
50
38
  export declare function installIoBridge(bridge: IoBridge | null): () => void;
package/dist/io.js CHANGED
@@ -1,6 +1,8 @@
1
1
  // server/src/runtime/io.ts
2
2
  function mediaUrl(path, options = {}) {
3
3
  if (/^(https?:|data:|blob:)/.test(path)) return path;
4
+ const bridge = localIo();
5
+ if (bridge?.url) return bridge.url(path, options);
4
6
  const clean = path.replace(/^\.?\//, "");
5
7
  const encoded = clean.split("/").map(encodeURIComponent).join("/");
6
8
  const params = new URLSearchParams();
@@ -40,17 +42,33 @@ async function loadBytes(path, options = { raw: true }) {
40
42
  async function loadImage(path, options = { raw: true }) {
41
43
  const image = new Image();
42
44
  const bridge = localIo();
43
- if (bridge) {
44
- image.src = new Uint8Array(await loadBytes(path, options));
45
- } else {
46
- image.crossOrigin = "anonymous";
47
- image.src = mediaUrl(path, options);
45
+ let temporaryUrl;
46
+ try {
47
+ if (bridge?.url) {
48
+ image.crossOrigin = "anonymous";
49
+ image.src = bridge.url(path, options);
50
+ } else if (bridge) {
51
+ const bytes = await loadBytes(path, options);
52
+ if (typeof document === "undefined") {
53
+ image.src = new Uint8Array(bytes);
54
+ } else {
55
+ temporaryUrl = URL.createObjectURL(new Blob([bytes]));
56
+ image.src = temporaryUrl;
57
+ }
58
+ } else {
59
+ image.crossOrigin = "anonymous";
60
+ image.src = mediaUrl(path, options);
61
+ }
62
+ await image.decode();
63
+ return image;
64
+ } finally {
65
+ if (temporaryUrl) URL.revokeObjectURL(temporaryUrl);
48
66
  }
49
- await image.decode();
50
- return image;
51
67
  }
52
68
  async function loadBitmap(path, options = { raw: true }) {
53
- if (localIo()) return createImageBitmap(new Blob([await loadBytes(path, options)]));
69
+ const bridge = localIo();
70
+ if (bridge?.url) return createImageBitmap(await loadImage(path, options));
71
+ if (bridge) return createImageBitmap(new Blob([await loadBytes(path, options)]));
54
72
  const response = await fetch(mediaUrl(path, options));
55
73
  if (!response.ok) throw new Error(`cascade/io: cannot load ${path} (${response.status})`);
56
74
  return createImageBitmap(await response.blob());