pupt-lib 1.1.3 → 1.1.5
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/api.d.ts +1 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/component.d.ts +15 -2
- package/dist/component.d.ts.map +1 -1
- package/dist/index.js +86 -37
- package/dist/render.d.ts +17 -1
- package/dist/render.d.ts.map +1 -1
- package/dist/services/browser-support.d.ts +5 -1
- package/dist/services/browser-support.d.ts.map +1 -1
- package/dist/services/input-iterator.d.ts +10 -2
- package/dist/services/input-iterator.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface DiscoveredPromptWithMethods {
|
|
|
9
9
|
tags: string[];
|
|
10
10
|
library: string;
|
|
11
11
|
element: PuptElement;
|
|
12
|
-
render(options?: Partial<RenderOptions>): RenderResult
|
|
12
|
+
render(options?: Partial<RenderOptions>): Promise<RenderResult>;
|
|
13
13
|
getInputIterator(): InputIterator;
|
|
14
14
|
}
|
|
15
15
|
/**
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,aAAa,EACb,aAAa,EACb,YAAY,EACZ,WAAW,EACZ,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAGpF;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,YAAY,CAAC;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e;IAavB,OAAO,CAAC,sBAAsB;CA8B/B"}
|
package/dist/component.d.ts
CHANGED
|
@@ -8,13 +8,26 @@ export declare const COMPONENT_MARKER: unique symbol;
|
|
|
8
8
|
* Abstract base class for pupt-lib components.
|
|
9
9
|
* Extend this class to create class-based components with access to render context.
|
|
10
10
|
*
|
|
11
|
+
* Components can implement either synchronous or asynchronous render methods.
|
|
12
|
+
* Async render methods are useful for fetching data from APIs or performing
|
|
13
|
+
* other async operations.
|
|
14
|
+
*
|
|
11
15
|
* @example
|
|
12
16
|
* ```typescript
|
|
17
|
+
* // Synchronous render
|
|
13
18
|
* class Greeting extends Component<{ name: string }> {
|
|
14
19
|
* render(props: { name: string }, context: RenderContext): string {
|
|
15
20
|
* return `Hello, ${props.name}!`;
|
|
16
21
|
* }
|
|
17
22
|
* }
|
|
23
|
+
*
|
|
24
|
+
* // Asynchronous render
|
|
25
|
+
* class UserInfo extends Component<{ userId: string }> {
|
|
26
|
+
* async render(props: { userId: string }, context: RenderContext): Promise<string> {
|
|
27
|
+
* const user = await fetchUser(props.userId);
|
|
28
|
+
* return `Name: ${user.name}`;
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
18
31
|
* ```
|
|
19
32
|
*/
|
|
20
33
|
export declare abstract class Component<Props = Record<string, unknown>> {
|
|
@@ -26,9 +39,9 @@ export declare abstract class Component<Props = Record<string, unknown>> {
|
|
|
26
39
|
*
|
|
27
40
|
* @param props - The properties passed to the component
|
|
28
41
|
* @param context - The render context containing environment and inputs
|
|
29
|
-
* @returns The rendered output as a PuptNode
|
|
42
|
+
* @returns The rendered output as a PuptNode, or a Promise resolving to a PuptNode for async components
|
|
30
43
|
*/
|
|
31
|
-
abstract render(props: Props, context: RenderContext): PuptNode
|
|
44
|
+
abstract render(props: Props, context: RenderContext): PuptNode | Promise<PuptNode>;
|
|
32
45
|
}
|
|
33
46
|
/**
|
|
34
47
|
* Type guard to check if a value is a Component class (not an instance).
|
package/dist/component.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,gBAAgB,eAAsC,CAAC;AAEpE
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,gBAAgB,eAAsC,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,8BAAsB,SAAS,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC7D,MAAM,CAAC,CAAC,gBAAgB,CAAC,UAAQ;IAEjC,qEAAqE;IACrE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;IAEtC;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,GAAG,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;CACpF;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,OAAO,SAAS,CAK3B"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
var _a, _b;
|
|
4
|
+
var _a, _b, _c, _d;
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { Fragment } from "./jsx-runtime/index.js";
|
|
7
7
|
import MiniSearch from "minisearch";
|
|
@@ -210,7 +210,23 @@ function getComponentName(type) {
|
|
|
210
210
|
}
|
|
211
211
|
return "Unknown";
|
|
212
212
|
}
|
|
213
|
-
|
|
213
|
+
const DEBUG_TIMING$1 = typeof process !== "undefined" && ((_b = process.env) == null ? void 0 : _b.CI) === "true";
|
|
214
|
+
const SLOW_THRESHOLD_MS$1 = 1e3;
|
|
215
|
+
let renderCallCount = 0;
|
|
216
|
+
async function render(element, options = {}) {
|
|
217
|
+
const callNum = ++renderCallCount;
|
|
218
|
+
const start = Date.now();
|
|
219
|
+
let lastCheckpoint = start;
|
|
220
|
+
const logSlow = (step) => {
|
|
221
|
+
if (!DEBUG_TIMING$1) return;
|
|
222
|
+
const now = Date.now();
|
|
223
|
+
const stepTime = now - lastCheckpoint;
|
|
224
|
+
const totalTime = now - start;
|
|
225
|
+
if (stepTime >= SLOW_THRESHOLD_MS$1) {
|
|
226
|
+
console.log(`[SLOW RENDER #${callNum}] ${step} took ${stepTime}ms (total: ${totalTime}ms)`);
|
|
227
|
+
}
|
|
228
|
+
lastCheckpoint = now;
|
|
229
|
+
};
|
|
214
230
|
const {
|
|
215
231
|
inputs = /* @__PURE__ */ new Map(),
|
|
216
232
|
env = DEFAULT_ENVIRONMENT,
|
|
@@ -224,7 +240,9 @@ function render(element, options = {}) {
|
|
|
224
240
|
postExecution,
|
|
225
241
|
errors
|
|
226
242
|
};
|
|
227
|
-
|
|
243
|
+
logSlow("context setup");
|
|
244
|
+
const text = await renderNode(element, context);
|
|
245
|
+
logSlow("renderNode");
|
|
228
246
|
const trimmedText = trim ? text.trim() : text;
|
|
229
247
|
if (errors.length > 0) {
|
|
230
248
|
return {
|
|
@@ -240,7 +258,7 @@ function render(element, options = {}) {
|
|
|
240
258
|
postExecution
|
|
241
259
|
};
|
|
242
260
|
}
|
|
243
|
-
function renderNode(node, context) {
|
|
261
|
+
async function renderNode(node, context) {
|
|
244
262
|
if (node === null || node === void 0 || node === false) {
|
|
245
263
|
return "";
|
|
246
264
|
}
|
|
@@ -248,14 +266,16 @@ function renderNode(node, context) {
|
|
|
248
266
|
return String(node);
|
|
249
267
|
}
|
|
250
268
|
if (Array.isArray(node)) {
|
|
251
|
-
|
|
269
|
+
const results = await Promise.all(node.map((n) => renderNode(n, context)));
|
|
270
|
+
return results.join("");
|
|
252
271
|
}
|
|
253
272
|
return renderElement(node, context);
|
|
254
273
|
}
|
|
255
|
-
function renderChildrenFallback(children, context) {
|
|
256
|
-
|
|
274
|
+
async function renderChildrenFallback(children, context) {
|
|
275
|
+
const results = await Promise.all(children.map((c) => renderNode(c, context)));
|
|
276
|
+
return results.join("");
|
|
257
277
|
}
|
|
258
|
-
function renderComponentWithValidation(type, componentName, props, children, context, renderFn) {
|
|
278
|
+
async function renderComponentWithValidation(type, componentName, props, children, context, renderFn) {
|
|
259
279
|
const schema = getSchema(type);
|
|
260
280
|
if (!schema) {
|
|
261
281
|
context.errors.push({
|
|
@@ -274,7 +294,8 @@ function renderComponentWithValidation(type, componentName, props, children, con
|
|
|
274
294
|
}
|
|
275
295
|
try {
|
|
276
296
|
const result = renderFn();
|
|
277
|
-
|
|
297
|
+
const resolvedResult = result instanceof Promise ? await result : result;
|
|
298
|
+
return renderNode(resolvedResult, context);
|
|
278
299
|
} catch (err) {
|
|
279
300
|
const message = err instanceof Error ? err.message : String(err);
|
|
280
301
|
context.errors.push({
|
|
@@ -287,10 +308,11 @@ function renderComponentWithValidation(type, componentName, props, children, con
|
|
|
287
308
|
return renderChildrenFallback(children, context);
|
|
288
309
|
}
|
|
289
310
|
}
|
|
290
|
-
function renderElement(element, context) {
|
|
311
|
+
async function renderElement(element, context) {
|
|
291
312
|
const { type, props, children } = element;
|
|
292
313
|
if (type === Fragment) {
|
|
293
|
-
|
|
314
|
+
const results = await Promise.all(children.map((c) => renderNode(c, context)));
|
|
315
|
+
return results.join("");
|
|
294
316
|
}
|
|
295
317
|
if (isComponentClass(type)) {
|
|
296
318
|
return renderComponentWithValidation(
|
|
@@ -320,10 +342,14 @@ function renderElement(element, context) {
|
|
|
320
342
|
}
|
|
321
343
|
if (typeof type === "string") {
|
|
322
344
|
console.warn(`Unknown component type "${type}". Components should be imported, not referenced by string.`);
|
|
323
|
-
|
|
345
|
+
const results = await Promise.all(children.map((c) => renderNode(c, context)));
|
|
346
|
+
return results.join("");
|
|
324
347
|
}
|
|
325
348
|
return "";
|
|
326
349
|
}
|
|
350
|
+
const DEBUG_TIMING = typeof process !== "undefined" && ((_c = process.env) == null ? void 0 : _c.CI) === "true";
|
|
351
|
+
const SLOW_THRESHOLD_MS = 1e3;
|
|
352
|
+
let iteratorCallCount = 0;
|
|
327
353
|
function detectEnvironment() {
|
|
328
354
|
var _a2;
|
|
329
355
|
if (typeof process !== "undefined" && ((_a2 = process.versions) == null ? void 0 : _a2.node)) {
|
|
@@ -366,7 +392,7 @@ function createInputIterator(element, options = {}) {
|
|
|
366
392
|
values2.set(key, value);
|
|
367
393
|
}
|
|
368
394
|
async function processNonInteractively() {
|
|
369
|
-
const allReqs = collectRequirements(element);
|
|
395
|
+
const allReqs = await collectRequirements(element);
|
|
370
396
|
for (const req of allReqs) {
|
|
371
397
|
if (values2.has(req.name)) {
|
|
372
398
|
continue;
|
|
@@ -396,8 +422,9 @@ function createInputIterator(element, options = {}) {
|
|
|
396
422
|
values2.set(req.name, valueToUse);
|
|
397
423
|
}
|
|
398
424
|
}
|
|
399
|
-
function collectRequirements(node) {
|
|
425
|
+
async function collectRequirements(node) {
|
|
400
426
|
const collected = [];
|
|
427
|
+
const configStart = Date.now();
|
|
401
428
|
const context = {
|
|
402
429
|
inputs: values2,
|
|
403
430
|
env: { ...DEFAULT_ENVIRONMENT, runtime: createRuntimeConfig() },
|
|
@@ -405,7 +432,14 @@ function createInputIterator(element, options = {}) {
|
|
|
405
432
|
errors: [],
|
|
406
433
|
__requirements: collected
|
|
407
434
|
};
|
|
408
|
-
|
|
435
|
+
if (DEBUG_TIMING && Date.now() - configStart >= SLOW_THRESHOLD_MS) {
|
|
436
|
+
console.log(`[SLOW] createRuntimeConfig took ${Date.now() - configStart}ms`);
|
|
437
|
+
}
|
|
438
|
+
const walkStart = Date.now();
|
|
439
|
+
await walkNode(node, context);
|
|
440
|
+
if (DEBUG_TIMING && Date.now() - walkStart >= SLOW_THRESHOLD_MS) {
|
|
441
|
+
console.log(`[SLOW] walkNode took ${Date.now() - walkStart}ms`);
|
|
442
|
+
}
|
|
409
443
|
return collected;
|
|
410
444
|
}
|
|
411
445
|
function findNextUnfilledIndex(reqs, startIndex) {
|
|
@@ -416,7 +450,7 @@ function createInputIterator(element, options = {}) {
|
|
|
416
450
|
}
|
|
417
451
|
return reqs.length;
|
|
418
452
|
}
|
|
419
|
-
function walkNode(node, context) {
|
|
453
|
+
async function walkNode(node, context) {
|
|
420
454
|
if (node === null || node === void 0 || node === false) {
|
|
421
455
|
return;
|
|
422
456
|
}
|
|
@@ -425,7 +459,7 @@ function createInputIterator(element, options = {}) {
|
|
|
425
459
|
}
|
|
426
460
|
if (Array.isArray(node)) {
|
|
427
461
|
for (const child of node) {
|
|
428
|
-
walkNode(child, context);
|
|
462
|
+
await walkNode(child, context);
|
|
429
463
|
}
|
|
430
464
|
return;
|
|
431
465
|
}
|
|
@@ -433,29 +467,31 @@ function createInputIterator(element, options = {}) {
|
|
|
433
467
|
const { type, props, children } = element2;
|
|
434
468
|
if (type === Fragment) {
|
|
435
469
|
for (const child of children) {
|
|
436
|
-
walkNode(child, context);
|
|
470
|
+
await walkNode(child, context);
|
|
437
471
|
}
|
|
438
472
|
return;
|
|
439
473
|
}
|
|
440
474
|
if (isComponentClass(type)) {
|
|
441
475
|
const instance = new type();
|
|
442
|
-
const
|
|
476
|
+
const renderResult = instance.render({ ...props, children }, context);
|
|
477
|
+
const result = renderResult instanceof Promise ? await renderResult : renderResult;
|
|
443
478
|
if (result !== null && typeof result === "object") {
|
|
444
|
-
walkNode(result, context);
|
|
479
|
+
await walkNode(result, context);
|
|
445
480
|
}
|
|
446
481
|
return;
|
|
447
482
|
}
|
|
448
483
|
if (typeof type === "function" && !isComponentClass(type)) {
|
|
449
484
|
const fn = type;
|
|
450
|
-
const
|
|
485
|
+
const renderResult = fn({ ...props, children });
|
|
486
|
+
const result = renderResult instanceof Promise ? await renderResult : renderResult;
|
|
451
487
|
if (result !== null && typeof result === "object") {
|
|
452
|
-
walkNode(result, context);
|
|
488
|
+
await walkNode(result, context);
|
|
453
489
|
}
|
|
454
490
|
return;
|
|
455
491
|
}
|
|
456
492
|
if (typeof type === "string") {
|
|
457
493
|
for (const child of children) {
|
|
458
|
-
walkNode(child, context);
|
|
494
|
+
await walkNode(child, context);
|
|
459
495
|
}
|
|
460
496
|
}
|
|
461
497
|
}
|
|
@@ -754,7 +790,15 @@ function createInputIterator(element, options = {}) {
|
|
|
754
790
|
};
|
|
755
791
|
}
|
|
756
792
|
return {
|
|
757
|
-
start() {
|
|
793
|
+
async start() {
|
|
794
|
+
const callNum = ++iteratorCallCount;
|
|
795
|
+
const logSlow = (step, stepStart) => {
|
|
796
|
+
if (!DEBUG_TIMING) return;
|
|
797
|
+
const stepTime = Date.now() - stepStart;
|
|
798
|
+
if (stepTime >= SLOW_THRESHOLD_MS) {
|
|
799
|
+
console.log(`[SLOW ITERATOR #${callNum}] ${step} took ${stepTime}ms`);
|
|
800
|
+
}
|
|
801
|
+
};
|
|
758
802
|
if (state !== "NOT_STARTED") {
|
|
759
803
|
throw new Error("Iterator already started.");
|
|
760
804
|
}
|
|
@@ -762,7 +806,9 @@ function createInputIterator(element, options = {}) {
|
|
|
762
806
|
state = "DONE";
|
|
763
807
|
return;
|
|
764
808
|
}
|
|
765
|
-
|
|
809
|
+
const collectStart = Date.now();
|
|
810
|
+
requirements = await collectRequirements(element);
|
|
811
|
+
logSlow("collectRequirements", collectStart);
|
|
766
812
|
currentIndex = findNextUnfilledIndex(requirements, 0);
|
|
767
813
|
state = currentIndex < requirements.length ? "ITERATING" : "DONE";
|
|
768
814
|
},
|
|
@@ -797,7 +843,7 @@ function createInputIterator(element, options = {}) {
|
|
|
797
843
|
warnings: []
|
|
798
844
|
};
|
|
799
845
|
},
|
|
800
|
-
advance() {
|
|
846
|
+
async advance() {
|
|
801
847
|
if (state === "NOT_STARTED") {
|
|
802
848
|
throw new Error("Iterator not started. Call start() first.");
|
|
803
849
|
}
|
|
@@ -807,7 +853,7 @@ function createInputIterator(element, options = {}) {
|
|
|
807
853
|
if (state === "DONE") {
|
|
808
854
|
throw new Error("Iterator is done. Nothing to advance.");
|
|
809
855
|
}
|
|
810
|
-
requirements = collectRequirements(element);
|
|
856
|
+
requirements = await collectRequirements(element);
|
|
811
857
|
currentIndex = findNextUnfilledIndex(requirements, currentIndex + 1);
|
|
812
858
|
state = currentIndex < requirements.length ? "ITERATING" : "DONE";
|
|
813
859
|
},
|
|
@@ -15666,8 +15712,8 @@ const movedSimpleCellAddress = (address, toSheet, toRight, toBottom) => {
|
|
|
15666
15712
|
};
|
|
15667
15713
|
const addressKey = (address) => `${address.sheet},${address.row},${address.col}`;
|
|
15668
15714
|
function isSimpleCellAddress(obj) {
|
|
15669
|
-
var _a2, _b2,
|
|
15670
|
-
return obj && (typeof obj === "object" || typeof obj === "function") && typeof ((_a2 = obj) === null || _a2 === void 0 ? void 0 : _a2.sheet) === "number" && typeof ((_b2 = obj) === null || _b2 === void 0 ? void 0 : _b2.col) === "number" && typeof ((
|
|
15715
|
+
var _a2, _b2, _c2;
|
|
15716
|
+
return obj && (typeof obj === "object" || typeof obj === "function") && typeof ((_a2 = obj) === null || _a2 === void 0 ? void 0 : _a2.sheet) === "number" && typeof ((_b2 = obj) === null || _b2 === void 0 ? void 0 : _b2.col) === "number" && typeof ((_c2 = obj) === null || _c2 === void 0 ? void 0 : _c2.row) === "number";
|
|
15671
15717
|
}
|
|
15672
15718
|
const absoluteSheetReference = (address, baseAddress) => {
|
|
15673
15719
|
var _a2;
|
|
@@ -17397,7 +17443,7 @@ function defaultParseToDateTime(text, dateFormat, timeFormat) {
|
|
|
17397
17443
|
}
|
|
17398
17444
|
}
|
|
17399
17445
|
function defaultParseToTime(timeItems, timeFormat) {
|
|
17400
|
-
var _a2, _b2,
|
|
17446
|
+
var _a2, _b2, _c2;
|
|
17401
17447
|
if (timeFormat === void 0) {
|
|
17402
17448
|
return void 0;
|
|
17403
17449
|
}
|
|
@@ -17427,7 +17473,7 @@ function defaultParseToTime(timeItems, timeFormat) {
|
|
|
17427
17473
|
if (!(Number.isFinite(minutes) && Number.isInteger(minutes))) {
|
|
17428
17474
|
return void 0;
|
|
17429
17475
|
}
|
|
17430
|
-
const hoursParsed = Number((
|
|
17476
|
+
const hoursParsed = Number((_c2 = timeItems[hourItem]) !== null && _c2 !== void 0 ? _c2 : "0");
|
|
17431
17477
|
if (!(Number.isFinite(hoursParsed) && Number.isInteger(hoursParsed))) {
|
|
17432
17478
|
return void 0;
|
|
17433
17479
|
}
|
|
@@ -21887,9 +21933,9 @@ const buildCriterion = (operator, value) => ({
|
|
|
21887
21933
|
});
|
|
21888
21934
|
class CriterionBuilder {
|
|
21889
21935
|
constructor(config) {
|
|
21890
|
-
var _a2, _b2,
|
|
21936
|
+
var _a2, _b2, _c2, _d2;
|
|
21891
21937
|
this.trueString = (_b2 = (_a2 = config.translationPackage.getMaybeFunctionTranslation("TRUE")) === null || _a2 === void 0 ? void 0 : _a2.toLowerCase()) !== null && _b2 !== void 0 ? _b2 : "true";
|
|
21892
|
-
this.falseString = (
|
|
21938
|
+
this.falseString = (_d2 = (_c2 = config.translationPackage.getMaybeFunctionTranslation("FALSE")) === null || _c2 === void 0 ? void 0 : _c2.toLowerCase()) !== null && _d2 !== void 0 ? _d2 : "false";
|
|
21893
21939
|
}
|
|
21894
21940
|
fromCellValue(raw, arithmeticHelper) {
|
|
21895
21941
|
if (typeof raw !== "string" && typeof raw !== "boolean" && typeof raw !== "number") {
|
|
@@ -30945,14 +30991,14 @@ class InformationPlugin extends FunctionPlugin {
|
|
|
30945
30991
|
*/
|
|
30946
30992
|
index(ast, state) {
|
|
30947
30993
|
return this.runFunction(ast.args, state, this.metadata("INDEX"), (rangeValue, row, col) => {
|
|
30948
|
-
var _a2, _b2,
|
|
30994
|
+
var _a2, _b2, _c2, _d2, _e, _f;
|
|
30949
30995
|
if (col < 1 || row < 1) {
|
|
30950
30996
|
return new CellError(ErrorType.VALUE, ErrorMessage.LessThanOne);
|
|
30951
30997
|
}
|
|
30952
30998
|
if (col > rangeValue.width() || row > rangeValue.height()) {
|
|
30953
30999
|
return new CellError(ErrorType.NUM, ErrorMessage.ValueLarge);
|
|
30954
31000
|
}
|
|
30955
|
-
return (_f = (
|
|
31001
|
+
return (_f = (_c2 = (_b2 = (_a2 = rangeValue === null || rangeValue === void 0 ? void 0 : rangeValue.data) === null || _a2 === void 0 ? void 0 : _a2[row - 1]) === null || _b2 === void 0 ? void 0 : _b2[col - 1]) !== null && _c2 !== void 0 ? _c2 : (_e = (_d2 = rangeValue === null || rangeValue === void 0 ? void 0 : rangeValue.data) === null || _d2 === void 0 ? void 0 : _d2[0]) === null || _e === void 0 ? void 0 : _e[0]) !== null && _f !== void 0 ? _f : new CellError(ErrorType.VALUE, ErrorMessage.CellRangeExpected);
|
|
30956
31002
|
});
|
|
30957
31003
|
}
|
|
30958
31004
|
/**
|
|
@@ -38429,7 +38475,7 @@ ${result}`;
|
|
|
38429
38475
|
}
|
|
38430
38476
|
return result;
|
|
38431
38477
|
}
|
|
38432
|
-
const isNode = typeof process !== "undefined" && ((
|
|
38478
|
+
const isNode = typeof process !== "undefined" && ((_d = process.versions) == null ? void 0 : _d.node);
|
|
38433
38479
|
async function resolveLocalPath(source) {
|
|
38434
38480
|
if (!isNode) {
|
|
38435
38481
|
return source;
|
|
@@ -38715,12 +38761,14 @@ ${json}
|
|
|
38715
38761
|
<\/script>`;
|
|
38716
38762
|
}
|
|
38717
38763
|
const DEFAULT_ZOD_VERSION = "3.24.2";
|
|
38764
|
+
const DEFAULT_MINISEARCH_VERSION = "7.2.0";
|
|
38718
38765
|
function generatePuptLibImportMap(options = {}) {
|
|
38719
38766
|
const {
|
|
38720
38767
|
cdn = "esm.sh",
|
|
38721
38768
|
cdnTemplate,
|
|
38722
38769
|
puptLibVersion = "latest",
|
|
38723
38770
|
zodVersion = DEFAULT_ZOD_VERSION,
|
|
38771
|
+
minisearchVersion = DEFAULT_MINISEARCH_VERSION,
|
|
38724
38772
|
additionalDependencies = []
|
|
38725
38773
|
} = options;
|
|
38726
38774
|
const cdnOptions = cdnTemplate ? { cdnTemplate } : { cdn };
|
|
@@ -38729,6 +38777,7 @@ function generatePuptLibImportMap(options = {}) {
|
|
|
38729
38777
|
imports["pupt-lib"] = puptLibUrl;
|
|
38730
38778
|
imports["pupt-lib/jsx-runtime"] = `${puptLibUrl}/jsx-runtime`;
|
|
38731
38779
|
imports["zod"] = resolveCdn("zod", zodVersion, cdnOptions);
|
|
38780
|
+
imports["minisearch"] = resolveCdn("minisearch", minisearchVersion, cdnOptions);
|
|
38732
38781
|
for (const dep of additionalDependencies) {
|
|
38733
38782
|
imports[dep.name] = resolveCdn(dep.name, dep.version, cdnOptions);
|
|
38734
38783
|
}
|
|
@@ -40194,7 +40243,7 @@ class Pupt {
|
|
|
40194
40243
|
tags,
|
|
40195
40244
|
library,
|
|
40196
40245
|
element,
|
|
40197
|
-
render: (options) => {
|
|
40246
|
+
render: async (options) => {
|
|
40198
40247
|
const inputsObj = (options == null ? void 0 : options.inputs) ?? {};
|
|
40199
40248
|
const inputsMap = inputsObj instanceof Map ? inputsObj : new Map(Object.entries(inputsObj));
|
|
40200
40249
|
return render(element, {
|
package/dist/render.d.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
1
|
import { PuptElement, RenderResult, RenderOptions } from './types';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Render a PuptElement tree to a string.
|
|
4
|
+
*
|
|
5
|
+
* This function is async to support components with async render methods.
|
|
6
|
+
* Components can perform async operations like API calls in their render methods.
|
|
7
|
+
*
|
|
8
|
+
* @param element - The root PuptElement to render
|
|
9
|
+
* @param options - Render options including inputs and environment
|
|
10
|
+
* @returns A Promise resolving to the RenderResult
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const result = await render(<MyPrompt />);
|
|
15
|
+
* console.log(result.text);
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function render(element: PuptElement, options?: RenderOptions): Promise<RenderResult>;
|
|
3
19
|
//# sourceMappingURL=render.d.ts.map
|
package/dist/render.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAY,YAAY,EAAE,aAAa,EAAmD,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAY,YAAY,EAAE,aAAa,EAAmD,MAAM,SAAS,CAAC;AAcnI;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,MAAM,CAC1B,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,YAAY,CAAC,CAmDvB"}
|
|
@@ -120,6 +120,8 @@ export interface PuptLibImportMapOptions {
|
|
|
120
120
|
puptLibVersion?: string;
|
|
121
121
|
/** zod version (default: '3.24.2') */
|
|
122
122
|
zodVersion?: string;
|
|
123
|
+
/** minisearch version (default: '7.2.0') */
|
|
124
|
+
minisearchVersion?: string;
|
|
123
125
|
/** Additional dependencies to include */
|
|
124
126
|
additionalDependencies?: Dependency[];
|
|
125
127
|
}
|
|
@@ -131,6 +133,7 @@ export interface PuptLibImportMapOptions {
|
|
|
131
133
|
* - pupt-lib main entry
|
|
132
134
|
* - pupt-lib/jsx-runtime subpath
|
|
133
135
|
* - zod (required peer dependency)
|
|
136
|
+
* - minisearch (required for search functionality)
|
|
134
137
|
*
|
|
135
138
|
* @param options - Configuration options
|
|
136
139
|
* @returns An ImportMap object ready to be serialized
|
|
@@ -163,7 +166,8 @@ export interface PuptLibImportMapOptions {
|
|
|
163
166
|
* "imports": {
|
|
164
167
|
* "pupt-lib": "https://esm.sh/pupt-lib@1.1.0",
|
|
165
168
|
* "pupt-lib/jsx-runtime": "https://esm.sh/pupt-lib@1.1.0/jsx-runtime",
|
|
166
|
-
* "zod": "https://esm.sh/zod@3.24.2"
|
|
169
|
+
* "zod": "https://esm.sh/zod@3.24.2",
|
|
170
|
+
* "minisearch": "https://esm.sh/minisearch@7.2.0"
|
|
167
171
|
* }
|
|
168
172
|
* }
|
|
169
173
|
* </script>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-support.d.ts","sourceRoot":"","sources":["../../src/services/browser-support.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,CAAC;AAYtE;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,0BAA0B;IAC1B,GAAG,CAAC,EAAE,WAAW,CAAC;IAClB,qFAAqF;IACrF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,UAAU,GAClB,MAAM,CAsBR;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,UAAU,EAAE,EAC1B,OAAO,EAAE,UAAU,GAClB,SAAS,CAeX;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAE/D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,UAAU,EAAE,EAC1B,OAAO,EAAE,UAAU,GAClB,MAAM,CAIR;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,8CAA8C;IAC9C,GAAG,CAAC,EAAE,WAAW,CAAC;IAClB,8BAA8B;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4DAA4D;IAC5D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sCAAsC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,sBAAsB,CAAC,EAAE,UAAU,EAAE,CAAC;CACvC;
|
|
1
|
+
{"version":3,"file":"browser-support.d.ts","sourceRoot":"","sources":["../../src/services/browser-support.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,CAAC;AAYtE;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,0BAA0B;IAC1B,GAAG,CAAC,EAAE,W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CAAC,EAAE,MAAM,CAAC;IACpB,4CAA4C;IAC5C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,yCAAyC;IACzC,sBAAsB,CAAC,EAAE,UAAU,EAAE,CAAC;CACvC;AAcD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,GAAE,uBAA4B,GACpC,SAAS,CAmCX;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,GAAE,uBAA4B,GACpC,MAAM,CAIR"}
|
|
@@ -27,10 +27,18 @@ export interface InputIteratorOptions {
|
|
|
27
27
|
onMissingDefault?: OnMissingDefaultStrategy;
|
|
28
28
|
}
|
|
29
29
|
export interface InputIterator {
|
|
30
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Start the iterator by collecting input requirements from the element tree.
|
|
32
|
+
* This is async to support components with async render methods.
|
|
33
|
+
*/
|
|
34
|
+
start(): Promise<void>;
|
|
31
35
|
current(): InputRequirement | null;
|
|
32
36
|
submit(value: unknown): Promise<ValidationResult>;
|
|
33
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Advance to the next unfilled requirement.
|
|
39
|
+
* This is async to support re-collecting requirements from async components.
|
|
40
|
+
*/
|
|
41
|
+
advance(): Promise<void>;
|
|
34
42
|
isDone(): boolean;
|
|
35
43
|
getValues(): Map<string, unknown>;
|
|
36
44
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-iterator.d.ts","sourceRoot":"","sources":["../../src/services/input-iterator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAY,gBAAgB,EAAE,gBAAgB,EAAiB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"input-iterator.d.ts","sourceRoot":"","sources":["../../src/services/input-iterator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAY,gBAAgB,EAAE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