@wix/himalaya-cli 0.878.0 → 0.880.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/cli.mjs +117 -11
- package/package.json +2 -2
package/dist/cli.mjs
CHANGED
|
@@ -37688,6 +37688,8 @@ var init_kits = __esm({
|
|
|
37688
37688
|
// ../../core/dev-server/src/widgets.ts
|
|
37689
37689
|
var widgets_exports = {};
|
|
37690
37690
|
__export(widgets_exports, {
|
|
37691
|
+
MAX_PRODUCE_CACHE_ENTRIES: () => MAX_PRODUCE_CACHE_ENTRIES,
|
|
37692
|
+
PRODUCE_CACHE_TTL_MS: () => PRODUCE_CACHE_TTL_MS,
|
|
37691
37693
|
WIDGET_BUDGET_MS: () => WIDGET_BUDGET_MS,
|
|
37692
37694
|
buildViewSnapshot: () => buildViewSnapshot,
|
|
37693
37695
|
buildWidgetSnapshot: () => buildWidgetSnapshot,
|
|
@@ -37695,6 +37697,7 @@ __export(widgets_exports, {
|
|
|
37695
37697
|
extractWidgets: () => extractWidgets,
|
|
37696
37698
|
freezeOverrideSnapshot: () => freezeOverrideSnapshot,
|
|
37697
37699
|
frozenViewManifestEntries: () => frozenViewManifestEntries,
|
|
37700
|
+
resetWidgetProduceCache: () => resetWidgetProduceCache,
|
|
37698
37701
|
resetWidgetRealm: () => resetWidgetRealm,
|
|
37699
37702
|
viewWidgetId: () => viewWidgetId,
|
|
37700
37703
|
widgetRealm: () => widgetRealm
|
|
@@ -37723,6 +37726,84 @@ async function widgetRealm() {
|
|
|
37723
37726
|
function resetWidgetRealm() {
|
|
37724
37727
|
realmPromise = null;
|
|
37725
37728
|
}
|
|
37729
|
+
function guestClock(clock) {
|
|
37730
|
+
return clock === void 0 ? void 0 : Math.trunc(clock);
|
|
37731
|
+
}
|
|
37732
|
+
function serializedServices(produced) {
|
|
37733
|
+
try {
|
|
37734
|
+
return JSON.stringify(produced.services) ?? void 0;
|
|
37735
|
+
} catch {
|
|
37736
|
+
return void 0;
|
|
37737
|
+
}
|
|
37738
|
+
}
|
|
37739
|
+
function resetWidgetProduceCache() {
|
|
37740
|
+
produceCacheGeneration++;
|
|
37741
|
+
}
|
|
37742
|
+
function realmProduceCache(evaluator) {
|
|
37743
|
+
const existing = produceCache.get(evaluator);
|
|
37744
|
+
if (!existing) {
|
|
37745
|
+
const fresh = { generation: produceCacheGeneration, entries: /* @__PURE__ */ new Map(), bytes: 0 };
|
|
37746
|
+
produceCache.set(evaluator, fresh);
|
|
37747
|
+
return fresh;
|
|
37748
|
+
}
|
|
37749
|
+
if (existing.generation !== produceCacheGeneration) {
|
|
37750
|
+
existing.entries.clear();
|
|
37751
|
+
existing.bytes = 0;
|
|
37752
|
+
existing.generation = produceCacheGeneration;
|
|
37753
|
+
}
|
|
37754
|
+
return existing;
|
|
37755
|
+
}
|
|
37756
|
+
function dropEntry(cache, key2) {
|
|
37757
|
+
const entry = cache.entries.get(key2);
|
|
37758
|
+
if (!entry) return;
|
|
37759
|
+
cache.entries.delete(key2);
|
|
37760
|
+
cache.bytes -= entry.bytes;
|
|
37761
|
+
}
|
|
37762
|
+
function produceCacheKey(bundleJs, timeoutMs, clock) {
|
|
37763
|
+
const digest2 = createHash14("sha256").update(bundleJs).digest("base64");
|
|
37764
|
+
return `${timeoutMs}|${clock === void 0 ? "live" : Math.trunc(clock)}|${digest2}`;
|
|
37765
|
+
}
|
|
37766
|
+
function cachedProduce(evaluator, key2) {
|
|
37767
|
+
const cache = realmProduceCache(evaluator);
|
|
37768
|
+
const hit = cache.entries.get(key2);
|
|
37769
|
+
if (!hit) return void 0;
|
|
37770
|
+
if (Date.now() >= hit.expiresAt) {
|
|
37771
|
+
dropEntry(cache, key2);
|
|
37772
|
+
return void 0;
|
|
37773
|
+
}
|
|
37774
|
+
cache.entries.delete(key2);
|
|
37775
|
+
cache.entries.set(key2, hit);
|
|
37776
|
+
return { services: JSON.parse(hit.servicesJson), envelope: hit.envelope };
|
|
37777
|
+
}
|
|
37778
|
+
function rememberProduce(evaluator, key2, servicesJson, envelope, expiresAt) {
|
|
37779
|
+
const bytes2 = envelope.length + servicesJson.length;
|
|
37780
|
+
if (bytes2 > MAX_PRODUCE_ENTRY_BYTES) return;
|
|
37781
|
+
const cache = realmProduceCache(evaluator);
|
|
37782
|
+
dropEntry(cache, key2);
|
|
37783
|
+
cache.entries.set(key2, { servicesJson, envelope, expiresAt, bytes: bytes2 });
|
|
37784
|
+
cache.bytes += bytes2;
|
|
37785
|
+
const over = () => cache.entries.size > MAX_PRODUCE_CACHE_ENTRIES || cache.bytes > MAX_PRODUCE_CACHE_BYTES;
|
|
37786
|
+
if (!over()) return;
|
|
37787
|
+
const now = Date.now();
|
|
37788
|
+
for (const [k, entry] of [...cache.entries]) {
|
|
37789
|
+
if (!over()) break;
|
|
37790
|
+
if (k !== key2 && now >= entry.expiresAt) dropEntry(cache, k);
|
|
37791
|
+
}
|
|
37792
|
+
while (over()) {
|
|
37793
|
+
const oldest = cache.entries.keys().next();
|
|
37794
|
+
if (oldest.done || oldest.value === key2) break;
|
|
37795
|
+
dropEntry(cache, oldest.value);
|
|
37796
|
+
}
|
|
37797
|
+
}
|
|
37798
|
+
function reuseWindowMs(parsed) {
|
|
37799
|
+
let window2 = PRODUCE_CACHE_TTL_MS;
|
|
37800
|
+
for (const raw of [...parsed.widgets ?? [], ...parsed.views ?? []]) {
|
|
37801
|
+
const ttl2 = parseJsonField(raw.refresh)?.ttlSeconds;
|
|
37802
|
+
if (typeof ttl2 !== "number" || !Number.isFinite(ttl2) || ttl2 <= 0) continue;
|
|
37803
|
+
window2 = Math.min(window2, ttl2 * 1e3);
|
|
37804
|
+
}
|
|
37805
|
+
return window2;
|
|
37806
|
+
}
|
|
37726
37807
|
function viewRenderModes() {
|
|
37727
37808
|
const out = {};
|
|
37728
37809
|
for (const target of [...SURFACE_GROUPS, ...PREVIEW_SURFACES.map((s) => s.id)]) {
|
|
@@ -37925,7 +38006,30 @@ function parseJsonField(value) {
|
|
|
37925
38006
|
}
|
|
37926
38007
|
}
|
|
37927
38008
|
async function extractWidgets(bundleJs, opts = {}) {
|
|
37928
|
-
const
|
|
38009
|
+
const evaluator = opts.evaluator ?? await widgetRealm();
|
|
38010
|
+
const timeoutMs = opts.timeoutMs ?? WIDGET_BUDGET_MS;
|
|
38011
|
+
const clock = guestClock(opts.clock);
|
|
38012
|
+
const key2 = produceCacheKey(bundleJs, timeoutMs, clock);
|
|
38013
|
+
const cached3 = cachedProduce(evaluator, key2);
|
|
38014
|
+
const produced = cached3 ?? runProduce(evaluator, bundleJs, timeoutMs, clock);
|
|
38015
|
+
let parsed;
|
|
38016
|
+
try {
|
|
38017
|
+
parsed = JSON.parse(produced.envelope);
|
|
38018
|
+
} catch (err) {
|
|
38019
|
+
throw new Error(`the widget producer's realm returned a malformed envelope: ${describeThrown(err)}`);
|
|
38020
|
+
}
|
|
38021
|
+
let services = produced.services;
|
|
38022
|
+
if (!cached3) {
|
|
38023
|
+
const servicesJson = serializedServices(produced);
|
|
38024
|
+
if (servicesJson !== void 0) {
|
|
38025
|
+
services = JSON.parse(servicesJson);
|
|
38026
|
+
rememberProduce(evaluator, key2, servicesJson, produced.envelope, Date.now() + reuseWindowMs(parsed));
|
|
38027
|
+
}
|
|
38028
|
+
}
|
|
38029
|
+
return interpretProduce(services, parsed);
|
|
38030
|
+
}
|
|
38031
|
+
function runProduce(evaluator, bundleJs, timeoutMs, clock) {
|
|
38032
|
+
const services = /* @__PURE__ */ Object.create(null);
|
|
37929
38033
|
let envelope;
|
|
37930
38034
|
const inert = makeInert2();
|
|
37931
38035
|
const himalayaTarget = {
|
|
@@ -37967,21 +38071,17 @@ async function extractWidgets(bundleJs, opts = {}) {
|
|
|
37967
38071
|
}
|
|
37968
38072
|
};
|
|
37969
38073
|
sandbox.globalThis = sandbox;
|
|
37970
|
-
|
|
37971
|
-
|
|
37972
|
-
timeoutMs: opts.timeoutMs ?? WIDGET_BUDGET_MS,
|
|
38074
|
+
evaluator.run(widgetProgram(bundleJs, clock), sandbox, {
|
|
38075
|
+
timeoutMs,
|
|
37973
38076
|
filename: "widget-bundle.js",
|
|
37974
38077
|
captureConsole: false
|
|
37975
38078
|
});
|
|
37976
38079
|
if (envelope === void 0) {
|
|
37977
38080
|
throw new Error("the widget producer's realm returned no registrations envelope");
|
|
37978
38081
|
}
|
|
37979
|
-
|
|
37980
|
-
|
|
37981
|
-
|
|
37982
|
-
} catch (err) {
|
|
37983
|
-
throw new Error(`the widget producer's realm returned a malformed envelope: ${describeThrown(err)}`);
|
|
37984
|
-
}
|
|
38082
|
+
return { services, envelope };
|
|
38083
|
+
}
|
|
38084
|
+
function interpretProduce(services, parsed) {
|
|
37985
38085
|
const widgets = {};
|
|
37986
38086
|
for (const raw of parsed.widgets ?? []) {
|
|
37987
38087
|
widgets[String(raw.id)] = {
|
|
@@ -38240,7 +38340,7 @@ function freezeOverrideSnapshot(input, opts = {}) {
|
|
|
38240
38340
|
}
|
|
38241
38341
|
return snapshot2;
|
|
38242
38342
|
}
|
|
38243
|
-
var MAX_TIMELINE_FRAMES, WIDGET_BUDGET_MS, realmPromise, CAPTURE_SLOT, READBACK_SERVICE;
|
|
38343
|
+
var MAX_TIMELINE_FRAMES, WIDGET_BUDGET_MS, realmPromise, PRODUCE_CACHE_TTL_MS, MAX_PRODUCE_CACHE_ENTRIES, MAX_PRODUCE_ENTRY_BYTES, MAX_PRODUCE_CACHE_BYTES, produceCache, produceCacheGeneration, CAPTURE_SLOT, READBACK_SERVICE;
|
|
38244
38344
|
var init_widgets = __esm({
|
|
38245
38345
|
"../../core/dev-server/src/widgets.ts"() {
|
|
38246
38346
|
init_validator();
|
|
@@ -38248,6 +38348,12 @@ var init_widgets = __esm({
|
|
|
38248
38348
|
MAX_TIMELINE_FRAMES = 48;
|
|
38249
38349
|
WIDGET_BUDGET_MS = 5e3;
|
|
38250
38350
|
realmPromise = null;
|
|
38351
|
+
PRODUCE_CACHE_TTL_MS = 6e4;
|
|
38352
|
+
MAX_PRODUCE_CACHE_ENTRIES = 2048;
|
|
38353
|
+
MAX_PRODUCE_ENTRY_BYTES = 4 * 1024 * 1024;
|
|
38354
|
+
MAX_PRODUCE_CACHE_BYTES = 64 * 1024 * 1024;
|
|
38355
|
+
produceCache = /* @__PURE__ */ new WeakMap();
|
|
38356
|
+
produceCacheGeneration = 0;
|
|
38251
38357
|
CAPTURE_SLOT = "himi.widget.capture";
|
|
38252
38358
|
READBACK_SERVICE = "himi.widget.readback";
|
|
38253
38359
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/himalaya-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.880.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "himi — the Himalaya authoring CLI. Build a Tier-5 content package on your own machine, push it to the production serve as a draft, preview it on web + Himi Player, and read worker logs back — the remote dev loop. Wraps @himalaya/serve-cli for transport.",
|
|
6
6
|
"keywords": [
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"artifactId": "himalaya-cli"
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
|
-
"falconPackageHash": "
|
|
66
|
+
"falconPackageHash": "ef087e28bd7651f75f109ba701d8602c5b59ee6fe462bb2616c6802a"
|
|
67
67
|
}
|