@occluze/umber 0.3.0 → 0.4.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.
Files changed (87) hide show
  1. package/README.md +93 -47
  2. package/THIRD-PARTY-NOTICES.md +33 -0
  3. package/dist/chunks/badge.js +2 -2
  4. package/dist/chunks/basis.js +2 -2
  5. package/dist/chunks/batches.js +2 -0
  6. package/dist/chunks/capture.js +2 -2
  7. package/dist/chunks/covers.js +2 -2
  8. package/dist/chunks/curves.js +2 -2
  9. package/dist/chunks/flip.js +2 -2
  10. package/dist/chunks/fx.js +2 -2
  11. package/dist/chunks/gl.js +2 -2
  12. package/dist/chunks/glsl.js +2 -2
  13. package/dist/chunks/glyphs.js +2 -0
  14. package/dist/chunks/inspect.js +2 -2
  15. package/dist/chunks/instances.js +2 -2
  16. package/dist/chunks/layers.js +2 -2
  17. package/dist/chunks/licence.js +2 -2
  18. package/dist/chunks/morph.js +2 -2
  19. package/dist/chunks/pace.js +2 -0
  20. package/dist/chunks/patch.js +2 -2
  21. package/dist/chunks/prepared.js +2 -2
  22. package/dist/chunks/profiler.js +2 -2
  23. package/dist/chunks/recheck.js +2 -0
  24. package/dist/chunks/resize.js +2 -0
  25. package/dist/chunks/restore.js +2 -2
  26. package/dist/chunks/shapes.js +2 -2
  27. package/dist/chunks/sim.js +2 -2
  28. package/dist/chunks/text.js +2 -2
  29. package/dist/chunks/video.js +2 -2
  30. package/dist/chunks/vocabulary.js +2 -2
  31. package/dist/chunks/warm.js +2 -2
  32. package/dist/modules/debug.js +2 -2
  33. package/dist/modules/debug.mjs +2 -2
  34. package/dist/modules/handoff.js +2 -2
  35. package/dist/modules/handoff.mjs +2 -2
  36. package/dist/modules/input.js +2 -2
  37. package/dist/modules/input.mjs +2 -2
  38. package/dist/modules/scrollfx.js +2 -2
  39. package/dist/modules/scrollfx.mjs +2 -2
  40. package/dist/modules/scrub.js +2 -2
  41. package/dist/modules/scrub.mjs +2 -2
  42. package/dist/modules/three.js +2 -2
  43. package/dist/modules/three.mjs +2 -2
  44. package/dist/node/assets.mjs +4 -2
  45. package/dist/node/astro.mjs +26 -18
  46. package/dist/node/cli.mjs +63 -10
  47. package/dist/node/shared-NFSQ5J4B.mjs +2116 -0
  48. package/dist/node/{shared-4FIU6DYP.mjs → shared-OUFNIXQ7.mjs} +106 -17
  49. package/dist/node/vite.mjs +7 -3
  50. package/dist/prepared.mjs +2 -0
  51. package/dist/umber.css +1 -1
  52. package/dist/umber.js +2 -2
  53. package/dist/umber.mjs +2 -2
  54. package/docs/AI-quick.md +43 -87
  55. package/docs/AI.md +1977 -1829
  56. package/docs/npm.md +13 -16
  57. package/package.json +32 -48
  58. package/types/assets.d.ts +109 -4
  59. package/types/astro.d.ts +20 -23
  60. package/types/debug.d.ts +1 -1
  61. package/types/esm.d.ts +2 -6
  62. package/types/input.d.ts +3 -3
  63. package/types/loop.d.ts +21 -9
  64. package/types/module.d.ts +0 -2
  65. package/types/scrollfx.d.ts +5 -41
  66. package/types/scrub.d.ts +2 -2
  67. package/types/three.d.ts +26 -1
  68. package/types/umber.d.ts +152 -155
  69. package/types/vite.d.ts +3 -3
  70. package/dist/chunks/views.js +0 -2
  71. package/dist/frameworks/astro.mjs +0 -2
  72. package/dist/frameworks/react.mjs +0 -2
  73. package/dist/frameworks/svelte.mjs +0 -2
  74. package/dist/frameworks/vue.mjs +0 -2
  75. package/dist/modules/router-swap.js +0 -2
  76. package/dist/modules/router.js +0 -2
  77. package/dist/modules/router.mjs +0 -2
  78. package/dist/modules/scroll-more.js +0 -2
  79. package/dist/modules/scroll-touch.js +0 -2
  80. package/dist/modules/scroll.js +0 -2
  81. package/dist/modules/scroll.mjs +0 -2
  82. package/dist/node/shared-3Q24RNIF.mjs +0 -602
  83. package/types/react.d.ts +0 -15
  84. package/types/router.d.ts +0 -223
  85. package/types/scroll.d.ts +0 -190
  86. package/types/svelte.d.ts +0 -16
  87. package/types/vue.d.ts +0 -14
