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