@lotics/cli 0.112.0 → 0.113.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/README.md +7 -4
- package/dist/src/cli.js +161 -54
- package/docs/cli_reference.md +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -156,12 +156,15 @@ The CLI bundles Lotics's own xlsx and docx engines so you can read, write, and e
|
|
|
156
156
|
```bash
|
|
157
157
|
# .xlsx
|
|
158
158
|
lotics xlsx read ./report.xlsx # → JSON of sheets, cells, merges
|
|
159
|
+
lotics xlsx read ./report.xlsx --with-format # …plus each cell's resolved style
|
|
159
160
|
lotics xlsx write ./out.xlsx '{"sheets":[{"name":"S1","cells":{"A1":"Hi","B1":42}}]}'
|
|
160
161
|
# A cell is a bare value, or an object with numFmt / style / formula:
|
|
161
|
-
lotics xlsx write ./out.xlsx '{"sheets":[{"name":"S1",
|
|
162
|
-
"
|
|
163
|
-
"
|
|
164
|
-
|
|
162
|
+
lotics xlsx write ./out.xlsx '{"sheets":[{"name":"S1",
|
|
163
|
+
"colWidths":{"A":34,"B":14}, "rowHeights":{"1":28},
|
|
164
|
+
"cells":{
|
|
165
|
+
"A1":{"value":"Tổng","style":{"fontBold":true}},
|
|
166
|
+
"B1":{"value":1234567,"numFmt":"#,##0"},
|
|
167
|
+
"B2":{"formula":"B1*0.1","numFmt":"#,##0"}}}]}' # unknown keys are rejected, not ignored
|
|
165
168
|
lotics xlsx set-cell ./report.xlsx 'Sheet1!A1' '=SUM(B:B)'
|
|
166
169
|
lotics xlsx add-sheet ./report.xlsx 'Summary'
|
|
167
170
|
lotics xlsx merge ./report.xlsx 'Sheet1!A1:C1'
|
package/dist/src/cli.js
CHANGED
|
@@ -33334,8 +33334,8 @@ var require_utils2 = __commonJS({
|
|
|
33334
33334
|
var { Address } = require_helpers();
|
|
33335
33335
|
var { Prefix, Postfix, Infix, Operators } = require_operators();
|
|
33336
33336
|
var Collection = require_collection();
|
|
33337
|
-
var
|
|
33338
|
-
var
|
|
33337
|
+
var MAX_ROW2 = 1048576;
|
|
33338
|
+
var MAX_COLUMN2 = 16384;
|
|
33339
33339
|
var { NotAllInputParsedException } = require_api();
|
|
33340
33340
|
var Utils = class {
|
|
33341
33341
|
constructor(context) {
|
|
@@ -33564,7 +33564,7 @@ var require_utils2 = __commonJS({
|
|
|
33564
33564
|
// * @return {{ref: {from: {col: number, row: number}, to: {col: number, row: number}}}}
|
|
33565
33565
|
*/
|
|
33566
33566
|
applyRange(refs) {
|
|
33567
|
-
let res, maxRow = -1, maxCol = -1, minRow =
|
|
33567
|
+
let res, maxRow = -1, maxCol = -1, minRow = MAX_ROW2 + 1, minCol = MAX_COLUMN2 + 1;
|
|
33568
33568
|
refs.forEach((ref2) => {
|
|
33569
33569
|
if (this.isFormulaError(ref2))
|
|
33570
33570
|
return ref2;
|
|
@@ -33574,11 +33574,11 @@ var require_utils2 = __commonJS({
|
|
|
33574
33574
|
ref2 = ref2.ref;
|
|
33575
33575
|
if (ref2.row === void 0) {
|
|
33576
33576
|
minRow = 1;
|
|
33577
|
-
maxRow =
|
|
33577
|
+
maxRow = MAX_ROW2;
|
|
33578
33578
|
}
|
|
33579
33579
|
if (ref2.col === void 0) {
|
|
33580
33580
|
minCol = 1;
|
|
33581
|
-
maxCol =
|
|
33581
|
+
maxCol = MAX_COLUMN2;
|
|
33582
33582
|
}
|
|
33583
33583
|
if (ref2.row > maxRow)
|
|
33584
33584
|
maxRow = ref2.row;
|
|
@@ -34014,8 +34014,8 @@ var require_utils3 = __commonJS({
|
|
|
34014
34014
|
var { FormulaHelpers, Types, Address } = require_helpers();
|
|
34015
34015
|
var { Prefix, Postfix, Infix, Operators } = require_operators();
|
|
34016
34016
|
var Collection = require_collection();
|
|
34017
|
-
var
|
|
34018
|
-
var
|
|
34017
|
+
var MAX_ROW2 = 1048576;
|
|
34018
|
+
var MAX_COLUMN2 = 16384;
|
|
34019
34019
|
var Utils = class {
|
|
34020
34020
|
constructor(context) {
|
|
34021
34021
|
this.context = context;
|
|
@@ -34161,7 +34161,7 @@ var require_utils3 = __commonJS({
|
|
|
34161
34161
|
// * @return {{ref: {from: {col: number, row: number}, to: {col: number, row: number}}}}
|
|
34162
34162
|
*/
|
|
34163
34163
|
applyRange(refs) {
|
|
34164
|
-
let res, maxRow = -1, maxCol = -1, minRow =
|
|
34164
|
+
let res, maxRow = -1, maxCol = -1, minRow = MAX_ROW2 + 1, minCol = MAX_COLUMN2 + 1;
|
|
34165
34165
|
refs.forEach((ref2) => {
|
|
34166
34166
|
if (this.isFormulaError(ref2))
|
|
34167
34167
|
return ref2;
|
|
@@ -34171,11 +34171,11 @@ var require_utils3 = __commonJS({
|
|
|
34171
34171
|
ref2 = ref2.ref;
|
|
34172
34172
|
if (ref2.row === void 0) {
|
|
34173
34173
|
minRow = 1;
|
|
34174
|
-
maxRow =
|
|
34174
|
+
maxRow = MAX_ROW2;
|
|
34175
34175
|
}
|
|
34176
34176
|
if (ref2.col === void 0) {
|
|
34177
34177
|
minCol = 1;
|
|
34178
|
-
maxCol =
|
|
34178
|
+
maxCol = MAX_COLUMN2;
|
|
34179
34179
|
}
|
|
34180
34180
|
if (ref2.row > maxRow)
|
|
34181
34181
|
maxRow = ref2.row;
|
|
@@ -44124,9 +44124,9 @@ var require_load = __commonJS({
|
|
|
44124
44124
|
var require_lib4 = __commonJS({
|
|
44125
44125
|
"../../node_modules/jszip/lib/index.js"(exports2, module2) {
|
|
44126
44126
|
"use strict";
|
|
44127
|
-
function
|
|
44128
|
-
if (!(this instanceof
|
|
44129
|
-
return new
|
|
44127
|
+
function JSZip5() {
|
|
44128
|
+
if (!(this instanceof JSZip5)) {
|
|
44129
|
+
return new JSZip5();
|
|
44130
44130
|
}
|
|
44131
44131
|
if (arguments.length) {
|
|
44132
44132
|
throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");
|
|
@@ -44135,7 +44135,7 @@ var require_lib4 = __commonJS({
|
|
|
44135
44135
|
this.comment = null;
|
|
44136
44136
|
this.root = "";
|
|
44137
44137
|
this.clone = function() {
|
|
44138
|
-
var newObj = new
|
|
44138
|
+
var newObj = new JSZip5();
|
|
44139
44139
|
for (var i2 in this) {
|
|
44140
44140
|
if (typeof this[i2] !== "function") {
|
|
44141
44141
|
newObj[i2] = this[i2];
|
|
@@ -44144,16 +44144,16 @@ var require_lib4 = __commonJS({
|
|
|
44144
44144
|
return newObj;
|
|
44145
44145
|
};
|
|
44146
44146
|
}
|
|
44147
|
-
|
|
44148
|
-
|
|
44149
|
-
|
|
44150
|
-
|
|
44151
|
-
|
|
44152
|
-
|
|
44153
|
-
return new
|
|
44147
|
+
JSZip5.prototype = require_object();
|
|
44148
|
+
JSZip5.prototype.loadAsync = require_load();
|
|
44149
|
+
JSZip5.support = require_support();
|
|
44150
|
+
JSZip5.defaults = require_defaults();
|
|
44151
|
+
JSZip5.version = "3.10.1";
|
|
44152
|
+
JSZip5.loadAsync = function(content, options) {
|
|
44153
|
+
return new JSZip5().loadAsync(content, options);
|
|
44154
44154
|
};
|
|
44155
|
-
|
|
44156
|
-
module2.exports =
|
|
44155
|
+
JSZip5.external = require_external();
|
|
44156
|
+
module2.exports = JSZip5;
|
|
44157
44157
|
}
|
|
44158
44158
|
});
|
|
44159
44159
|
|
|
@@ -64462,12 +64462,26 @@ var VALID_OPERATORS = {
|
|
|
64462
64462
|
var VALID_FILTER_TYPES = Object.keys(VALID_OPERATORS);
|
|
64463
64463
|
|
|
64464
64464
|
// ../shared/src/chat_models.ts
|
|
64465
|
-
var
|
|
64466
|
-
var
|
|
64467
|
-
|
|
64468
|
-
|
|
64469
|
-
|
|
64470
|
-
|
|
64465
|
+
var MODEL_TIERS = ["haiku", "sonnet", "opus"];
|
|
64466
|
+
var TIER_MODELS = {
|
|
64467
|
+
haiku: "claude-haiku-4-5",
|
|
64468
|
+
sonnet: "claude-sonnet-5",
|
|
64469
|
+
opus: "claude-opus-5"
|
|
64470
|
+
};
|
|
64471
|
+
var RESOLVED_MODEL_IDS = MODEL_TIERS.map(
|
|
64472
|
+
(tier) => TIER_MODELS[tier]
|
|
64473
|
+
);
|
|
64474
|
+
function tierForModelId(modelId) {
|
|
64475
|
+
for (const tier of MODEL_TIERS) {
|
|
64476
|
+
if (modelId.startsWith(`claude-${tier}-`)) return tier;
|
|
64477
|
+
}
|
|
64478
|
+
return null;
|
|
64479
|
+
}
|
|
64480
|
+
var DEFAULT_MODEL_TIER = "sonnet";
|
|
64481
|
+
var UTILITY_MODEL_TIER = "haiku";
|
|
64482
|
+
var DEFAULT_MODEL_ID = TIER_MODELS[DEFAULT_MODEL_TIER];
|
|
64483
|
+
var PICKER_MODEL_TIERS = MODEL_TIERS.filter(
|
|
64484
|
+
(tier) => tier !== UTILITY_MODEL_TIER
|
|
64471
64485
|
);
|
|
64472
64486
|
var EFFORT_LEVELS = ["low", "medium", "high", "xhigh", "max"];
|
|
64473
64487
|
|
|
@@ -64927,11 +64941,20 @@ var appAgentDeclarationSchema = zod_default.object({
|
|
|
64927
64941
|
workflow_aliases: zod_default.array(zod_default.string().min(1)).optional().describe(
|
|
64928
64942
|
"Workflows from this app's manifest the agent may invoke via `run_app_workflow`, validated at declare time against the app's own workflows. This is the agent's ENTIRE write surface \u2014 the same declared mutation path the app's UI uses, so table hooks and side-effect harvesting apply. Omit for a read-only agent."
|
|
64929
64943
|
),
|
|
64930
|
-
|
|
64931
|
-
"
|
|
64944
|
+
model_tier: zod_default.enum(MODEL_TIERS).optional().describe(
|
|
64945
|
+
"Model tier the agent runs on \u2014 `haiku`, `sonnet`, or `opus`. Omit to follow the platform default tier, resolved at run time: the preferred choice. A tier names capability, not a version, so the generation behind it moves with the platform and this declaration never needs a rewrite. Pin only a deliberate, tested choice."
|
|
64932
64946
|
),
|
|
64947
|
+
/**
|
|
64948
|
+
* LEGACY, read-only. A version pin written by a release from before tiers.
|
|
64949
|
+
* Parsed so a declaration an older release wrote during the rollout window
|
|
64950
|
+
* still resolves (via `tierForModelId`) instead of reading as unpinned
|
|
64951
|
+
* and silently dropping to the default. Never written by this release, and
|
|
64952
|
+
* rejected on the write surface. Deleted with the strip migration, once no
|
|
64953
|
+
* deployed release writes it.
|
|
64954
|
+
*/
|
|
64955
|
+
model_id: zod_default.string().min(1).optional(),
|
|
64933
64956
|
effort_level: zod_default.enum(EFFORT_LEVELS).optional().describe(
|
|
64934
|
-
"Reasoning depth for adaptive-thinking
|
|
64957
|
+
"Reasoning depth for adaptive-thinking tiers \u2014 one of the chosen tier's supported levels (validated against model_tier at declare time). Omit to use the model default; ignored on tiers without adaptive thinking."
|
|
64935
64958
|
),
|
|
64936
64959
|
inputs: zod_default.record(zod_default.string(), appWorkflowInputSchema).optional().describe(
|
|
64937
64960
|
"Typed input schema for one run. Keys are input names; values declare type + constraints. The server validates the run payload against this before invoking; CLI codegen emits a typed `useAgentRun<alias>` signature. Omit for an untyped payload."
|
|
@@ -65070,6 +65093,8 @@ var agentStepSchema = stepBaseSchema.extend({
|
|
|
65070
65093
|
instructions: zod_default.string().min(1),
|
|
65071
65094
|
input: zod_default.record(zod_default.string(), toolInputValueSchema),
|
|
65072
65095
|
tool_names: zod_default.array(zod_default.string().min(1)),
|
|
65096
|
+
model_tier: zod_default.enum(MODEL_TIERS).optional(),
|
|
65097
|
+
/** LEGACY, read-only — see `appAgentDeclarationSchema.model_id`. */
|
|
65073
65098
|
model_id: zod_default.string().min(1).optional(),
|
|
65074
65099
|
output: agentOutputSpecSchema
|
|
65075
65100
|
});
|
|
@@ -69683,8 +69708,6 @@ function walkAgentInvocation(call, scope, stepId, description) {
|
|
|
69683
69708
|
const toolsNode = kw.get("tools");
|
|
69684
69709
|
if (!toolsNode) fail(arg, "agent requires `tools` (use [] for none).");
|
|
69685
69710
|
const tool_names = readStaticStringArray(toolsNode, "agent `tools`");
|
|
69686
|
-
const modelNode = kw.get("model");
|
|
69687
|
-
const model_id = modelNode ? readStaticString(modelNode, "agent `model`") : void 0;
|
|
69688
69711
|
const outputNode = kw.get("output");
|
|
69689
69712
|
if (!outputNode) fail(arg, "agent requires `output`.");
|
|
69690
69713
|
const outputResult = agentOutputSpecSchema.safeParse(walkStaticJsonLiteral(outputNode));
|
|
@@ -69692,6 +69715,19 @@ function walkAgentInvocation(call, scope, stepId, description) {
|
|
|
69692
69715
|
const detail = outputResult.error.issues.map((i2) => `${i2.path.join(".") || "<root>"}: ${i2.message}`).join("; ");
|
|
69693
69716
|
fail(outputNode, `Invalid agent \`output\`: ${detail}`);
|
|
69694
69717
|
}
|
|
69718
|
+
const modelNode = kw.get("model");
|
|
69719
|
+
let model_tier;
|
|
69720
|
+
if (modelNode) {
|
|
69721
|
+
const literal2 = readStaticString(modelNode, "agent `model`");
|
|
69722
|
+
const tier = MODEL_TIERS.includes(literal2) ? literal2 : tierForModelId(literal2);
|
|
69723
|
+
if (!tier) {
|
|
69724
|
+
fail(
|
|
69725
|
+
modelNode,
|
|
69726
|
+
`Unknown agent \`model\` "${literal2}" \u2014 expected one of: ${MODEL_TIERS.join(", ")}.`
|
|
69727
|
+
);
|
|
69728
|
+
}
|
|
69729
|
+
model_tier = tier;
|
|
69730
|
+
}
|
|
69695
69731
|
return {
|
|
69696
69732
|
id: stepId,
|
|
69697
69733
|
description: description ?? "agent",
|
|
@@ -69699,7 +69735,7 @@ function walkAgentInvocation(call, scope, stepId, description) {
|
|
|
69699
69735
|
instructions,
|
|
69700
69736
|
input,
|
|
69701
69737
|
tool_names,
|
|
69702
|
-
...
|
|
69738
|
+
...model_tier !== void 0 ? { model_tier } : {},
|
|
69703
69739
|
output: outputResult.data
|
|
69704
69740
|
};
|
|
69705
69741
|
}
|
|
@@ -83163,6 +83199,8 @@ function buildSheetXml(sheet, styles, ssIndex, isActive, xfMap, numFmtMap, dxfMa
|
|
|
83163
83199
|
}
|
|
83164
83200
|
arr.push({ col: rc.col, cell });
|
|
83165
83201
|
}
|
|
83202
|
+
for (const rowNum of sheet.rowHeights.keys()) if (!rowMap.has(rowNum)) rowMap.set(rowNum, []);
|
|
83203
|
+
for (const rowNum of sheet.hiddenRows) if (!rowMap.has(rowNum)) rowMap.set(rowNum, []);
|
|
83166
83204
|
const sortedRows = Array.from(rowMap.keys()).sort((a, b) => a - b);
|
|
83167
83205
|
for (const rowNum of sortedRows) {
|
|
83168
83206
|
const cells = rowMap.get(rowNum);
|
|
@@ -83319,11 +83357,12 @@ function buildSheetXml(sheet, styles, ssIndex, isActive, xfMap, numFmtMap, dxfMa
|
|
|
83319
83357
|
}
|
|
83320
83358
|
}
|
|
83321
83359
|
let dimensionRef = "A1";
|
|
83322
|
-
|
|
83360
|
+
const cellRows = sortedRows.filter((rowNum) => rowMap.get(rowNum).length > 0);
|
|
83361
|
+
if (cellRows.length > 0) {
|
|
83323
83362
|
let minCol = Infinity, maxCol = 0;
|
|
83324
|
-
const minRow =
|
|
83325
|
-
const maxRow =
|
|
83326
|
-
for (const rowNum of
|
|
83363
|
+
const minRow = cellRows[0];
|
|
83364
|
+
const maxRow = cellRows[cellRows.length - 1];
|
|
83365
|
+
for (const rowNum of cellRows) {
|
|
83327
83366
|
const cells = rowMap.get(rowNum);
|
|
83328
83367
|
for (const { col } of cells) {
|
|
83329
83368
|
if (col < minCol) minCol = col;
|
|
@@ -92919,6 +92958,9 @@ function adjustMergedCellsForColDelete(sheet, atCol, count) {
|
|
|
92919
92958
|
|
|
92920
92959
|
// src/xlsx.ts
|
|
92921
92960
|
var SIMPLE_CELL_KEYS = /* @__PURE__ */ new Set(["value", "formula", "numFmt", "style"]);
|
|
92961
|
+
var SIMPLE_SHEET_KEYS = /* @__PURE__ */ new Set(["name", "cells", "merges", "freeze", "colWidths", "rowHeights"]);
|
|
92962
|
+
var MAX_COLUMN = 16384;
|
|
92963
|
+
var MAX_ROW = 1048576;
|
|
92922
92964
|
function loadFile(filePath) {
|
|
92923
92965
|
if (!fs6.existsSync(filePath)) fail2(`File not found: ${filePath}`);
|
|
92924
92966
|
const buffer = fs6.readFileSync(filePath);
|
|
@@ -92970,7 +93012,7 @@ function lazyEngine(workbook) {
|
|
|
92970
93012
|
}
|
|
92971
93013
|
};
|
|
92972
93014
|
}
|
|
92973
|
-
function readToJson(filePath, filter3) {
|
|
93015
|
+
function readToJson(filePath, filter3, opts) {
|
|
92974
93016
|
const buffer = fs6.readFileSync(filePath);
|
|
92975
93017
|
const arrayBuffer = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
92976
93018
|
const parsed = parseExcelBuffer(arrayBuffer);
|
|
@@ -92989,13 +93031,13 @@ function readToJson(filePath, filter3) {
|
|
|
92989
93031
|
name: s.name,
|
|
92990
93032
|
totalRowCount: s.totalRowCount,
|
|
92991
93033
|
truncated: s.truncated,
|
|
92992
|
-
cells: cellsFromParsedRows(s.rows, filter3?.range),
|
|
93034
|
+
cells: cellsFromParsedRows(s.rows, filter3?.range, opts?.withFormat === true),
|
|
92993
93035
|
merges: s.mergedCells.map((m) => `${rowColToRef(m.startRow, m.startCol)}:${rowColToRef(m.endRow, m.endCol)}`),
|
|
92994
93036
|
freeze: s.freezePane ? { row: s.freezePane.frozenRows, col: s.freezePane.frozenCols } : void 0
|
|
92995
93037
|
}))
|
|
92996
93038
|
};
|
|
92997
93039
|
}
|
|
92998
|
-
function cellsFromParsedRows(rows, range2) {
|
|
93040
|
+
function cellsFromParsedRows(rows, range2, withFormat = false) {
|
|
92999
93041
|
const out = {};
|
|
93000
93042
|
for (const row of rows) {
|
|
93001
93043
|
if (range2 && (row.index < range2.startRow || row.index > range2.endRow)) continue;
|
|
@@ -93005,6 +93047,8 @@ function cellsFromParsedRows(rows, range2) {
|
|
|
93005
93047
|
const value2 = cell.typedValue ?? cell.value;
|
|
93006
93048
|
const entry = { value: value2 };
|
|
93007
93049
|
if (cell.formula) entry.formula = cell.formula;
|
|
93050
|
+
if (cell.numFmtCode && cell.numFmtCode !== "General") entry.numFmt = cell.numFmtCode;
|
|
93051
|
+
if (withFormat && cell.style && Object.keys(cell.style).length > 0) entry.style = cell.style;
|
|
93008
93052
|
out[ref2] = entry;
|
|
93009
93053
|
}
|
|
93010
93054
|
}
|
|
@@ -93025,6 +93069,10 @@ function buildWorkbookFromJson(input) {
|
|
|
93025
93069
|
}
|
|
93026
93070
|
function validateSimpleSheet(s, index) {
|
|
93027
93071
|
if (!s || typeof s !== "object") fail2(`sheets[${index}] must be an object`);
|
|
93072
|
+
const unknown2 = Object.keys(s).filter((k) => !SIMPLE_SHEET_KEYS.has(k));
|
|
93073
|
+
if (unknown2.length > 0) {
|
|
93074
|
+
fail2(`sheets[${index}] has unknown propert${unknown2.length > 1 ? "ies" : "y"}: ${unknown2.join(", ")}. Supported: ${[...SIMPLE_SHEET_KEYS].join(", ")}.`);
|
|
93075
|
+
}
|
|
93028
93076
|
if (typeof s.name !== "string" || s.name === "") fail2(`sheets[${index}].name must be a non-empty string`);
|
|
93029
93077
|
if (s.cells !== void 0 && (typeof s.cells !== "object" || s.cells === null || Array.isArray(s.cells))) {
|
|
93030
93078
|
fail2(`sheets[${index}].cells must be an object keyed by cell ref (e.g. {"A1": "value"})`);
|
|
@@ -93038,6 +93086,23 @@ function validateSimpleSheet(s, index) {
|
|
|
93038
93086
|
fail2(`sheets[${index}].freeze.row and .col must be numbers`);
|
|
93039
93087
|
}
|
|
93040
93088
|
}
|
|
93089
|
+
validateDimensionMap(s.colWidths, `sheets[${index}].colWidths`, "column letter within A..XFD", (k) => {
|
|
93090
|
+
const coord = /^[A-Za-z]+$/.test(k) ? refToRowCol(`${k.toUpperCase()}1`) : void 0;
|
|
93091
|
+
return coord !== void 0 && coord.col <= MAX_COLUMN;
|
|
93092
|
+
});
|
|
93093
|
+
validateDimensionMap(s.rowHeights, `sheets[${index}].rowHeights`, `row number within 1..${MAX_ROW}`, (k) => /^[0-9]+$/.test(k) && Number(k) >= 1 && Number(k) <= MAX_ROW);
|
|
93094
|
+
}
|
|
93095
|
+
function validateDimensionMap(map3, label, keyHint, keyOk) {
|
|
93096
|
+
if (map3 === void 0) return;
|
|
93097
|
+
if (typeof map3 !== "object" || map3 === null || Array.isArray(map3)) {
|
|
93098
|
+
fail2(`${label} must be an object keyed by ${keyHint}`);
|
|
93099
|
+
}
|
|
93100
|
+
for (const [key, value2] of Object.entries(map3)) {
|
|
93101
|
+
if (!keyOk(key)) fail2(`${label} key "${key}" must be a ${keyHint}`);
|
|
93102
|
+
if (typeof value2 !== "number" || !Number.isFinite(value2) || value2 <= 0) {
|
|
93103
|
+
fail2(`${label}["${key}"] must be a positive number`);
|
|
93104
|
+
}
|
|
93105
|
+
}
|
|
93041
93106
|
}
|
|
93042
93107
|
function applySheetCells(workbook, sheetIndex, def) {
|
|
93043
93108
|
const sheet = workbook.sheets[sheetIndex];
|
|
@@ -93070,6 +93135,20 @@ function applySheetCells(workbook, sheetIndex, def) {
|
|
|
93070
93135
|
if (def.freeze) {
|
|
93071
93136
|
sheet.freeze = { row: def.freeze.row, col: def.freeze.col };
|
|
93072
93137
|
}
|
|
93138
|
+
if (def.colWidths) {
|
|
93139
|
+
for (const [letter, width] of Object.entries(def.colWidths)) {
|
|
93140
|
+
const coord = refToRowCol(`${letter.toUpperCase()}1`);
|
|
93141
|
+
if (!coord) fail2(`Invalid column in sheet "${def.name}".colWidths: ${letter}`);
|
|
93142
|
+
sheet.colWidths.set(coord.col, width);
|
|
93143
|
+
}
|
|
93144
|
+
}
|
|
93145
|
+
if (def.rowHeights) {
|
|
93146
|
+
for (const [rowKey, height] of Object.entries(def.rowHeights)) {
|
|
93147
|
+
const row = Number(rowKey);
|
|
93148
|
+
if (!Number.isInteger(row) || row < 1) fail2(`Invalid row in sheet "${def.name}".rowHeights: ${rowKey}`);
|
|
93149
|
+
sheet.rowHeights.set(row, height);
|
|
93150
|
+
}
|
|
93151
|
+
}
|
|
93073
93152
|
}
|
|
93074
93153
|
function normalizeSimpleCell(raw, sheetName, ref2) {
|
|
93075
93154
|
if (raw && typeof raw === "object" && !Array.isArray(raw)) {
|
|
@@ -93100,9 +93179,10 @@ function splitOptionalSheetRef(spec) {
|
|
|
93100
93179
|
return { sheet: spec.slice(0, idx), ref: spec.slice(idx + 1) };
|
|
93101
93180
|
}
|
|
93102
93181
|
function xlsxRead(filePath, rest2) {
|
|
93103
|
-
if (!filePath) fail2("Usage: lotics xlsx read <file> [--sheet <name>] [--range <sheet>!<A1:G60>]");
|
|
93182
|
+
if (!filePath) fail2("Usage: lotics xlsx read <file> [--sheet <name>] [--range <sheet>!<A1:G60>] [--with-format]");
|
|
93104
93183
|
const rangeArg = readOptionFlag(rest2, "--range");
|
|
93105
93184
|
const sheetArg = readOptionFlag(rest2, "--sheet");
|
|
93185
|
+
const withFormat = rest2.includes("--with-format");
|
|
93106
93186
|
let filter3;
|
|
93107
93187
|
if (rangeArg !== void 0) {
|
|
93108
93188
|
const { sheet, ref: ref2 } = splitOptionalSheetRef(rangeArg);
|
|
@@ -93114,7 +93194,7 @@ function xlsxRead(filePath, rest2) {
|
|
|
93114
93194
|
} else if (sheetArg !== void 0) {
|
|
93115
93195
|
filter3 = { sheet: sheetArg };
|
|
93116
93196
|
}
|
|
93117
|
-
const data2 = readToJson(filePath, filter3);
|
|
93197
|
+
const data2 = readToJson(filePath, filter3, { withFormat });
|
|
93118
93198
|
console.log(JSON.stringify(data2, null, 2));
|
|
93119
93199
|
}
|
|
93120
93200
|
function xlsxWrite(filePath, json2) {
|
|
@@ -93351,14 +93431,17 @@ function printXlsxHelp() {
|
|
|
93351
93431
|
console.error(`Lotics xlsx commands \u2014 manipulate .xlsx files in place.
|
|
93352
93432
|
Uses Lotics' own xlsx engine; round-trips faithfully with the Lotics editor and templates.
|
|
93353
93433
|
|
|
93354
|
-
lotics xlsx read <file> [--sheet <name>] [--range <sheet>!<A1:G60>]
|
|
93434
|
+
lotics xlsx read <file> [--sheet <name>] [--range <sheet>!<A1:G60>] [--with-format]
|
|
93355
93435
|
Dump file as JSON (sheets, cells, merges, freeze).
|
|
93356
93436
|
--sheet limits to one sheet; --range to a cell window
|
|
93357
93437
|
(its <sheet>! prefix is optional when --sheet is given)
|
|
93438
|
+
A cell carries numFmt when it has one; --with-format
|
|
93439
|
+
adds the resolved style (always present, hence a flag)
|
|
93358
93440
|
lotics xlsx write <file> '<json>' Create .xlsx from {"sheets":[{"name","cells":{"A1":...}}]}
|
|
93359
93441
|
A cell is a bare value, or {value|formula, numFmt, style}:
|
|
93360
93442
|
{"A1":{"value":1234,"numFmt":"#,##0 \\"\u20AB\\"","style":{"fontBold":true}}}
|
|
93361
|
-
|
|
93443
|
+
A sheet also takes merges, freeze, colWidths ({"A":34}),
|
|
93444
|
+
rowHeights ({"1":44}). Unknown properties are rejected.
|
|
93362
93445
|
lotics xlsx set-cell <file> <sheet>!<ref> '<v>' Set cell value (prefix '=' for formula)
|
|
93363
93446
|
lotics xlsx clear-range <file> <sheet>!<range> Clear all cells in a range
|
|
93364
93447
|
lotics xlsx merge <file> <sheet>!<range> Merge a range into one cell
|
|
@@ -95352,7 +95435,7 @@ function parseLegacyDoc(bytes) {
|
|
|
95352
95435
|
}
|
|
95353
95436
|
|
|
95354
95437
|
// ../ooxml/src/document.ts
|
|
95355
|
-
var
|
|
95438
|
+
var import_jszip2 = __toESM(require_lib4(), 1);
|
|
95356
95439
|
|
|
95357
95440
|
// ../ooxml/node_modules/fast-xml-parser/src/util.js
|
|
95358
95441
|
var nameStartChar2 = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
|
|
@@ -98031,6 +98114,14 @@ async function docModelToDocx(model) {
|
|
|
98031
98114
|
return doc;
|
|
98032
98115
|
}
|
|
98033
98116
|
|
|
98117
|
+
// ../ooxml/src/opc.ts
|
|
98118
|
+
var import_jszip = __toESM(require_lib4(), 1);
|
|
98119
|
+
function dropFolderEntries(zip) {
|
|
98120
|
+
for (const [path8, entry] of Object.entries(zip.files)) {
|
|
98121
|
+
if (entry.dir) delete zip.files[path8];
|
|
98122
|
+
}
|
|
98123
|
+
}
|
|
98124
|
+
|
|
98034
98125
|
// ../ooxml/src/document.ts
|
|
98035
98126
|
var DOCUMENT_ATTRS = {
|
|
98036
98127
|
"@_xmlns:wpc": "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
|
|
@@ -98040,6 +98131,10 @@ var DOCUMENT_ATTRS = {
|
|
|
98040
98131
|
"@_xmlns:m": "http://schemas.openxmlformats.org/officeDocument/2006/math",
|
|
98041
98132
|
"@_xmlns:v": "urn:schemas-microsoft-com:vml",
|
|
98042
98133
|
"@_xmlns:wp": "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",
|
|
98134
|
+
// Declared because mc:Ignorable below names it. Markup Compatibility (ECMA-376 Part 3) requires
|
|
98135
|
+
// every prefix listed there to be a declared namespace prefix; an undeclared one made Word
|
|
98136
|
+
// report unreadable content and offer to repair EVERY document this package wrote.
|
|
98137
|
+
"@_xmlns:wp14": "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",
|
|
98043
98138
|
"@_xmlns:w10": "urn:schemas-microsoft-com:office:word",
|
|
98044
98139
|
"@_xmlns:w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
|
98045
98140
|
"@_xmlns:w14": "http://schemas.microsoft.com/office/word/2010/wordml",
|
|
@@ -98135,7 +98230,7 @@ async function loadDocxFromBuffer(buffer) {
|
|
|
98135
98230
|
if (isLegacyDoc(buffer)) {
|
|
98136
98231
|
return docxFromLegacyDoc(buffer);
|
|
98137
98232
|
}
|
|
98138
|
-
const zip = await
|
|
98233
|
+
const zip = await import_jszip2.default.loadAsync(buffer);
|
|
98139
98234
|
const docFile = zip.file("word/document.xml");
|
|
98140
98235
|
if (!docFile) {
|
|
98141
98236
|
throw new Error("Invalid .docx: missing word/document.xml");
|
|
@@ -98168,19 +98263,30 @@ function withTrailingParagraph(body) {
|
|
|
98168
98263
|
out.splice(lastBlock + 1, 0, { "w:p": [] });
|
|
98169
98264
|
return out;
|
|
98170
98265
|
}
|
|
98266
|
+
function pruneIgnorable(attrs) {
|
|
98267
|
+
const listed = (attrs["@_mc:Ignorable"] ?? "").split(/\s+/).filter(Boolean);
|
|
98268
|
+
if (listed.length === 0) return attrs;
|
|
98269
|
+
const kept = listed.filter((prefix) => `@_xmlns:${prefix}` in attrs);
|
|
98270
|
+
if (kept.length === listed.length) return attrs;
|
|
98271
|
+
const next = { ...attrs };
|
|
98272
|
+
if (kept.length === 0) delete next["@_mc:Ignorable"];
|
|
98273
|
+
else next["@_mc:Ignorable"] = kept.join(" ");
|
|
98274
|
+
return next;
|
|
98275
|
+
}
|
|
98171
98276
|
async function saveDocxToBuffer(doc) {
|
|
98172
98277
|
const bodyChildren = withTrailingParagraph(doc.bodyElements);
|
|
98173
98278
|
const documentEl = {
|
|
98174
98279
|
"w:document": [{ "w:body": bodyChildren }],
|
|
98175
|
-
":@":
|
|
98280
|
+
":@": pruneIgnorable(doc.documentAttrs)
|
|
98176
98281
|
};
|
|
98177
98282
|
const xml = buildXml([documentEl]);
|
|
98178
98283
|
doc.zip.file("word/document.xml", xml);
|
|
98284
|
+
dropFolderEntries(doc.zip);
|
|
98179
98285
|
const buffer = await doc.zip.generateAsync({ type: "nodebuffer", compression: "DEFLATE" });
|
|
98180
98286
|
return buffer;
|
|
98181
98287
|
}
|
|
98182
98288
|
function createBlankDocx(opts) {
|
|
98183
|
-
const zip = new
|
|
98289
|
+
const zip = new import_jszip2.default();
|
|
98184
98290
|
zip.file("[Content_Types].xml", CONTENT_TYPES_XML);
|
|
98185
98291
|
zip.file("_rels/.rels", RELS_XML);
|
|
98186
98292
|
zip.file("word/_rels/document.xml.rels", DOCUMENT_RELS_XML);
|
|
@@ -98239,9 +98345,9 @@ async function ensureContentTypeOverride(doc, partName, contentType) {
|
|
|
98239
98345
|
}
|
|
98240
98346
|
|
|
98241
98347
|
// ../docx/src/parse/parser.ts
|
|
98242
|
-
var
|
|
98348
|
+
var import_jszip3 = __toESM(require_lib4(), 1);
|
|
98243
98349
|
async function parseDocx(buffer) {
|
|
98244
|
-
const zip = await
|
|
98350
|
+
const zip = await import_jszip3.default.loadAsync(buffer);
|
|
98245
98351
|
const parts = /* @__PURE__ */ new Map();
|
|
98246
98352
|
const filePromises = [];
|
|
98247
98353
|
zip.forEach((path8, file2) => {
|
|
@@ -98376,7 +98482,7 @@ function parseOpaqueRunChild(el) {
|
|
|
98376
98482
|
}
|
|
98377
98483
|
|
|
98378
98484
|
// ../docx/src/serialize/serializer.ts
|
|
98379
|
-
var
|
|
98485
|
+
var import_jszip4 = __toESM(require_lib4(), 1);
|
|
98380
98486
|
|
|
98381
98487
|
// ../docx/src/serialize/default_parts.ts
|
|
98382
98488
|
var encoder = new TextEncoder();
|
|
@@ -98490,7 +98596,7 @@ function fillDefaultParts(parts) {
|
|
|
98490
98596
|
|
|
98491
98597
|
// ../docx/src/serialize/serializer.ts
|
|
98492
98598
|
async function serializeDocx(doc) {
|
|
98493
|
-
const zip = new
|
|
98599
|
+
const zip = new import_jszip4.default();
|
|
98494
98600
|
const parts = fillDefaultParts(new Map(doc.parts));
|
|
98495
98601
|
for (const [path8, bytes] of parts) {
|
|
98496
98602
|
if (path8 === "word/document.xml") continue;
|
|
@@ -98498,6 +98604,7 @@ async function serializeDocx(doc) {
|
|
|
98498
98604
|
}
|
|
98499
98605
|
const documentXml = serializeDocumentXml(doc);
|
|
98500
98606
|
zip.file("word/document.xml", documentXml);
|
|
98607
|
+
dropFolderEntries(zip);
|
|
98501
98608
|
const out = await zip.generateAsync({
|
|
98502
98609
|
type: "uint8array",
|
|
98503
98610
|
compression: "DEFLATE"
|
package/docs/cli_reference.md
CHANGED
|
@@ -45,7 +45,7 @@ Per-command syntax, flags, contracts, and gotchas for the public `lotics` CLI. S
|
|
|
45
45
|
| `lotics app rename "<new name>"` | Change the app's display name (launcher/title) via the `update_app` tool. app_id comes from the local `package.json` manifest; the public address (`subdomain`) and code (`deploy`) are unchanged. |
|
|
46
46
|
| `lotics app dev [path] [--port=N] [--vite-port=N] [--view-as=<member_id>]` | Spawn Vite dev server + an RPC-forwarding HTTP server. The wrapper page embeds the iframe with `sandbox="allow-scripts allow-same-origin"` matching production; postMessage ops (query / workflow / members / context / upload / openExternal / urlState / agentRun) are forwarded to api.lotics.ai using the CLI's API key — file bytes move in **both** directions through the dev server's own relays, never browser↔storage: dev runs against the PROD bucket, whose CORS admits `https://*.lotics.app` and not `http://localhost:<port>`, so a direct browser transfer is blocked — no upload could complete and no preview engine (PDF/Word/Excel all FETCH the bytes) could read a file. `upload` mints a presigned URL and PUTs it **to `PUT /_upload/<file_id>`** (`dev/upload_relay.ts`) from the wrapper page — same-origin, so no preflight and no CORS — and Node forwards it on; every presigned `url`/`thumbnail_url`/`preview_url` on a **file object** in an RPC result is rewritten to **`GET /_file/<token>`** (`dev/file_relay.ts`, absolute — the iframe would resolve a relative path against Vite), which streams the bytes back with `Range` passthrough (206s intact, so PDF seeking works) and an `Access-Control-Allow-Origin` for the Vite origin (the one cross-origin hop left is OUR response to allow). Neither relay ever takes a destination from the client — it gets a `file_id`/token and transfers only to/from a URL it minted or observed itself, so there is no client-controlled target and no SSRF surface. A URL in a record's own text cell is NOT rewritten. Production is unchanged (direct-to-storage, no bytes through the API server); `openExternal` and `urlState.get/set` are handled locally (the latter read/write the wrapper page's own address bar — `set` writes in place via `replaceState` and browser back/forward broadcast a `url-state` message back, so `useUrlState` survives refresh and is shareable in the dev loop; in-app *routing* is the app's own (the iframe owns its url via `@lotics/app-sdk/router`), and the wrapper bakes the saved screen (`_loc`) into the iframe src on load so a refresh restores it, mirroring production); `agentRun` (streaming) is proxied through `POST /_agent_run`, which opens the run's SSE with the CLI key and pipes chunks back to the iframe (`stream-chunk`* → `stream-end`), so `useAgentRun` works in the dev loop just like production; `context` resolves the viewer (`member_id` from `cli/whoami` + `comments_enabled` from the local manifest) and fetches the installation's stored `config` live from the app row, so `useConfig()` renders the same values as production. `--view-as` (global flag; also `LOTICS_VIEW_AS`) threads `x-view-as-member-id` so `is_current_member` + `context` resolve to that member — **admin key only** (the server 403s a non-admin), writes stay attributed to the key owner. Hot reload via Vite; full DevTools / Playwright access via plain localhost. The dev-optimizer pre-bundle list (`optimizeDeps.include`, load-bearing for dev) is imported from `@lotics/ui/vite` (`loticsOptimizeDeps`) rather than hardcoded in the scaffold, so it tracks the installed `@lotics/ui` and can never go stale. Binds **loopback only** (`127.0.0.1`) — `/_rpc` dispatches with the developer's API key, so a socket on every interface would hand anyone on the network full read/write on the workspace. |
|
|
47
47
|
| `LOTICS_UI_SRC=<abs path to packages/ui/src>` (env, not a command) | Dev-link `@lotics/ui` to a monorepo checkout for the length of ONE command, **for every tool at once**. The app's `vite.config.ts` gets its whole `resolve` block from the kit (`resolve: loticsResolve()` — `@lotics/ui/vite`), which reads the variable at call time and adds the `@lotics/ui/*` → working-copy alias, so kit edits go live under `lotics app dev` (HMR) and bundle under `lotics app deploy`. In the same breath, every command that regenerates types (`create`/`pull`/`dev`/`deploy`/`codegen`, all via `writeAppDts`) writes **`.lotics/tsconfig.link.json`** — the matching `paths`, which the app's `tsconfig.json` `extends` — so `tsc`, vitest, eslint and your EDITOR resolve the same copy Vite does. Unset ⇒ every one of them goes back to `node_modules`, and the generated file is rewritten inert. **Why `paths` and not `npm link`:** the kit ships un-built `.tsx`, so a kit file outside `node_modules` resolves its OWN `react`/`react-native` from the monorepo — two copies in one program and every shared type stops matching ("Two different types with this name exist, but they are unrelated"). The generated file therefore also pins every peer @lotics/ui declares to the APP's copy, types-package first (`react` → `@types/react`; pinning the runtime package instead strands tsc on a `.js` with no declarations). The pin set is derived from the installed kit's `peerDependencies`, so it tracks the kit rather than rotting. **Nothing hand-written is touched** — the generated file lives in `.lotics/` (the CLI's own dir) and no config is edited by regex, which is what the deleted `lotics ui link` did when it twice destroyed the load-bearing `react-native` alias along with the array's closing bracket. Identical for a monorepo app and an EXTERNAL one (e.g. `~/lotics_apps`). `app deploy` still warns whenever the variable is set — that the bundle carries kit code from your working copy, or that the app's config predates `loticsResolve()` and never reads it, so the PUBLISHED kit is going out. An app whose `tsconfig.json` already `extends` something else is told rather than rewritten: add `./.lotics/tsconfig.link.json` to the array yourself. |
|
|
48
|
-
| `lotics xlsx <subcmd>` | Local .xlsx read/write/edit using the bundled `@lotics/xlsx` engine (no auth, no network). 14 named subcommands (read, write, set-cell, clear-range, merge, unmerge, add-sheet, delete-sheet, rename-sheet, insert-rows, delete-rows, insert-cols, delete-cols, set-style) + `batch` for applying multiple of the same 14 ops in a single parse/export cycle. `read` also takes `--sheet <name>` (limit output to one sheet — unknown name fails with the available list) and `--range <sheet>!<A1:G60>` (limit to a cell window; the `<sheet>!` prefix is optional when `--sheet` supplies the sheet, a single cell like `S1!B2` is a 1×1 window) to trim a large workbook's JSON — the output shape is unchanged, only the `sheets` array and each sheet's `cells` map are filtered. Atomic in-place write (temp file + rename). |
|
|
48
|
+
| `lotics xlsx <subcmd>` | Local .xlsx read/write/edit using the bundled `@lotics/xlsx` engine (no auth, no network). 14 named subcommands (read, write, set-cell, clear-range, merge, unmerge, add-sheet, delete-sheet, rename-sheet, insert-rows, delete-rows, insert-cols, delete-cols, set-style) + `batch` for applying multiple of the same 14 ops in a single parse/export cycle. `read` also takes `--sheet <name>` (limit output to one sheet — unknown name fails with the available list) and `--range <sheet>!<A1:G60>` (limit to a cell window; the `<sheet>!` prefix is optional when `--sheet` supplies the sheet, a single cell like `S1!B2` is a 1×1 window) to trim a large workbook's JSON — the output shape is unchanged, only the `sheets` array and each sheet's `cells` map are filtered. **`read` reports formatting back, so a generated file is verifiable through this path** rather than by unzipping OOXML: each cell carries `numFmt` when the file gave it one, and `--with-format` adds the resolved `style`. The asymmetry is deliberate — a parsed cell's style is *never* absent (every cell resolves to at least a font — size, name, colour), so emitting it by default would put three noise keys on every plain cell and make “is this styled?” unanswerable by presence; `numFmt` is genuinely absent on an unformatted cell, so it needs no flag. **`write` takes sheet-level `colWidths` (`{"A":34}`) and `rowHeights` (`{"1":44}`)** — without them every column is the default width and a human-facing workbook is unreadable no matter what the cells say. Both are written *pinned* (`customWidth`/`customHeight`), so Excel does not auto-fit them away, and both apply to a row/column that holds no cells (a spacer row's height survives). Keys are a bare column letter and a bare row number, bounded by Excel's grid (`A`…`XFD`, `1`…`1048576`): a key outside it, or a cell ref like `A1` where a column letter belongs, is **rejected** rather than resolved to something adjacent — past the grid the reference is written into the file verbatim, addressing a cell that cannot exist. Unknown **sheet** properties are rejected on the same terms as unknown cell properties — a silently-ignored `columnWidths` typo is a file that looks written and is not. Atomic in-place write (temp file + rename). |
|
|
49
49
|
| `lotics docx <subcmd>` | Local .docx read/write/edit using the bundled `@lotics/docx` engine (OOXML round-trip surface only — no ProseMirror baggage). Subcommands: read, write, append-paragraph, insert-paragraph, delete-block, replace-text, batch. A legacy `.doc` (Word 97–2003 OLE2 binary) is detected in `loadFile` and routed through `@lotics/ooxml`'s `loadDocxFromBuffer` (which re-emits it as real OOXML) before reading — so `lotics docx read` works on a `.doc`, not just a `.docx`. Opaque blocks (tables, custom XML) preserved verbatim. Atomic in-place write. **`replace-text` matches across run boundaries** — Word splits a run at every formatting change, so a `{{marker}}` routinely lands split — and reads straight THROUGH marks that occupy no place in the sentence (`w:proofErr`, `w:footnoteReference`, endnote/comment refs + ranges, `w:bookmarkStart`/`End`, `w:lastRenderedPageBreak`). `w:proofErr` is the one that decides whether this works in practice — Word brackets every word its dictionary rejects, so on non-English text it lands between nearly every pair of runs. It still refuses to join across anything that occupies space in the text — `w:br`, `w:tab`, `w:sym`, a drawing, or any tag not on that allowlist — because the joined string does not represent the glyph and a match there would rewrite text the caller never saw. The SAME rule applies inside a table cell as outside it — both run one `replaceInParagraph` over paragraphs found at any depth, so a marker split by a line break is refused in both rather than rewritten in the cell and skipped in the body under a success message. Zero matches is always a hard error, never a silent no-op, and when the words ARE on the page the error names the block and the splitting mark (`The text IS present at block 1, split by w:br …`) rather than claiming the text is absent. |
|
|
50
50
|
| `lotics file preview <file\|fil_id> [-o out.png]` | (also `lotics preview`) Render a .docx/.xlsx to a PNG using the SAME engines the frontend FilePreview uses (`@lotics/docx` `loadDocxIntoElement` / `@lotics/xlsx` `drawSpreadsheet`) — so what you see matches an operator. Accepts a **local path** OR a stored **`fil_…` id** (`isStoredFileId` — a bare id, no extension): an id is first downloaded to a temp dir via `downloadFileById` (the `signed_url` presign path — same authority as `lotics file download`), rendered, then the transient source is removed; with no `-o` the PNG lands in cwd under the stored file's base name (`defaultPreviewOutputPath`). Drives a headless Chrome over **CDP with only Node built-ins** (`WebSocket`/`fetch`/`http`/`child_process`) — zero npm deps, the CLI stays a single bundled binary. The browser render logic is a separate esbuild **browser** bundle shipped at `dist/render_page.js` (built by `build_cli.mjs`, excluded from the node `tsgo`), served over a throwaway localhost http server and screenshotted full-page. **Requires a Chrome/Chromium on the machine** — detected from `CHROME_PATH`/`LOTICS_CHROME`, then Playwright's installed chromium, then system paths — inherent to rendering these browser formats; a clear "install a browser" error otherwise. PDFs need no render (open them directly). |
|
|
51
51
|
|