@wix/himalaya-cli 0.1864.0 → 0.1865.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 +107 -5
- package/package.json +2 -2
package/dist/cli.mjs
CHANGED
|
@@ -4452,7 +4452,6 @@ var init_himi_package = __esm({
|
|
|
4452
4452
|
var ICON_VIEW_BOX, ICON_STROKE_WIDTH, ICON_FALLBACK, ICON_CATALOG, ICON_NORMALIZED_INDEX, ICON_NAMES;
|
|
4453
4453
|
var init_icon_catalog_generated = __esm({
|
|
4454
4454
|
"../../core/ts/src/icon-catalog.generated.ts"() {
|
|
4455
|
-
"use strict";
|
|
4456
4455
|
init_define_HHP_CATALOG();
|
|
4457
4456
|
ICON_VIEW_BOX = 24;
|
|
4458
4457
|
ICON_STROKE_WIDTH = 2;
|
|
@@ -278627,6 +278626,104 @@ var init_header_badges_cli = __esm({
|
|
|
278627
278626
|
}
|
|
278628
278627
|
});
|
|
278629
278628
|
|
|
278629
|
+
// src/one-app/media-size.ts
|
|
278630
|
+
function wixRenditionUrl(url, opaquePngs = /* @__PURE__ */ new Set()) {
|
|
278631
|
+
const media = BARE_WIX_MEDIA.exec(url);
|
|
278632
|
+
if (!media) return url;
|
|
278633
|
+
if (media[1].toLowerCase() === "png" && !opaquePngs.has(url)) return url;
|
|
278634
|
+
return `${url}/v1/fit/w_${IMAGE_CEILING_PX},h_${IMAGE_CEILING_PX},q_${QUALITY}/image.jpg`;
|
|
278635
|
+
}
|
|
278636
|
+
function pngIsOpaque(head2) {
|
|
278637
|
+
if (head2.length < COLOR_TYPE_BYTES) return false;
|
|
278638
|
+
if (!PNG_SIGNATURE2.every((byte2, i2) => head2[i2] === byte2)) return false;
|
|
278639
|
+
if (String.fromCharCode(...head2.subarray(12, 16)) !== "IHDR") return false;
|
|
278640
|
+
return OPAQUE_COLOR_TYPES.has(head2[25]);
|
|
278641
|
+
}
|
|
278642
|
+
function barePngUrls(raw) {
|
|
278643
|
+
const found = /* @__PURE__ */ new Set();
|
|
278644
|
+
const add = (value2) => {
|
|
278645
|
+
if (typeof value2 === "string" && /\.png$/i.test(value2) && BARE_WIX_MEDIA.test(value2)) found.add(value2);
|
|
278646
|
+
};
|
|
278647
|
+
const record5 = (value2) => value2 && typeof value2 === "object" && !Array.isArray(value2) ? value2 : {};
|
|
278648
|
+
const sections2 = record5(record5(raw).sections);
|
|
278649
|
+
for (const section3 of Object.values(sections2)) {
|
|
278650
|
+
const settings = record5(record5(section3).settings);
|
|
278651
|
+
add(record5(settings.data).url);
|
|
278652
|
+
add(settings.imageUri);
|
|
278653
|
+
if (Array.isArray(settings.items)) for (const item2 of settings.items) add(record5(item2).imageUrl);
|
|
278654
|
+
}
|
|
278655
|
+
return [...found];
|
|
278656
|
+
}
|
|
278657
|
+
async function readRange(fetchAsset, url, start2, length2, signal) {
|
|
278658
|
+
const response = await fetchAsset(url, { headers: { range: `bytes=${start2}-${start2 + length2 - 1}` }, signal, redirect: "error" });
|
|
278659
|
+
const reader = response.body?.getReader();
|
|
278660
|
+
try {
|
|
278661
|
+
if (!reader || !response.ok || start2 > 0 && response.status !== 206) return null;
|
|
278662
|
+
const bytes2 = new Uint8Array(length2);
|
|
278663
|
+
let filled2 = 0;
|
|
278664
|
+
while (filled2 < length2) {
|
|
278665
|
+
const { done, value: value2 } = await reader.read();
|
|
278666
|
+
if (done || !value2) break;
|
|
278667
|
+
const take = Math.min(value2.length, length2 - filled2);
|
|
278668
|
+
bytes2.set(value2.subarray(0, take), filled2);
|
|
278669
|
+
filled2 += take;
|
|
278670
|
+
}
|
|
278671
|
+
return bytes2.subarray(0, filled2);
|
|
278672
|
+
} finally {
|
|
278673
|
+
await (reader ? reader.cancel() : response.body?.cancel())?.catch(() => void 0);
|
|
278674
|
+
}
|
|
278675
|
+
}
|
|
278676
|
+
async function isOpaquePng(fetchAsset, url, signal) {
|
|
278677
|
+
const head2 = await readRange(fetchAsset, url, 0, FIRST_CHUNK_AT, signal);
|
|
278678
|
+
if (!head2 || head2.length < FIRST_CHUNK_AT || !pngIsOpaque(head2)) return false;
|
|
278679
|
+
let offset = FIRST_CHUNK_AT;
|
|
278680
|
+
for (let chunk2 = 0; chunk2 < MAX_CHUNKS; chunk2++) {
|
|
278681
|
+
const header2 = await readRange(fetchAsset, url, offset, 8, signal);
|
|
278682
|
+
if (!header2 || header2.length < 8) return false;
|
|
278683
|
+
const type2 = String.fromCharCode(...header2.subarray(4, 8));
|
|
278684
|
+
if (type2 === "tRNS" || type2 === "acTL") return false;
|
|
278685
|
+
if (type2 === "IDAT") return true;
|
|
278686
|
+
offset += 12 + new DataView(header2.buffer, header2.byteOffset, 4).getUint32(0);
|
|
278687
|
+
}
|
|
278688
|
+
return false;
|
|
278689
|
+
}
|
|
278690
|
+
async function opaquePngUrls(urls, fetchAsset, limits = PROBE_LIMITS) {
|
|
278691
|
+
const opaque2 = /* @__PURE__ */ new Set();
|
|
278692
|
+
const queue = urls.slice(0, limits.maxPngs);
|
|
278693
|
+
const started = Date.now();
|
|
278694
|
+
const probe2 = async (url) => {
|
|
278695
|
+
const deadline = AbortSignal.timeout(limits.perPngMs);
|
|
278696
|
+
const expired = new Promise((resolve135) => deadline.addEventListener("abort", () => resolve135(false), { once: true }));
|
|
278697
|
+
try {
|
|
278698
|
+
if (await Promise.race([isOpaquePng(fetchAsset, url, deadline), expired])) opaque2.add(url);
|
|
278699
|
+
} catch {
|
|
278700
|
+
}
|
|
278701
|
+
};
|
|
278702
|
+
const worker = async () => {
|
|
278703
|
+
for (let url = queue.shift(); url !== void 0; url = queue.shift()) {
|
|
278704
|
+
if (Date.now() - started >= limits.totalMs) return;
|
|
278705
|
+
await probe2(url);
|
|
278706
|
+
}
|
|
278707
|
+
};
|
|
278708
|
+
await Promise.all(Array.from({ length: Math.min(limits.concurrency, queue.length) }, worker));
|
|
278709
|
+
return opaque2;
|
|
278710
|
+
}
|
|
278711
|
+
var IMAGE_CEILING_PX, QUALITY, BARE_WIX_MEDIA, OPAQUE_COLOR_TYPES, PNG_SIGNATURE2, FIRST_CHUNK_AT, COLOR_TYPE_BYTES, MAX_CHUNKS, PROBE_LIMITS;
|
|
278712
|
+
var init_media_size = __esm({
|
|
278713
|
+
"src/one-app/media-size.ts"() {
|
|
278714
|
+
init_define_HHP_CATALOG();
|
|
278715
|
+
IMAGE_CEILING_PX = 2048;
|
|
278716
|
+
QUALITY = 85;
|
|
278717
|
+
BARE_WIX_MEDIA = /^https:\/\/static\.wixstatic\.com\/media\/[^/?#]+\.(png|jpe?g)$/i;
|
|
278718
|
+
OPAQUE_COLOR_TYPES = /* @__PURE__ */ new Set([0, 2]);
|
|
278719
|
+
PNG_SIGNATURE2 = [137, 80, 78, 71, 13, 10, 26, 10];
|
|
278720
|
+
FIRST_CHUNK_AT = 33;
|
|
278721
|
+
COLOR_TYPE_BYTES = 26;
|
|
278722
|
+
MAX_CHUNKS = 16;
|
|
278723
|
+
PROBE_LIMITS = { concurrency: 6, perPngMs: 15e3, totalMs: 3e4, maxPngs: 200 };
|
|
278724
|
+
}
|
|
278725
|
+
});
|
|
278726
|
+
|
|
278630
278727
|
// src/one-app/recipes.ts
|
|
278631
278728
|
import { existsSync as existsSync156, readFileSync as readFileSync185 } from "node:fs";
|
|
278632
278729
|
import { join as join199 } from "node:path";
|
|
@@ -279251,6 +279348,7 @@ function generateScreens(input) {
|
|
|
279251
279348
|
page: { label: label4, screenId, layoutItemId },
|
|
279252
279349
|
taken: taken2,
|
|
279253
279350
|
hasScreen: (id) => !input.takenScreenIds || input.takenScreenIds.has(id),
|
|
279351
|
+
imageUrl: (url) => wixRenditionUrl(url, input.opaquePngs),
|
|
279254
279352
|
uses: (module, key4, opts) => {
|
|
279255
279353
|
if (input.hasModule && !input.hasModule(MODULES[module].file)) throw new RecipeError(`tier5-src/_shared/${MODULES[module].file}.ts is missing: this scaffold does not ship that module, so the section keeps its title and a See All link.`);
|
|
279256
279354
|
const svc = `himiPage_${screenId}_${key4}`;
|
|
@@ -279615,6 +279713,7 @@ var init_generate2 = __esm({
|
|
|
279615
279713
|
init_podcast();
|
|
279616
279714
|
init_tab_ids();
|
|
279617
279715
|
init_events_section();
|
|
279716
|
+
init_media_size();
|
|
279618
279717
|
TEMPLATE_HOME_SCREEN = "himi_branded_home";
|
|
279619
279718
|
TEMPLATE_SCREEN_PARAM_KEYS = {
|
|
279620
279719
|
himi_shop: ["categoryId"],
|
|
@@ -279932,7 +280031,7 @@ var init_generate2 = __esm({
|
|
|
279932
280031
|
if (tap) modifiers.onTap = tap;
|
|
279933
280032
|
}
|
|
279934
280033
|
return vstack(`${id}.box`, [node2(id, "Image", {
|
|
279935
|
-
url,
|
|
280034
|
+
url: ctx.imageUrl(url),
|
|
279936
280035
|
fillWidth: true,
|
|
279937
280036
|
...typeof data.aspectRatio === "number" ? { aspectRatio: data.aspectRatio } : {},
|
|
279938
280037
|
contentMode: st2.displayMode === "fit" ? "fit" : "fill",
|
|
@@ -280000,7 +280099,7 @@ var init_generate2 = __esm({
|
|
|
280000
280099
|
if (!title && !url) return [];
|
|
280001
280100
|
const parts = [];
|
|
280002
280101
|
if (url) parts.push(node2(`${id}.i${i2}.img`, "Image", {
|
|
280003
|
-
url,
|
|
280102
|
+
url: ctx.imageUrl(url),
|
|
280004
280103
|
fillWidth: true,
|
|
280005
280104
|
...typeof options2.aspectRatio === "number" ? { aspectRatio: options2.aspectRatio } : {},
|
|
280006
280105
|
contentMode: options2.imageScale === "fit" ? "fit" : "fill",
|
|
@@ -280020,7 +280119,7 @@ var init_generate2 = __esm({
|
|
|
280020
280119
|
const tap = sourceTap(obj16(st2.action), ctx.hasScreen);
|
|
280021
280120
|
const align = st2.horizontalAlign === "center" ? "center" : st2.horizontalAlign === "right" ? "trailing" : "leading";
|
|
280022
280121
|
const picture = url ? node2(`${id}.img`, "Image", {
|
|
280023
|
-
url,
|
|
280122
|
+
url: ctx.imageUrl(url),
|
|
280024
280123
|
fillWidth: true,
|
|
280025
280124
|
...typeof st2.aspectRatio === "number" ? { aspectRatio: st2.aspectRatio } : {},
|
|
280026
280125
|
contentMode: "fill",
|
|
@@ -281244,9 +281343,10 @@ async function runOneAppGenerate(args, io2) {
|
|
|
281244
281343
|
} catch {
|
|
281245
281344
|
return report8(io2, false, { code: "content_invalid", error: "himalaya.content.json not found or unreadable: --content must be a Himi content package." });
|
|
281246
281345
|
}
|
|
281346
|
+
const opaquePngs = await opaquePngUrls(barePngUrls(raw), pinnedFetch);
|
|
281247
281347
|
let result;
|
|
281248
281348
|
try {
|
|
281249
|
-
result = generateScreens({ raw, pages: pages2, business, navigation, takenScreenIds: taken2, ...homeScreenId ? { homeScreenId } : {}, recipe: (name, values) => readRecipe(options2.contentDir, name, values), recipeNodes: (name, values) => readRecipeNodes(options2.contentDir, name, values), hasModule: (file2) => existsSync159(join202(options2.contentDir, "tier5-src", "_shared", `${file2}.ts`)) });
|
|
281349
|
+
result = generateScreens({ raw, pages: pages2, business, opaquePngs, navigation, takenScreenIds: taken2, ...homeScreenId ? { homeScreenId } : {}, recipe: (name, values) => readRecipe(options2.contentDir, name, values), recipeNodes: (name, values) => readRecipeNodes(options2.contentDir, name, values), hasModule: (file2) => existsSync159(join202(options2.contentDir, "tier5-src", "_shared", `${file2}.ts`)) });
|
|
281250
281350
|
} catch (error) {
|
|
281251
281351
|
if (error instanceof RecipeError) return report8(io2, false, { code: "recipe_unavailable", error: error.message });
|
|
281252
281352
|
throw error;
|
|
@@ -281351,6 +281451,8 @@ var init_generate_cli = __esm({
|
|
|
281351
281451
|
"src/one-app/generate-cli.ts"() {
|
|
281352
281452
|
init_define_HHP_CATALOG();
|
|
281353
281453
|
init_validate_topbar();
|
|
281454
|
+
init_media_size();
|
|
281455
|
+
init_net_guard();
|
|
281354
281456
|
init_generate2();
|
|
281355
281457
|
init_recipes();
|
|
281356
281458
|
init_provision();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/himalaya-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1865.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": [
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"artifactId": "himalaya-cli"
|
|
83
83
|
}
|
|
84
84
|
},
|
|
85
|
-
"falconPackageHash": "
|
|
85
|
+
"falconPackageHash": "52f2f21e056cb1d7ad13a65bd8c4bcdb94b21555be411dc9b25d6b91"
|
|
86
86
|
}
|