@@ -1,47 +1,55 @@
1
- /*! Umber v0.3.0 asset tool | (c) Ravi Klaassens | UNLICENSED */
1
+ /*! Umber v0.4.1 asset tool | (c) Ravi Klaassens | UNLICENSED */
2
2
  import {
3
+ builtEngine,
3
4
  umberChunks,
5
+ umberDevChunks,
6
+ umberNeeds,
4
7
  umberShaders
5
- } from "./shared-4FIU6DYP.mjs";
8
+ } from "./shared-OUFNIXQ7.mjs";
6
9
  import {
7
- prepareSite
8
- } from "./shared-3Q24RNIF.mjs";
10
+ prepareBuilt
11
+ } from "./shared-NFSQ5J4B.mjs";
9
12
 
10
13
  // tools/assets/astro.ts
11
14
  import { fileURLToPath } from "node:url";
12
- function astroScroll() {
13
- return () => void 0;
14
- }
15
15
  function umberAstro(options = {}) {
16
16
  const { shaders, chunks, ...site } = options;
17
17
  let base = "/";
18
+ const engine = chunks === false ? null : umberChunks();
19
+ const needs = umberNeeds();
18
20
  return {
19
21
  name: "@occluze/umber",
20
22
  hooks: {
21
23
  "astro:config:setup": ({
22
24
  updateConfig
23
25
  }) => {
24
- const plugins = [...shaders === false ? [] : [umberShaders()], ...chunks === false ? [] : [umberChunks()]];
25
- if (plugins.length) updateConfig({ vite: { plugins } });
26
+ const plugins = [
27
+ ...shaders === false ? [] : [umberShaders()],
28
+ needs,
29
+ ...engine ? [engine, umberDevChunks()] : []
30
+ ];
31
+ updateConfig({ vite: { plugins } });
26
32
  },
27
33
  "astro:config:done": ({ config }) => {
28
34
  base = config.base;
29
35
  },
30
36
  "astro:build:done": async ({ dir, logger }) => {
31
- const result = await prepareSite({
32
- ...site,
33
- dir: fileURLToPath(dir),
34
- baseUrl: base,
35
- log: (line) => {
36
- logger.info(line);
37
- }
38
- });
37
+ const result = await prepareBuilt(
38
+ {
39
+ ...site,
40
+ dir: fileURLToPath(dir),
41
+ baseUrl: base,
42
+ log: (line) => {
43
+ logger.info(line);
44
+ }
45
+ },
46
+ { engine: builtEngine(engine, base), scripts: needs.scripts() }
47
+ );
39
48
  for (const line of result.skipped) logger.warn(`skipped ${line}`);
40
49
  }
41
50
  }
42
51
  };
43
52
  }
44
53
  export {
45
- astroScroll,
46
54
  umberAstro as default
47
55
  };
package/dist/node/cli.mjs CHANGED
@@ -1,10 +1,12 @@
1
1
  #!/usr/bin/env node
2
- /*! Umber v0.3.0 asset tool | (c) Ravi Klaassens | UNLICENSED */
2
+ /*! Umber v0.4.1 asset tool | (c) Ravi Klaassens | UNLICENSED */
3
3
  import {
4
4
  prepareSite
5
- } from "./shared-3Q24RNIF.mjs";
5
+ } from "./shared-NFSQ5J4B.mjs";
6
6
 
