@wix/himalaya-cli 0.965.0 → 0.967.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.
|
@@ -4,6 +4,14 @@ export * from "./wix-gateway.rules.js";
|
|
|
4
4
|
export interface WixGatewayState {
|
|
5
5
|
mode: WixGatewayMode;
|
|
6
6
|
rules: WixMockRule[];
|
|
7
|
+
/** An OPERATOR replaced the rules or the mode through `/__dev/{wix,net}/*`.
|
|
8
|
+
*
|
|
9
|
+
* Read by the date-rollover re-seed (net-mocks-rollover.ts), which must not
|
|
10
|
+
* regenerate what a person pushed: seeding from the app's scenario reassigns
|
|
11
|
+
* `rules` wholesale AND forces `mode` back to the declared one, so an operator
|
|
12
|
+
* watching real traffic in `record` mode would have both silently reverted at
|
|
13
|
+
* midnight with only a "re-seeded N rule(s)" line on stderr. */
|
|
14
|
+
operatorOverride?: boolean;
|
|
7
15
|
traffic: WixTrafficEvent[];
|
|
8
16
|
clients: Set<ServerResponse>;
|
|
9
17
|
seq: number;
|
package/dist/cli.mjs
CHANGED
|
@@ -15337,7 +15337,10 @@ data: ${JSON.stringify({ mode: gw.mode })}
|
|
|
15337
15337
|
if (suffix === "mode" && method === "POST") {
|
|
15338
15338
|
try {
|
|
15339
15339
|
const { mode } = JSON.parse(await readBody(req));
|
|
15340
|
-
if (mode === "record" || mode === "mock")
|
|
15340
|
+
if (mode === "record" || mode === "mock") {
|
|
15341
|
+
gw.mode = mode;
|
|
15342
|
+
gw.operatorOverride = true;
|
|
15343
|
+
}
|
|
15341
15344
|
} catch {
|
|
15342
15345
|
}
|
|
15343
15346
|
return json(res, 200, { ok: true, mode: gw.mode }), true;
|
|
@@ -15349,6 +15352,7 @@ data: ${JSON.stringify({ mode: gw.mode })}
|
|
|
15349
15352
|
try {
|
|
15350
15353
|
const { rules } = JSON.parse(await readBody(req));
|
|
15351
15354
|
gw.rules = Array.isArray(rules) ? rules.map((r) => ({ ...r, id: r.id || ++gw.ruleSeq })) : [];
|
|
15355
|
+
gw.operatorOverride = true;
|
|
15352
15356
|
} catch {
|
|
15353
15357
|
return json(res, 400, { error: "invalid_json" }), true;
|
|
15354
15358
|
}
|
|
@@ -17042,6 +17046,59 @@ var init_tier4_verifier = __esm({
|
|
|
17042
17046
|
}
|
|
17043
17047
|
});
|
|
17044
17048
|
|
|
17049
|
+
// ../../core/dev-server/src/net-mocks-rollover.ts
|
|
17050
|
+
function todayYmd(now = /* @__PURE__ */ new Date()) {
|
|
17051
|
+
const utc = now.toISOString().slice(0, 10);
|
|
17052
|
+
let local = utc;
|
|
17053
|
+
try {
|
|
17054
|
+
const parts = new Intl.DateTimeFormat("en-CA", { year: "numeric", month: "2-digit", day: "2-digit" }).formatToParts(now);
|
|
17055
|
+
const get = (t) => parts.find((x) => x.type === t)?.value ?? "";
|
|
17056
|
+
const assembled = `${get("year")}-${get("month")}-${get("day")}`;
|
|
17057
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(assembled)) local = assembled;
|
|
17058
|
+
} catch {
|
|
17059
|
+
}
|
|
17060
|
+
return local > utc ? local : utc;
|
|
17061
|
+
}
|
|
17062
|
+
async function reseedIfDayChanged(host, today = todayYmd()) {
|
|
17063
|
+
if (!host.seededFromApp) return { reseeded: false, reason: "not-from-app" };
|
|
17064
|
+
if (host.wix.operatorOverride) return { reseeded: false, reason: "operator-override" };
|
|
17065
|
+
const from = host.seededOn;
|
|
17066
|
+
if (!from || from === today) return { reseeded: false, reason: "same-day" };
|
|
17067
|
+
const reload = await host.reloadAppModule("net-mocks date rollover");
|
|
17068
|
+
if (!reload.ok) return { reseeded: false, reason: "reload-failed" };
|
|
17069
|
+
if (host.wix.operatorOverride) return { reseeded: false, reason: "operator-override" };
|
|
17070
|
+
const declared = host.declaredRules();
|
|
17071
|
+
if (!declared?.rules?.length) {
|
|
17072
|
+
const before = { mode: host.wix.mode, rules: [...host.wix.rules] };
|
|
17073
|
+
host.seed({ mode: declared ? declared.mode : "record", rules: [] });
|
|
17074
|
+
if (scenarioChanged(before, { mode: host.wix.mode, rules: host.wix.rules })) {
|
|
17075
|
+
host.publishConfigInvalidated("net-mocks scenario removed");
|
|
17076
|
+
}
|
|
17077
|
+
host.seededOn = today;
|
|
17078
|
+
return { reseeded: false, reason: "no-rules" };
|
|
17079
|
+
}
|
|
17080
|
+
host.seed({ mode: declared.mode, rules: declared.rules });
|
|
17081
|
+
host.seededOn = today;
|
|
17082
|
+
host.publishConfigInvalidated("net-mocks date rollover");
|
|
17083
|
+
return { reseeded: true, rules: declared.rules.length, from, to: today };
|
|
17084
|
+
}
|
|
17085
|
+
function scenarioChanged(before, after) {
|
|
17086
|
+
if (before.mode !== after.mode) return true;
|
|
17087
|
+
if (before.rules.length !== after.rules.length) return true;
|
|
17088
|
+
return serialise(before.rules) !== serialise(after.rules);
|
|
17089
|
+
}
|
|
17090
|
+
function serialise(rules) {
|
|
17091
|
+
return JSON.stringify(rules.map((r) => {
|
|
17092
|
+
if (!r || typeof r !== "object") return r;
|
|
17093
|
+
const { id: _id, ...rest } = r;
|
|
17094
|
+
return rest;
|
|
17095
|
+
}));
|
|
17096
|
+
}
|
|
17097
|
+
var init_net_mocks_rollover = __esm({
|
|
17098
|
+
"../../core/dev-server/src/net-mocks-rollover.ts"() {
|
|
17099
|
+
}
|
|
17100
|
+
});
|
|
17101
|
+
|
|
17045
17102
|
// ../../core/dev-server/src/player-proxy.ts
|
|
17046
17103
|
function isPlayerHost(appName) {
|
|
17047
17104
|
return appName === PLAYER_APP_ID || process.env.HIMALAYA_DEV_MULTI_APP === "1";
|
|
@@ -30890,7 +30947,66 @@ function applyTopBarDefault(descriptor, config) {
|
|
|
30890
30947
|
if (!fallback || own2) return descriptor;
|
|
30891
30948
|
return { ...descriptor, topBar: fallback };
|
|
30892
30949
|
}
|
|
30893
|
-
|
|
30950
|
+
function syncNetMocksWithApp(state) {
|
|
30951
|
+
if (!state.wixSeededFromApp || state.wix.operatorOverride) return;
|
|
30952
|
+
const declared = state.app?.meta.devGateway;
|
|
30953
|
+
const next = declared?.rules ?? [];
|
|
30954
|
+
const before = { mode: state.wix.mode, rules: state.wix.rules };
|
|
30955
|
+
const beforeSnapshot = { mode: before.mode, rules: JSON.parse(JSON.stringify(before.rules)) };
|
|
30956
|
+
applyNetMocks(state.wix, { mode: declared?.mode, rules: next });
|
|
30957
|
+
state.wixSeededOn = todayYmd();
|
|
30958
|
+
state.wixReseedBackoffUntil = 0;
|
|
30959
|
+
if (scenarioChanged(beforeSnapshot, { mode: state.wix.mode, rules: state.wix.rules })) {
|
|
30960
|
+
publishSSE(state, "config.invalidated", { reason: "net-mocks scenario changed", at: Date.now() });
|
|
30961
|
+
console.error(`[himalaya-dev] net-mocks: re-synced ${next.length} rule(s) after an app reload`);
|
|
30962
|
+
}
|
|
30963
|
+
}
|
|
30964
|
+
async function maybeReseedNetMocks(state) {
|
|
30965
|
+
if (state.wixReseedInFlight) return state.wixReseedInFlight;
|
|
30966
|
+
if (!state.wixSeededFromApp || !state.wixSeededOn || state.wixSeededOn === todayYmd()) return;
|
|
30967
|
+
if (Date.now() < (state.wixReseedBackoffUntil ?? 0)) return;
|
|
30968
|
+
const run2 = reseedNetMocksNow(state).finally(() => {
|
|
30969
|
+
state.wixReseedInFlight = void 0;
|
|
30970
|
+
});
|
|
30971
|
+
state.wixReseedInFlight = run2;
|
|
30972
|
+
return run2;
|
|
30973
|
+
}
|
|
30974
|
+
async function reseedNetMocksNow(state) {
|
|
30975
|
+
const outcome = await reseedIfDayChanged({
|
|
30976
|
+
wix: state.wix,
|
|
30977
|
+
declaredRules: () => state.app?.meta.devGateway,
|
|
30978
|
+
reloadAppModule: (reason) => reloadAppModule(state, { reason }),
|
|
30979
|
+
seed: (mocks) => {
|
|
30980
|
+
applyNetMocks(state.wix, mocks);
|
|
30981
|
+
},
|
|
30982
|
+
publishConfigInvalidated: (reason) => publishSSE(state, "config.invalidated", { reason, at: Date.now() }),
|
|
30983
|
+
get seededOn() {
|
|
30984
|
+
return state.wixSeededOn;
|
|
30985
|
+
},
|
|
30986
|
+
set seededOn(day) {
|
|
30987
|
+
state.wixSeededOn = day;
|
|
30988
|
+
},
|
|
30989
|
+
seededFromApp: state.wixSeededFromApp
|
|
30990
|
+
});
|
|
30991
|
+
if (outcome.reseeded) {
|
|
30992
|
+
console.error(`[himalaya-dev] net-mocks: re-seeded ${outcome.rules} rule(s) \u2014 the date turned (${outcome.from} \u2192 ${outcome.to})`);
|
|
30993
|
+
return;
|
|
30994
|
+
}
|
|
30995
|
+
if (outcome.reason === "reload-failed" || outcome.reason === "no-rules") {
|
|
30996
|
+
state.wixReseedBackoffUntil = Date.now() + 6e4;
|
|
30997
|
+
console.error(outcome.reason === "reload-failed" ? "[himalaya-dev] net-mocks: the date turned but the app module would not reload \u2014 keeping yesterday's rules, retrying in a minute" : "[himalaya-dev] net-mocks: the date turned and the app now declares no scenario \u2014 cleared the stale rules, re-checking in a minute");
|
|
30998
|
+
}
|
|
30999
|
+
}
|
|
31000
|
+
function reloadAppModule(state, opts) {
|
|
31001
|
+
const run2 = appReloadChain.then(
|
|
31002
|
+
() => reloadAppModuleNow(state, opts),
|
|
31003
|
+
() => reloadAppModuleNow(state, opts)
|
|
31004
|
+
// a previous failure must not block the queue
|
|
31005
|
+
);
|
|
31006
|
+
appReloadChain = run2.catch(() => void 0);
|
|
31007
|
+
return run2;
|
|
31008
|
+
}
|
|
31009
|
+
async function reloadAppModuleNow(state, opts) {
|
|
30894
31010
|
const current = state.app;
|
|
30895
31011
|
if (!current) return { ok: false, error: "no_app" };
|
|
30896
31012
|
const entry = resolve30(current.dir, "dev/index.ts");
|
|
@@ -30912,6 +31028,7 @@ async function reloadAppModule(state, opts) {
|
|
|
30912
31028
|
meta: deriveAppMeta(current.name, next, readPlatformsJson(current.dir)),
|
|
30913
31029
|
dir: current.dir
|
|
30914
31030
|
};
|
|
31031
|
+
syncNetMocksWithApp(state);
|
|
30915
31032
|
if (opts.recreateStore) {
|
|
30916
31033
|
try {
|
|
30917
31034
|
state.moduleStore?.close?.();
|
|
@@ -32350,12 +32467,16 @@ function createDevServer(opts = {}) {
|
|
|
32350
32467
|
);
|
|
32351
32468
|
if (resolved2) {
|
|
32352
32469
|
const seeded = applyNetMocks(state.wix, resolved2.mocks);
|
|
32470
|
+
state.wixSeededOn = todayYmd();
|
|
32471
|
+
state.wixSeededFromApp = resolved2.source !== "file";
|
|
32353
32472
|
const from = resolved2.source === "file" ? netMocksPath : `${state.appName} devGateway.rules`;
|
|
32354
32473
|
console.error(`[himalaya-dev] net-mocks: seeded ${seeded.rules} rule(s), mode=${seeded.mode} from ${from}`);
|
|
32355
32474
|
}
|
|
32356
32475
|
const appScenario = state.app?.meta.devGateway;
|
|
32357
32476
|
if (!netMocksDisabled && appScenario?.rules?.length && state.wix.rules.length === 0) {
|
|
32358
32477
|
const seeded = applyNetMocks(state.wix, { mode: appScenario.mode, rules: appScenario.rules });
|
|
32478
|
+
state.wixSeededOn = todayYmd();
|
|
32479
|
+
state.wixSeededFromApp = true;
|
|
32359
32480
|
console.error(`[himalaya-dev] net-mocks: seeded ${seeded.rules} rule(s), mode=${seeded.mode} from the app's devGateway scenario`);
|
|
32360
32481
|
}
|
|
32361
32482
|
if (state.hotReloadEnabled) {
|
|
@@ -32387,6 +32508,7 @@ function createDevServer(opts = {}) {
|
|
|
32387
32508
|
if (req.method === "HEAD") req.method = "GET";
|
|
32388
32509
|
void (async () => {
|
|
32389
32510
|
try {
|
|
32511
|
+
await maybeReseedNetMocks(state);
|
|
32390
32512
|
if (url.startsWith("/__dev/")) return await handleDev(req, res, state);
|
|
32391
32513
|
if (url.split("?")[0] === "/v1/app-icon" && req.method === "GET") {
|
|
32392
32514
|
const iconApp = new URLSearchParams(url.split("?")[1] ?? "").get("app") ?? "";
|
|
@@ -32751,7 +32873,7 @@ ${err.message}`);
|
|
|
32751
32873
|
});
|
|
32752
32874
|
return httpServer;
|
|
32753
32875
|
}
|
|
32754
|
-
var ROOT6, TIER3_ROOT, TIER4_ROOT, tier4Verifier, TIER5_ROOT2, ACTION_HANDLERS_ROOT, SAMPLES_ROOT, TELEMETRY_BUFFER_CAP, overrideHistorySeq, CACHE_CONTROL, TIER5_SRC_ROOT, HMR_TMP_DIR, appReloadSeq, WEBWIX_CLIENT_ID, WEBWIX_REDIRECT, WEBWIX_COOKIE, webOwnerPreviewInstances, MIME, widgetOverrides;
|
|
32876
|
+
var ROOT6, TIER3_ROOT, TIER4_ROOT, tier4Verifier, TIER5_ROOT2, ACTION_HANDLERS_ROOT, SAMPLES_ROOT, TELEMETRY_BUFFER_CAP, overrideHistorySeq, CACHE_CONTROL, TIER5_SRC_ROOT, HMR_TMP_DIR, appReloadSeq, appReloadChain, WEBWIX_CLIENT_ID, WEBWIX_REDIRECT, WEBWIX_COOKIE, webOwnerPreviewInstances, MIME, widgetOverrides;
|
|
32755
32877
|
var init_src6 = __esm({
|
|
32756
32878
|
"../../core/dev-server/src/index.ts"() {
|
|
32757
32879
|
init_inject();
|
|
@@ -32771,6 +32893,7 @@ var init_src6 = __esm({
|
|
|
32771
32893
|
init_preview();
|
|
32772
32894
|
init_tier4_verifier();
|
|
32773
32895
|
init_loader();
|
|
32896
|
+
init_net_mocks_rollover();
|
|
32774
32897
|
init_tier5_dir();
|
|
32775
32898
|
init_contained_dev_module();
|
|
32776
32899
|
init_player_proxy();
|
|
@@ -32801,6 +32924,7 @@ var init_src6 = __esm({
|
|
|
32801
32924
|
TIER5_SRC_ROOT = resolve30(ROOT6, "core/dev-server/tier5-bundles-src");
|
|
32802
32925
|
HMR_TMP_DIR = resolve30(ROOT6, "node_modules/.cache/himalaya-hmr");
|
|
32803
32926
|
appReloadSeq = 0;
|
|
32927
|
+
appReloadChain = Promise.resolve();
|
|
32804
32928
|
WEBWIX_CLIENT_ID = process.env.DEMO_APP_WIX_CLIENT_ID ?? "4f58d461-c1f5-4a5d-a467-62cc2329e4dd";
|
|
32805
32929
|
WEBWIX_REDIRECT = "himalaya-demo-app://oauth/callback";
|
|
32806
32930
|
WEBWIX_COOKIE = "himi_webwix_session";
|
|
@@ -43357,19 +43481,19 @@ var init_preview_assets_generated = __esm({
|
|
|
43357
43481
|
"../../packages/serve/src/preview-assets.generated.ts"() {
|
|
43358
43482
|
init_preview_assets_format();
|
|
43359
43483
|
PREVIEW_ASSET_MANIFEST = [
|
|
43360
|
-
{ key: "assets/index-
|
|
43361
|
-
{ key: "fonts/WixMadeforDisplay-Bold.ttf", contentType: "font/ttf", offset:
|
|
43362
|
-
{ key: "fonts/WixMadeforDisplay-ExtraBold.ttf", contentType: "font/ttf", offset:
|
|
43363
|
-
{ key: "fonts/WixMadeforDisplay-Medium.ttf", contentType: "font/ttf", offset:
|
|
43364
|
-
{ key: "fonts/WixMadeforDisplay-Regular.ttf", contentType: "font/ttf", offset:
|
|
43365
|
-
{ key: "fonts/WixMadeforDisplay-SemiBold.ttf", contentType: "font/ttf", offset:
|
|
43366
|
-
{ key: "fonts/WixMadeforText-Bold.ttf", contentType: "font/ttf", offset:
|
|
43367
|
-
{ key: "fonts/WixMadeforText-ExtraBold.ttf", contentType: "font/ttf", offset:
|
|
43368
|
-
{ key: "fonts/WixMadeforText-Medium.ttf", contentType: "font/ttf", offset:
|
|
43369
|
-
{ key: "fonts/WixMadeforText-Regular.ttf", contentType: "font/ttf", offset:
|
|
43370
|
-
{ key: "fonts/WixMadeforText-SemiBold.ttf", contentType: "font/ttf", offset:
|
|
43371
|
-
{ key: "index.html", contentType: "text/html; charset=utf-8", offset:
|
|
43372
|
-
{ key: "t5-frame.html", contentType: "text/html; charset=utf-8", offset:
|
|
43484
|
+
{ key: "assets/index-Dlirkows.js", contentType: "application/javascript; charset=utf-8", offset: 8, length: 985462, sha256: "b9aba518df2120a652af435c0f5f6d6b3770c54e2807220aa96b617953d08427" },
|
|
43485
|
+
{ key: "fonts/WixMadeforDisplay-Bold.ttf", contentType: "font/ttf", offset: 985470, length: 90924, sha256: "ec4c7d63772d980d6e147b2df6215fd2737e4b04cebe0cf7e11dc695fb63cdcf" },
|
|
43486
|
+
{ key: "fonts/WixMadeforDisplay-ExtraBold.ttf", contentType: "font/ttf", offset: 1076394, length: 90984, sha256: "bf4c16a2774edd38a921edf3099469866cd74c094fd596f3fa4e81f54a04dfaa" },
|
|
43487
|
+
{ key: "fonts/WixMadeforDisplay-Medium.ttf", contentType: "font/ttf", offset: 1167378, length: 90980, sha256: "368faca44fb9f7207e4af784e94750b1ee59c1098b8689e0f4a918926f244fb5" },
|
|
43488
|
+
{ key: "fonts/WixMadeforDisplay-Regular.ttf", contentType: "font/ttf", offset: 1258358, length: 90872, sha256: "97ed8f1a6772abe26e3d8af5cecfc4b02faa94497d585b0398b5053b739a70c1" },
|
|
43489
|
+
{ key: "fonts/WixMadeforDisplay-SemiBold.ttf", contentType: "font/ttf", offset: 1349230, length: 90980, sha256: "642feab8a48ddf6c7a89d7c2a7c0edfa0e6e773f671287e460e222703563191e" },
|
|
43490
|
+
{ key: "fonts/WixMadeforText-Bold.ttf", contentType: "font/ttf", offset: 1440210, length: 108636, sha256: "37c179b4fefb63ea9637322b84583a2df53aa226c150294eea1675c14b1b8e29" },
|
|
43491
|
+
{ key: "fonts/WixMadeforText-ExtraBold.ttf", contentType: "font/ttf", offset: 1548846, length: 109084, sha256: "62e2fe4718129f36ecdb0ae4de385bd6b81ecc876146447167c6c140fad699a9" },
|
|
43492
|
+
{ key: "fonts/WixMadeforText-Medium.ttf", contentType: "font/ttf", offset: 1657930, length: 109048, sha256: "4ecf270136af928612c76fe4ebade91d8156975e5ea4c0cf9225501dd1788e02" },
|
|
43493
|
+
{ key: "fonts/WixMadeforText-Regular.ttf", contentType: "font/ttf", offset: 1766978, length: 107700, sha256: "dee56f09fd3efc127c1ea95557edc74110c1460a46287da36e0af25efd341ef5" },
|
|
43494
|
+
{ key: "fonts/WixMadeforText-SemiBold.ttf", contentType: "font/ttf", offset: 1874678, length: 88108, sha256: "dced97a77624bc5f8b1ae65850360908297f4588e09feb6f22792d29dc7e765b" },
|
|
43495
|
+
{ key: "index.html", contentType: "text/html; charset=utf-8", offset: 1962786, length: 4448, sha256: "c41d62befc7517ad7b5ce19a8a3fb7673842e3a8f1b0e62b5db653676a333bfc" },
|
|
43496
|
+
{ key: "t5-frame.html", contentType: "text/html; charset=utf-8", offset: 1967234, length: 13784, sha256: "cfb9465254fab84f0e084bb4542c282758ea29774b5f172840cc0b9e4194ef89" }
|
|
43373
43497
|
];
|
|
43374
43498
|
}
|
|
43375
43499
|
});
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/himalaya-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.967.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": [
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"artifactId": "himalaya-cli"
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
|
-
"falconPackageHash": "
|
|
67
|
+
"falconPackageHash": "21a64fc457cad496774edeab407735299722e76708687a0a3a6dcaaf"
|
|
68
68
|
}
|