@aethervtt/shard-procgen 0.0.1 → 0.1.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/dist/runtime.d.ts +3 -1
- package/dist/runtime.js +21 -10
- package/package.json +12 -12
package/dist/runtime.d.ts
CHANGED
|
@@ -99,6 +99,8 @@ export declare class ProcgenRuntime {
|
|
|
99
99
|
/** Imported dependencies' artifacts and hashes, by guid (valid while the version matches). */
|
|
100
100
|
private readonly artifacts;
|
|
101
101
|
private pendingDeps;
|
|
102
|
+
/** Regenerations under way, by guid: the code hash and dependency versions each started for. */
|
|
103
|
+
private readonly regenerating;
|
|
102
104
|
constructor(world: World, options?: ProcgenOptions);
|
|
103
105
|
configure(options: ProcgenOptions): this;
|
|
104
106
|
/** The output entry of a request (label '' or a sub-asset like 'LOD1'), registered lazily. */
|
|
@@ -130,7 +132,7 @@ export declare class ProcgenRuntime {
|
|
|
130
132
|
/**
|
|
131
133
|
* Regenerates loaded outputs whose generator's code hash changed (or whose generator was
|
|
132
134
|
* redefined) and those whose dependencies reloaded. They swap in place when ready; returns their
|
|
133
|
-
* paths.
|
|
135
|
+
* paths. One already regenerating for the current code and dependencies isn't stale.
|
|
134
136
|
*/
|
|
135
137
|
regenerateStale(): string[];
|
|
136
138
|
/** Jobs running now, for procgen.describe. */
|
package/dist/runtime.js
CHANGED
|
@@ -14,6 +14,7 @@ import { loadNoiseKernel } from "@aethervtt/shard-noise";
|
|
|
14
14
|
import { LogResource } from "@aethervtt/shard-runtime";
|
|
15
15
|
import {
|
|
16
16
|
codeHashOf,
|
|
17
|
+
findGenerator,
|
|
17
18
|
guidOf,
|
|
18
19
|
identityOf,
|
|
19
20
|
proceduralPath,
|
|
@@ -190,6 +191,8 @@ class ProcgenRuntime {
|
|
|
190
191
|
/** Imported dependencies' artifacts and hashes, by guid (valid while the version matches). */
|
|
191
192
|
artifacts = /* @__PURE__ */ new Map();
|
|
192
193
|
pendingDeps = /* @__PURE__ */ new Set();
|
|
194
|
+
/** Regenerations under way, by guid: the code hash and dependency versions each started for. */
|
|
195
|
+
regenerating = /* @__PURE__ */ new Map();
|
|
193
196
|
constructor(world, options = {}) {
|
|
194
197
|
this.world = world;
|
|
195
198
|
this.server = assetServer(world);
|
|
@@ -456,9 +459,19 @@ class ProcgenRuntime {
|
|
|
456
459
|
regenerate(guid) {
|
|
457
460
|
const entry = this.server.entry(guid);
|
|
458
461
|
if (entry?.state !== "loaded") return;
|
|
459
|
-
|
|
460
|
-
|
|
462
|
+
const live = this.live.get(guid);
|
|
463
|
+
let target;
|
|
464
|
+
const gen = live && findGenerator(live.request.generator);
|
|
465
|
+
if (live && gen) {
|
|
466
|
+
const deps = /* @__PURE__ */ new Map();
|
|
467
|
+
for (const dep of live.deps.keys()) deps.set(dep, this.server.entry(dep)?.version ?? -1);
|
|
468
|
+
target = { codeHash: codeHashOf(gen), deps };
|
|
469
|
+
this.regenerating.set(guid, target);
|
|
470
|
+
}
|
|
471
|
+
const produce = () => this.produceLogged(guid).finally(() => {
|
|
472
|
+
if (this.regenerating.get(guid) === target) this.regenerating.delete(guid);
|
|
461
473
|
});
|
|
474
|
+
this.server.updateVirtual(guid, entry.path, entry.type, produce, { collectable: true });
|
|
462
475
|
}
|
|
463
476
|
regenerateForDeps() {
|
|
464
477
|
const changed = this.pendingDeps;
|
|
@@ -471,20 +484,18 @@ class ProcgenRuntime {
|
|
|
471
484
|
/**
|
|
472
485
|
* Regenerates loaded outputs whose generator's code hash changed (or whose generator was
|
|
473
486
|
* redefined) and those whose dependencies reloaded. They swap in place when ready; returns their
|
|
474
|
-
* paths.
|
|
487
|
+
* paths. One already regenerating for the current code and dependencies isn't stale.
|
|
475
488
|
*/
|
|
476
489
|
regenerateStale() {
|
|
477
490
|
const out = [];
|
|
478
491
|
for (const [guid, live] of this.live) {
|
|
479
492
|
const entry = this.server.entry(guid);
|
|
480
493
|
if (entry?.state !== "loaded") continue;
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
}
|
|
487
|
-
for (const [dep, version] of live.deps) {
|
|
494
|
+
const gen = findGenerator(live.request.generator);
|
|
495
|
+
if (!gen) continue;
|
|
496
|
+
const made = this.regenerating.get(guid) ?? live;
|
|
497
|
+
let stale = codeHashOf(gen) !== made.codeHash;
|
|
498
|
+
for (const [dep, version] of made.deps) {
|
|
488
499
|
if (this.server.entry(dep)?.version !== version) stale = true;
|
|
489
500
|
}
|
|
490
501
|
if (!stale) continue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aethervtt/shard-procgen",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -20,16 +20,16 @@
|
|
|
20
20
|
"README.md"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@aethervtt/shard-assets": "0.0
|
|
24
|
-
"@aethervtt/shard-core": "0.0
|
|
25
|
-
"@aethervtt/shard-mesh": "0.0
|
|
26
|
-
"@aethervtt/shard-noise": "0.0
|
|
27
|
-
"@aethervtt/shard-platform": "0.0
|
|
28
|
-
"@aethervtt/shard-protocol": "0.0
|
|
29
|
-
"@aethervtt/shard-render": "0.0
|
|
30
|
-
"@aethervtt/shard-runtime": "0.0
|
|
31
|
-
"@aethervtt/shard-scene": "0.0
|
|
32
|
-
"@aethervtt/shard-texture": "0.0
|
|
23
|
+
"@aethervtt/shard-assets": "0.1.0",
|
|
24
|
+
"@aethervtt/shard-core": "0.1.0",
|
|
25
|
+
"@aethervtt/shard-mesh": "0.1.0",
|
|
26
|
+
"@aethervtt/shard-noise": "0.1.0",
|
|
27
|
+
"@aethervtt/shard-platform": "0.1.0",
|
|
28
|
+
"@aethervtt/shard-protocol": "0.1.0",
|
|
29
|
+
"@aethervtt/shard-render": "0.1.0",
|
|
30
|
+
"@aethervtt/shard-runtime": "0.1.0",
|
|
31
|
+
"@aethervtt/shard-scene": "0.1.0",
|
|
32
|
+
"@aethervtt/shard-texture": "0.1.0"
|
|
33
33
|
},
|
|
34
34
|
"repository": {
|
|
35
35
|
"type": "git",
|
|
@@ -41,6 +41,6 @@
|
|
|
41
41
|
"provenance": true
|
|
42
42
|
},
|
|
43
43
|
"shard": {
|
|
44
|
-
"buildSha": "
|
|
44
|
+
"buildSha": "8e14c9896f82a3554b156f1ffdd68f2cc3e7d78a"
|
|
45
45
|
}
|
|
46
46
|
}
|