7
7
  // tools/assets/cli.ts
8
+ import { resolve } from "node:path";
9
+ import { pathToFileURL } from "node:url";
8
10
  import { parseArgs } from "node:util";
9
11
  var HELP = `Usage: umber assets <folder> [options]
10
12
 
@@ -17,6 +19,13 @@ Options:
17
19
  --base-url <path> the URL path the folder is served at (default /)
18
20
  --folder <name> the folder the prepared files go to, inside <folder> (default _umber)
19
21
  --all every picture in <folder>, not only the ones Umber draws
22
+ --pictures <list> more pictures to prepare, files or folders inside <folder> (uploads,img/work); a
23
+ shader's uniform draws a prepared file only for a picture named here:
24
+ for pages a server renders (pageWriter() in @occluze/umber/assets), or a
25
+ scene of your own (picture() in @occluze/umber/prepared)
26
+ --data <list> the site's own number files to pack, each a path inside <folder> and what
27
+ it holds (alps/height.bin:u16,mesh/points.bin:f32; raw, u8, i8, u16, i16,
28
+ u32, i32, f32, f64; no type: raw). Loaded with data() of @occluze/umber/prepared
20
29
  --formats <list> bc7,astc,etc2 (default: all three)
21
30
  --no-avif no AVIF fallback
22
31
  --avif-quality <n> 1 to 100 (default 80)
@@ -28,9 +37,22 @@ Options:
28
37
  --tiny-quality <n> the placeholder's AVIF quality, 1 to 100 (default 50)
29
38
  --cache <folder> where prepared files are kept between builds (default node_modules/.cache/umber-assets)
30
39
  --no-cache make every picture again
31
- --fonts also prepare the fonts of GL text, so its letters are painted from their
32
- outlines: sharp at any scale (at rest the default glyph atlas is closer
33
- to the browser's own text)
40
+ --no-fonts do not prepare the fonts of GL text. By default each font a GL text uses
41
+ is prepared, so its letters are painted from their outlines, sharp at any
42
+ scale; without, from the glyph atlas (the browser's own rasterising).
43
+ A prepared font's outlines are a public file: check the font's licence
44
+ --encode-videos encode the site's scrubbed videos with the ffmpeg on this computer (the PATH,
45
+ or $FFMPEG): a keyframe on every frame where a video has not, a phone-sized
46
+ file (720 px) and a poster frame for each. The tool ships no encoder: with no
47
+ ffmpeg it says so and leaves the videos alone
48
+ --no-videos leave scrubbed videos as they are (by default one whose index is at the end
49
+ of the file gets it moved in front, so it scrubs while it downloads)
50
+ --hints <list> more of Umber's chunks for every GL page to fetch early (shapes,sim...):
51
+ the tool reads what a page's elements and stylesheets ask for,
52
+ this names what only a script does
53
+ --effects <file> a module of the site's own whose \`effects\` (or default) export is its
54
+ effects by name, as it hands them to umber.effect(): a page whose elements
55
+ name one is hinted for the chunks that effect needs
34
56
  -h, --help this text`;
35
57
  function readArgs(args) {
36
58
  const { values, positionals } = parseArgs({
@@ -40,6 +62,10 @@ function readArgs(args) {
40
62
  "base-url": { type: "string" },
41
63
  folder: { type: "string" },
42
64
  all: { type: "boolean" },
65
+ pictures: { type: "string" },
66
+ data: { type: "string" },
67
+ "no-videos": { type: "boolean" },
68
+ "encode-videos": { type: "boolean" },
43
69
  formats: { type: "string" },
44
70
  "no-avif": { type: "boolean" },
45
71
  "avif-quality": { type: "string" },
@@ -50,7 +76,9 @@ function readArgs(args) {
50
76
  "tiny-quality": { type: "string" },
51
77
  cache: { type: "string" },
52
78
  "no-cache": { type: "boolean" },
53
- fonts: { type: "boolean" },
79
+ "no-fonts": { type: "boolean" },
80
+ hints: { type: "string" },
81
+ effects: { type: "string" },
54
82
  help: { type: "boolean", short: "h" }
55
83
  }
56
84
  });
@@ -63,6 +91,11 @@ function readArgs(args) {
63
91
  baseUrl: values["base-url"],
64
92
  folder: values.folder,
65
93
  all: values.all,
94
+ pictures: values.pictures?.split(",").map((name) => name.trim()),
95
+ data: values.data?.split(",").map((named) => {
96
+ const [, file = named, type] = /^(.*):(\w+)$/.exec(named.trim()) ?? [];
97
+ return type ? { file, type } : file.trim();
98
+ }),
66
99
  formats,
67
100
  avif: !values["no-avif"],
68
101
  avifQuality: values["avif-quality"] ? Number(values["avif-quality"]) : void 0,
@@ -72,23 +105,42 @@ function readArgs(args) {
72
105
  tinySize: values["tiny-size"] ? Number(values["tiny-size"]) : void 0,
73
106
  tinyQuality: values["tiny-quality"] ? Number(values["tiny-quality"]) : void 0,
74
107
  cache: values["no-cache"] ? false : values.cache,
75
- fonts: values.fonts
108
+ videos: !values["no-videos"],
109
+ encodeVideos: values["encode-videos"],
110
+ fonts: !values["no-fonts"],
111
+ hints: values.hints?.split(",").map((name) => name.trim()),
112
+ effectsFile: values.effects
76
113
  };
77
114
  }
115
+ async function readEffects(file) {
116
+ const module = await import(pathToFileURL(resolve(file)).href);
117
+ return module.effects ?? module.default;
118
+ }
78
119
  var kb = (bytes = 0) => `${(bytes / 1024).toFixed(0)} KB`;
79
120
  async function main() {
80
- const options = readArgs(process.argv.slice(2));
81
- if (!options) {
121
+ const args = readArgs(process.argv.slice(2));
122
+ if (!args) {
82
123
  console.log(HELP);
83
124
  return;
84
125
  }
126
+ const { effectsFile, ...options } = args;
85
127
  const result = await prepareSite({
86
128
  ...options,
129
+ effects: effectsFile ? await readEffects(effectsFile) : void 0,
87
130
  log: (line) => {
88
131
  console.log(line);
89
132
  }
90
133
  });
91
134
  for (const line of result.skipped) console.warn(`skipped ${line}`);
135
+ if (result.encoded) console.log(`${result.encoded} files encoded for scrubbed videos.`);
136
+ if (result.videos) console.log(`${result.videos} scrubbed videos have their index in front of their frames now.`);
137
+ if (result.hinted) {
138
+ console.log(`${result.hinted} pages fetch Umber's files early (hints in <head>).`);
139
+ if (!options.hints?.length)
140
+ console.log(
141
+ "Hinted from each page's elements and stylesheets. Chunks only a script asks for (umber.sim(), umber.view(), patch: true, an effect put on an element from code) are not known to this command: name them with --hints, or build with the Vite plugin or the Astro integration, which read the site's scripts."
142
+ );
143
+ }
92
144
  if (!result.manifest) {
93
145
  console.log(
94
146
  "No page has a picture Umber draws (a [data-umber] element's <img>): nothing to prepare. --all prepares every picture."
@@ -99,7 +151,8 @@ async function main() {
99
151
  const sizes = Object.entries(made).map(([kind, bytes]) => `${kind} ${kb(bytes)}`);
100
152
  const pictures = sizes.length ? `Pictures: sources ${kb(source)}, prepared ${sizes.join(", ")}. ` : "";
101
153
  const fonts = result.fonts ? `${result.fonts} fonts for GL text. ` : "";
102
- console.log(`${pictures}${fonts}${result.pages} pages point at ${result.manifest}`);
154
+ const data = result.data ? `${result.data} number files: ${kb(result.bytes.dataSource)} packed to ${kb(result.bytes.data)}. ` : "";
155
+ console.log(`${pictures}${fonts}${data}${result.pages} pages point at ${result.manifest}`);
103
156
  }
104
157
  try {
105
158
  await main();