@oomol-lab/open-flow 0.1.0-beta.72 → 0.1.0-beta.73

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.
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- var Gb=Object.defineProperty;var Hb=(e)=>e;function Qb(e,n){this[e]=Hb.bind(null,n)}var no=(e,n)=>{for(var t in n)Gb(e,t,{get:n[t],enumerable:!0,configurable:!0,set:Qb.bind(n,t)})};var Iu="0.1.0-beta.72";var rs=["en","zh-CN","zh-TW","ja","ko","ru","fr"],Cu="en";var ts=new Map(rs.map((e)=>[e.toLowerCase(),e])),Xb=new Set(["hk","mo","tw"]);function Ou(e){return typeof e=="string"&&ts.get(e.toLowerCase())==e}function to(e,n="en"){for(let t of e){let r=t==null?void 0:ew(t);if(r!=null)return r}return n}function ew(e){let n=e.trim().toLowerCase();if(n.length==0)return;let t=ts.get(n);if(t!=null)return t;let r=n.split("-");if(r[0]=="zh"){if(r.includes("hant"))return"zh-TW";if(r.includes("hans"))return"zh-CN";return r.some((o)=>Xb.has(o))?"zh-TW":"zh-CN"}return ts.get(r[0])}function Eu(e){return{en:"Imported workflow","zh-CN":"\u5BFC\u5165\u7684\u5DE5\u4F5C\u6D41","zh-TW":"\u532F\u5165\u7684\u5DE5\u4F5C\u6D41",ja:"\u30A4\u30F3\u30DD\u30FC\u30C8\u3057\u305F\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC",ko:"\uAC00\uC838\uC628 \uC6CC\uD06C\uD50C\uB85C",fr:"Workflow import\xE9",ru:"\u0418\u043C\u043F\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u043F\u0440\u043E\u0446\u0435\u0441\u0441"}[e]}import{spawn as IC}from"child_process";import{readFile as CC}from"fs/promises";import{setTimeout as OC}from"timers/promises";var ro="open-flow-engine/v7";var nw={waitAutoContinue:!0,webhookResponses:!0,platformExports:new Set(["engineContract","identity"]),platformModule:"open-flow:platform",platformSource:`export const engineContract = ${JSON.stringify("open-flow-engine/v7")}
2
+ var Gb=Object.defineProperty;var Hb=(e)=>e;function Qb(e,n){this[e]=Hb.bind(null,n)}var no=(e,n)=>{for(var t in n)Gb(e,t,{get:n[t],enumerable:!0,configurable:!0,set:Qb.bind(n,t)})};var Iu="0.1.0-beta.73";var rs=["en","zh-CN","zh-TW","ja","ko","ru","fr"],Cu="en";var ts=new Map(rs.map((e)=>[e.toLowerCase(),e])),Xb=new Set(["hk","mo","tw"]);function Ou(e){return typeof e=="string"&&ts.get(e.toLowerCase())==e}function to(e,n="en"){for(let t of e){let r=t==null?void 0:ew(t);if(r!=null)return r}return n}function ew(e){let n=e.trim().toLowerCase();if(n.length==0)return;let t=ts.get(n);if(t!=null)return t;let r=n.split("-");if(r[0]=="zh"){if(r.includes("hant"))return"zh-TW";if(r.includes("hans"))return"zh-CN";return r.some((o)=>Xb.has(o))?"zh-TW":"zh-CN"}return ts.get(r[0])}function Eu(e){return{en:"Imported workflow","zh-CN":"\u5BFC\u5165\u7684\u5DE5\u4F5C\u6D41","zh-TW":"\u532F\u5165\u7684\u5DE5\u4F5C\u6D41",ja:"\u30A4\u30F3\u30DD\u30FC\u30C8\u3057\u305F\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC",ko:"\uAC00\uC838\uC628 \uC6CC\uD06C\uD50C\uB85C",fr:"Workflow import\xE9",ru:"\u0418\u043C\u043F\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u043F\u0440\u043E\u0446\u0435\u0441\u0441"}[e]}import{spawn as IC}from"child_process";import{readFile as CC}from"fs/promises";import{setTimeout as OC}from"timers/promises";var ro="open-flow-engine/v7";var nw={waitAutoContinue:!0,webhookResponses:!0,platformExports:new Set(["engineContract","identity"]),platformModule:"open-flow:platform",platformSource:`export const engineContract = ${JSON.stringify("open-flow-engine/v7")}
3
3
  export function identity(value) { return value }
4
4
  `},AC={...nw,builtinModules:new Set(["assert","assert/strict","buffer","console","constants","crypto","events","fs","fs/promises","os","path","path/posix","process","punycode","querystring","stream","stream/promises","stream/web","string_decoder","timers","timers/promises","url","util","zlib"].flatMap((e)=>[e,`node:${e}`])),platformSource:`export const engineContract = ${JSON.stringify("open-flow-engine/v7/nodejs-compat-v1")}
5
5
  export function identity(value) { return value }
@@ -11520,11 +11520,16 @@ function readResult(value, query = {}) {
11520
11520
  offset,
11521
11521
  value: selected
11522
11522
  };
11523
- if (offset == 0 && (query.limit == null || description.length == null || description.length <= limit) && bytes(whole) <= maxBytes) return whole;
11523
+ if (offset == 0 && (query.limit == null || description.length == null || description.length <= limit) && (typeof selected != "string" || selected.length <= maxBytes) && bytes(whole) <= maxBytes) return whole;
11524
11524
  const root = description;
11525
11525
  if (typeof selected == "string") {
11526
11526
  let length = 0;
11527
- for (const _ of selected) length++;
11527
+ let start = 0;
11528
+ for (let index = 0; index < selected.length; length++) {
11529
+ if (length == offset) start = index;
11530
+ const point = selected.codePointAt(index);
11531
+ index += point > 65535 ? 2 : 1;
11532
+ }
11528
11533
  if (offset >= length) throw new Error("Result offset is out of range.");
11529
11534
  const budget = maxBytes - bytes({
11530
11535
  ...root,
@@ -11534,17 +11539,23 @@ function readResult(value, query = {}) {
11534
11539
  nextOffset: length
11535
11540
  });
11536
11541
  let used = 0;
11537
- let text = "";
11542
+ let cursor = start;
11538
11543
  let end = offset;
11539
- let position = 0;
11540
- for (const char of selected) {
11541
- if (position++ < offset) continue;
11542
- const size = bytes(char) - 2;
11544
+ while (cursor < selected.length) {
11545
+ const point = selected.codePointAt(cursor);
11546
+ let size;
11547
+ if (point == 34 || point == 92 || point == 8 || point == 9 || point == 10 || point == 12 || point == 13) size = 2;
11548
+ else if (point < 32 || point >= 55296 && point <= 57343) size = 6;
11549
+ else if (point < 128) size = 1;
11550
+ else if (point < 2048) size = 2;
11551
+ else if (point <= 65535) size = 3;
11552
+ else size = 4;
11543
11553
  if (used + size > budget) break;
11544
- text += char;
11554
+ cursor += point > 65535 ? 2 : 1;
11545
11555
  used += size;
11546
11556
  end++;
11547
11557
  }
11558
+ const text = selected.slice(start, cursor);
11548
11559
  if (end == offset) throw new Error("Result byte budget cannot fit a string character and page metadata.");
11549
11560
  return {
11550
11561
  ...root,
@@ -11559,6 +11570,13 @@ function readResult(value, query = {}) {
11559
11570
  const keys = Object.keys(selected);
11560
11571
  if (offset >= keys.length) throw new Error("Result offset is out of range.");
11561
11572
  const entries = [];
11573
+ const overhead = bytes({
11574
+ ...root,
11575
+ offset,
11576
+ entries: [],
11577
+ nextOffset: keys.length
11578
+ });
11579
+ let used = overhead;
11562
11580
  for (const key of keys.slice(offset, offset + limit)) {
11563
11581
  const path = `${pointer}/${key.replace(/~/g, "~0").replace(/\//g, "~1")}`;
11564
11582
  const item = Array.isArray(selected) ? selected[Number(key)] : selected[key];
@@ -11568,19 +11586,12 @@ function readResult(value, query = {}) {
11568
11586
  complete: true,
11569
11587
  value: item
11570
11588
  };
11571
- const next = bytes({
11572
- ...root,
11573
- offset,
11574
- entries: [full],
11575
- nextOffset: keys.length
11576
- }) <= maxBytes ? full : metadata;
11577
- if (bytes({
11578
- ...root,
11579
- offset,
11580
- entries: [...entries, next],
11581
- nextOffset: keys.length
11582
- }) > maxBytes) break;
11589
+ const fullBytes = bytes(full);
11590
+ const next = overhead + fullBytes <= maxBytes ? full : metadata;
11591
+ const size = (next === full ? fullBytes : bytes(metadata)) + (entries.length == 0 ? 0 : 1);
11592
+ if (used + size > maxBytes) break;
11583
11593
  entries.push(next);
11594
+ used += size;
11584
11595
  }
11585
11596
  if (entries.length == 0) throw new Error("Result property name exceeds the preview limit. Download the full result.");
11586
11597
  const end = offset + entries.length;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oomol-lab/open-flow",
3
- "version": "0.1.0-beta.72",
3
+ "version": "0.1.0-beta.73",
4
4
  "description": "TypeScript contracts and Browser runtime for Open Flow.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {