@occluze/umber 0.3.0 → 0.4.0
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/README.md +93 -47
- package/THIRD-PARTY-NOTICES.md +33 -0
- package/dist/chunks/badge.js +2 -2
- package/dist/chunks/basis.js +2 -2
- package/dist/chunks/batches.js +2 -0
- package/dist/chunks/capture.js +2 -2
- package/dist/chunks/covers.js +2 -2
- package/dist/chunks/curves.js +2 -2
- package/dist/chunks/flip.js +2 -2
- package/dist/chunks/fx.js +2 -2
- package/dist/chunks/gl.js +2 -2
- package/dist/chunks/glsl.js +2 -2
- package/dist/chunks/glyphs.js +2 -0
- package/dist/chunks/inspect.js +2 -2
- package/dist/chunks/instances.js +2 -2
- package/dist/chunks/layers.js +2 -2
- package/dist/chunks/licence.js +2 -2
- package/dist/chunks/morph.js +2 -2
- package/dist/chunks/pace.js +2 -0
- package/dist/chunks/patch.js +2 -2
- package/dist/chunks/prepared.js +2 -2
- package/dist/chunks/profiler.js +2 -2
- package/dist/chunks/recheck.js +2 -0
- package/dist/chunks/resize.js +2 -0
- package/dist/chunks/restore.js +2 -2
- package/dist/chunks/shapes.js +2 -2
- package/dist/chunks/sim.js +2 -2
- package/dist/chunks/text.js +2 -2
- package/dist/chunks/video.js +2 -2
- package/dist/chunks/vocabulary.js +2 -2
- package/dist/chunks/warm.js +2 -2
- package/dist/modules/debug.js +2 -2
- package/dist/modules/debug.mjs +2 -2
- package/dist/modules/handoff.js +2 -2
- package/dist/modules/handoff.mjs +2 -2
- package/dist/modules/input.js +2 -2
- package/dist/modules/input.mjs +2 -2
- package/dist/modules/scrollfx.js +2 -2
- package/dist/modules/scrollfx.mjs +2 -2
- package/dist/modules/scrub.js +2 -2
- package/dist/modules/scrub.mjs +2 -2
- package/dist/modules/three.js +2 -2
- package/dist/modules/three.mjs +2 -2
- package/dist/node/assets.mjs +4 -2
- package/dist/node/astro.mjs +26 -18
- package/dist/node/cli.mjs +63 -10
- package/dist/node/shared-P6KINBNR.mjs +2113 -0
- package/dist/node/{shared-4FIU6DYP.mjs → shared-VQKZUUXF.mjs} +106 -17
- package/dist/node/vite.mjs +7 -3
- package/dist/prepared.mjs +2 -0
- package/dist/umber.css +1 -1
- package/dist/umber.js +2 -2
- package/dist/umber.mjs +2 -2
- package/docs/AI-quick.md +43 -87
- package/docs/AI.md +1965 -1828
- package/docs/npm.md +13 -16
- package/package.json +31 -48
- package/types/assets.d.ts +109 -4
- package/types/astro.d.ts +20 -23
- package/types/debug.d.ts +1 -1
- package/types/esm.d.ts +2 -6
- package/types/input.d.ts +3 -3
- package/types/loop.d.ts +21 -9
- package/types/module.d.ts +0 -2
- package/types/scrollfx.d.ts +5 -41
- package/types/scrub.d.ts +2 -2
- package/types/three.d.ts +26 -1
- package/types/umber.d.ts +152 -155
- package/types/vite.d.ts +3 -3
- package/dist/chunks/views.js +0 -2
- package/dist/frameworks/astro.mjs +0 -2
- package/dist/frameworks/react.mjs +0 -2
- package/dist/frameworks/svelte.mjs +0 -2
- package/dist/frameworks/vue.mjs +0 -2
- package/dist/modules/router-swap.js +0 -2
- package/dist/modules/router.js +0 -2
- package/dist/modules/router.mjs +0 -2
- package/dist/modules/scroll-more.js +0 -2
- package/dist/modules/scroll-touch.js +0 -2
- package/dist/modules/scroll.js +0 -2
- package/dist/modules/scroll.mjs +0 -2
- package/dist/node/shared-3Q24RNIF.mjs +0 -602
- package/types/react.d.ts +0 -15
- package/types/router.d.ts +0 -223
- package/types/scroll.d.ts +0 -190
- package/types/svelte.d.ts +0 -16
- package/types/vue.d.ts +0 -14
package/dist/node/astro.mjs
CHANGED
|
@@ -1,47 +1,55 @@
|
|
|
1
|
-
/*! Umber v0.
|
|
1
|
+
/*! Umber v0.4.0 asset tool | (c) Ravi Klaassens | UNLICENSED */
|
|
2
2
|
import {
|
|
3
|
+
builtEngine,
|
|
3
4
|
umberChunks,
|
|
5
|
+
umberDevChunks,
|
|
6
|
+
umberNeeds,
|
|
4
7
|
umberShaders
|
|
5
|
-
} from "./shared-
|
|
8
|
+
} from "./shared-VQKZUUXF.mjs";
|
|
6
9
|
import {
|
|
7
|
-
|
|
8
|
-
} from "./shared-
|
|
10
|
+
prepareBuilt
|
|
11
|
+
} from "./shared-P6KINBNR.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 = [
|
|
25
|
-
|
|
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
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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.
|
|
2
|
+
/*! Umber v0.4.0 asset tool | (c) Ravi Klaassens | UNLICENSED */
|
|
3
3
|
import {
|
|
4
4
|
prepareSite
|
|
5
|
-
} from "./shared-
|
|
5
|
+
} from "./shared-P6KINBNR.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
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
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
|
|
81
|
-
if (!
|
|
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
|
-
|
|
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();
|