@deepraxis/cli 0.3.0-dev.6da4327 → 0.3.0-dev.ae46a71
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/COMMANDS.md +11 -8
- package/dist/praxis.js +983 -110
- package/package.json +1 -1
package/dist/praxis.js
CHANGED
|
@@ -7088,7 +7088,7 @@ across all toolsets allowed.`
|
|
|
7088
7088
|
type: "array",
|
|
7089
7089
|
itemType: "object",
|
|
7090
7090
|
required: false,
|
|
7091
|
-
description:
|
|
7091
|
+
description: `Platform resources and services this service agent's codemode may reach, as one list of typed bindings. Only kind=service accepts a nonempty list; general and personal agents return 400. There are two kinds. A resource binding names one resource with id and access: database (id db_..., read_only or read_write), vector_store (id vs_..., read_only or read_write), file (id file- plus 24 letters or digits, as the File API returns it; read_only), media_library (any id without ':' or whitespace, read_only or read_write), model (a model catalog id, invoke), workflow and script (id <namespace>/<name>, invoke). A service binding opens a whole service and carries only enabled: search, browser, ticket, crm, canvas or cut. The ticket service is bound by default: a service agent whose list has no ticket entry may call the ticket API, and {"type": "ticket", "enabled": false} removes it. Every other service stays closed until it is bound. An open service allows every public method of that service. At most 20 bindings per type, no repeated type and id, and each service type at most once. A session is authorized by the agent version it runs: newly added bindings apply only to new sessions, and a version saved with apply=false changes no access until it is applied. Applying a version that disables, removes or downgrades a binding revokes it immediately in running sessions on older versions. A resource that is not bound returns 404, a service that is not opened returns 403, and a write to a resource bound read_only returns 403 BINDING_READ_ONLY. Unknown types, fields on the wrong kind (id, access or instructions on a service binding), wrong access and malformed ids return 400. The former databases, vector_stores and files fields are removed and return 400. Omit on create for the default: the ticket service only. Saving checks added or changed database, vector_store, media_library and file bindings in the organization: unknown or deleted ids return 400. If an owner is unavailable or takes more than 3 seconds, saving succeeds with verified=false for the affected bindings. Unchanged bindings keep their previous verification result and are not rechecked. workflow and script ids are not verified at save time.`
|
|
7092
7092
|
},
|
|
7093
7093
|
{
|
|
7094
7094
|
name: "kind",
|
|
@@ -14312,6 +14312,16 @@ file at the root of that directory.`
|
|
|
14312
14312
|
required: false,
|
|
14313
14313
|
description: "可省略;账户使用 default 项目。"
|
|
14314
14314
|
},
|
|
14315
|
+
{
|
|
14316
|
+
name: "visibility",
|
|
14317
|
+
type: "string",
|
|
14318
|
+
enum: [
|
|
14319
|
+
"private",
|
|
14320
|
+
"organization"
|
|
14321
|
+
],
|
|
14322
|
+
required: false,
|
|
14323
|
+
description: "谁能看到这个新会话:默认 private 只有创建者;organization 允许同组织其他成员只读观看画面。"
|
|
14324
|
+
},
|
|
14315
14325
|
{
|
|
14316
14326
|
name: "keepAlive",
|
|
14317
14327
|
type: "boolean",
|
|
@@ -14503,6 +14513,42 @@ file at the root of that directory.`
|
|
|
14503
14513
|
}
|
|
14504
14514
|
]
|
|
14505
14515
|
},
|
|
14516
|
+
{
|
|
14517
|
+
resource: "browser.sessions",
|
|
14518
|
+
method: "retrieveFrame",
|
|
14519
|
+
summary: "读取会话只读画面帧",
|
|
14520
|
+
description: "读取会话的一张只读画面帧(JPEG 字节)。创建者可读,同组织其他成员只在该会话声明为组织可见时可读;其余情况一律返回 404 SESSION_NOT_FOUND,不提示会话是否存在。响应体没有任何可控制浏览器的凭据,且不接受任何动作参数。",
|
|
14521
|
+
http: "GET",
|
|
14522
|
+
path: "/browser/v1/sessions/{sessionId}/frame",
|
|
14523
|
+
streaming: "no",
|
|
14524
|
+
pagination: false,
|
|
14525
|
+
pathParams: [
|
|
14526
|
+
{
|
|
14527
|
+
name: "sessionId",
|
|
14528
|
+
sdkName: "sessionId",
|
|
14529
|
+
description: "浏览器会话 ID;使用创建或列出会话返回的 id,以 bss_ 开头。"
|
|
14530
|
+
}
|
|
14531
|
+
],
|
|
14532
|
+
query: []
|
|
14533
|
+
},
|
|
14534
|
+
{
|
|
14535
|
+
resource: "browser.sessions",
|
|
14536
|
+
method: "frames",
|
|
14537
|
+
summary: "订阅会话只读画面",
|
|
14538
|
+
description: "SSE:只推送只读画面帧,event 为 frame 或 end,data 为帧的 JSON 或 null;帧 data 是 JPEG 的 base64 编码,ts 是浏览器产生该帧的时刻(epoch 毫秒),约每秒最多 5 帧。评论 ping 每 15 秒一次,end 后关闭。这条通道与 /sessions/{sessionId}/stream 相互独立:它的消息只含画面,绝不含 wsUrl、signingKey、connectUrl、debuggerUrl、debuggerFullscreenUrl。创建者可订阅,同组织其他成员只在该会话声明为组织可见时可订阅;其余情况一律返回 404 SESSION_NOT_FOUND。",
|
|
14539
|
+
http: "GET",
|
|
14540
|
+
path: "/browser/v1/sessions/{sessionId}/frames",
|
|
14541
|
+
streaming: "always",
|
|
14542
|
+
pagination: false,
|
|
14543
|
+
pathParams: [
|
|
14544
|
+
{
|
|
14545
|
+
name: "sessionId",
|
|
14546
|
+
sdkName: "sessionId",
|
|
14547
|
+
description: "浏览器会话 ID;使用创建或列出会话返回的 id,以 bss_ 开头。"
|
|
14548
|
+
}
|
|
14549
|
+
],
|
|
14550
|
+
query: []
|
|
14551
|
+
},
|
|
14506
14552
|
{
|
|
14507
14553
|
resource: "browser.sessions.handoff",
|
|
14508
14554
|
method: "create",
|
|
@@ -14599,6 +14645,16 @@ file at the root of that directory.`
|
|
|
14599
14645
|
type: "string",
|
|
14600
14646
|
required: true,
|
|
14601
14647
|
description: "当前观看者的稳定标识;同一观看者重复心跳应使用相同值,长度为 1–128 个 UTF-16 代码单元。"
|
|
14648
|
+
},
|
|
14649
|
+
{
|
|
14650
|
+
name: "kind",
|
|
14651
|
+
type: "string",
|
|
14652
|
+
enum: [
|
|
14653
|
+
"control",
|
|
14654
|
+
"readonly"
|
|
14655
|
+
],
|
|
14656
|
+
required: false,
|
|
14657
|
+
description: "观看者类型:control 是需要控制浏览器的客户端,readonly 是只读观看者。只读观看者发送 control 也会按 readonly 记录。"
|
|
14602
14658
|
}
|
|
14603
14659
|
]
|
|
14604
14660
|
}
|
|
@@ -21832,7 +21888,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
|
|
|
21832
21888
|
resource: "media.libraries.assets",
|
|
21833
21889
|
method: "list",
|
|
21834
21890
|
summary: "List assets",
|
|
21835
|
-
description: "Upload content into an active library and return
|
|
21891
|
+
description: "Upload content into an active library and return the stored asset. Use file for a multipart file, data URI, public HTTPS URL or same-owner file identifier. Reusing public_id overwrites by default; overwrite=false returns the existing asset. Chunk uploads require both chunk headers.",
|
|
21836
21892
|
http: "GET",
|
|
21837
21893
|
path: "/media/v1/libraries/{library_id}/assets",
|
|
21838
21894
|
streaming: "no",
|
|
@@ -21851,17 +21907,6 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
|
|
|
21851
21907
|
required: false,
|
|
21852
21908
|
description: "Filter by the exact organizational folder path; an empty value selects assets at the root. Descendant folders are not included."
|
|
21853
21909
|
},
|
|
21854
|
-
{
|
|
21855
|
-
name: "resource_type",
|
|
21856
|
-
type: "string",
|
|
21857
|
-
enum: [
|
|
21858
|
-
"image",
|
|
21859
|
-
"video",
|
|
21860
|
-
"raw"
|
|
21861
|
-
],
|
|
21862
|
-
required: false,
|
|
21863
|
-
description: "image, video (including audio), raw; auto is accepted by Upload actions only, and listing with auto returns 400."
|
|
21864
|
-
},
|
|
21865
21910
|
{
|
|
21866
21911
|
name: "material_type",
|
|
21867
21912
|
type: "string",
|
|
@@ -21876,10 +21921,11 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
|
|
|
21876
21921
|
"text_template",
|
|
21877
21922
|
"animation_preset",
|
|
21878
21923
|
"lut",
|
|
21879
|
-
"transition_map"
|
|
21924
|
+
"transition_map",
|
|
21925
|
+
"file"
|
|
21880
21926
|
],
|
|
21881
21927
|
required: false,
|
|
21882
|
-
description: "Filter assets to one kind of material
|
|
21928
|
+
description: "Filter assets to one kind of material. Audio is one material type; use audio_role to tell speech, music and sound effects apart. Omit to list every material type."
|
|
21883
21929
|
},
|
|
21884
21930
|
{
|
|
21885
21931
|
name: "cursor",
|
|
@@ -21994,18 +22040,6 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
|
|
|
21994
22040
|
required: false,
|
|
21995
22041
|
description: "Requires an image and visual understanding enabled in the library; otherwise returns UNSUPPORTED. Tagging is asynchronous."
|
|
21996
22042
|
},
|
|
21997
|
-
{
|
|
21998
|
-
name: "resource_type",
|
|
21999
|
-
type: "string",
|
|
22000
|
-
enum: [
|
|
22001
|
-
"image",
|
|
22002
|
-
"video",
|
|
22003
|
-
"raw",
|
|
22004
|
-
"auto"
|
|
22005
|
-
],
|
|
22006
|
-
required: false,
|
|
22007
|
-
description: "Upload category: image for images, video for video or audio, raw for unprocessed files, or auto to detect the category. Defaults to auto."
|
|
22008
|
-
},
|
|
22009
22043
|
{
|
|
22010
22044
|
name: "type",
|
|
22011
22045
|
type: "string",
|
|
@@ -22117,18 +22151,6 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
|
|
|
22117
22151
|
required: false,
|
|
22118
22152
|
description: "Minimum confidence for adding generated labels to tags, from 0 to 1 inclusive. Requires an image and enabled visual understanding; labels appear after processing completes."
|
|
22119
22153
|
},
|
|
22120
|
-
{
|
|
22121
|
-
name: "resource_type",
|
|
22122
|
-
type: "string",
|
|
22123
|
-
enum: [
|
|
22124
|
-
"image",
|
|
22125
|
-
"video",
|
|
22126
|
-
"raw",
|
|
22127
|
-
"auto"
|
|
22128
|
-
],
|
|
22129
|
-
required: false,
|
|
22130
|
-
description: "Upload category: image for images, video for video or audio, raw for unprocessed files, or auto to detect the category. Defaults to auto."
|
|
22131
|
-
},
|
|
22132
22154
|
{
|
|
22133
22155
|
name: "type",
|
|
22134
22156
|
type: "string",
|
|
@@ -23052,10 +23074,11 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
|
|
|
23052
23074
|
"text_template",
|
|
23053
23075
|
"animation_preset",
|
|
23054
23076
|
"lut",
|
|
23055
|
-
"transition_map"
|
|
23077
|
+
"transition_map",
|
|
23078
|
+
"file"
|
|
23056
23079
|
],
|
|
23057
23080
|
required: false,
|
|
23058
|
-
description: "What this asset is as a reusable material
|
|
23081
|
+
description: "What this asset is as a reusable material. Always present: a file whose specific kind cannot be identified is file."
|
|
23059
23082
|
}
|
|
23060
23083
|
]
|
|
23061
23084
|
}
|
|
@@ -23121,7 +23144,7 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
|
|
|
23121
23144
|
type: "array",
|
|
23122
23145
|
itemType: "string",
|
|
23123
23146
|
enum: [
|
|
23124
|
-
"
|
|
23147
|
+
"material_type",
|
|
23125
23148
|
"format",
|
|
23126
23149
|
"asset_folder",
|
|
23127
23150
|
"processing_state"
|
|
@@ -23194,10 +23217,11 @@ The default is return=minimal: success returns HTTP 201 with an empty body. Send
|
|
|
23194
23217
|
"text_template",
|
|
23195
23218
|
"animation_preset",
|
|
23196
23219
|
"lut",
|
|
23197
|
-
"transition_map"
|
|
23220
|
+
"transition_map",
|
|
23221
|
+
"file"
|
|
23198
23222
|
],
|
|
23199
23223
|
required: false,
|
|
23200
|
-
description: "What this asset is as a reusable material
|
|
23224
|
+
description: "What this asset is as a reusable material. Always present: a file whose specific kind cannot be identified is file."
|
|
23201
23225
|
}
|
|
23202
23226
|
]
|
|
23203
23227
|
}
|
|
@@ -25093,7 +25117,8 @@ for more details.`
|
|
|
25093
25117
|
"openai.images.generations",
|
|
25094
25118
|
"openai.responses",
|
|
25095
25119
|
"openai.videos",
|
|
25096
|
-
"typesafe.systemone"
|
|
25120
|
+
"typesafe.systemone",
|
|
25121
|
+
"volcengine.voice_clone"
|
|
25097
25122
|
],
|
|
25098
25123
|
required: false,
|
|
25099
25124
|
description: "Match any comma-separated declared protocol ID; omitted or empty includes all models. Combined with type and output_modalities using AND. Invalid IDs return 400 with all legal values."
|
|
@@ -29193,6 +29218,12 @@ for more details.`
|
|
|
29193
29218
|
required: true,
|
|
29194
29219
|
description: "Name as the text will mention it; it must be unique inside this library after normalization, and it is what a unit claims when it links this entry."
|
|
29195
29220
|
},
|
|
29221
|
+
{
|
|
29222
|
+
name: "group",
|
|
29223
|
+
type: "string",
|
|
29224
|
+
required: false,
|
|
29225
|
+
description: "Free-text group to file this entry under, such as a layer of the setting, a faction or a cast, so people and later sessions find related entries together; leave it out or send an empty string for no group. At most 60 characters."
|
|
29226
|
+
},
|
|
29196
29227
|
{
|
|
29197
29228
|
name: "aliases",
|
|
29198
29229
|
type: "array",
|
|
@@ -29364,6 +29395,12 @@ for more details.`
|
|
|
29364
29395
|
required: false,
|
|
29365
29396
|
description: "New name for this entry, which also changes what the text has to mention for detection to find it."
|
|
29366
29397
|
},
|
|
29398
|
+
{
|
|
29399
|
+
name: "group",
|
|
29400
|
+
type: "string",
|
|
29401
|
+
required: false,
|
|
29402
|
+
description: "New group, replacing the previous one when group is named in the update mask; an empty string removes the entry from its group. At most 60 characters."
|
|
29403
|
+
},
|
|
29367
29404
|
{
|
|
29368
29405
|
name: "aliases",
|
|
29369
29406
|
type: "array",
|
|
@@ -32261,6 +32298,31 @@ for more details.`
|
|
|
32261
32298
|
}
|
|
32262
32299
|
]
|
|
32263
32300
|
},
|
|
32301
|
+
{
|
|
32302
|
+
resource: "ticket.repositories",
|
|
32303
|
+
method: "update",
|
|
32304
|
+
summary: "Update repositories",
|
|
32305
|
+
description: "Update repositories within the authenticated organization. Obtain resource identifiers from the corresponding list or create response. Writes complete synchronously; read the returned resource to observe the result. Service authorization applies to the verified human subject.",
|
|
32306
|
+
http: "PATCH",
|
|
32307
|
+
path: "/ticket/v1/repositories/{id}",
|
|
32308
|
+
streaming: "no",
|
|
32309
|
+
pagination: false,
|
|
32310
|
+
pathParams: [
|
|
32311
|
+
{
|
|
32312
|
+
name: "id",
|
|
32313
|
+
sdkName: "id",
|
|
32314
|
+
description: "Identifier returned by the matching create or list operation; number paths take repository-local numbers."
|
|
32315
|
+
}
|
|
32316
|
+
],
|
|
32317
|
+
query: [
|
|
32318
|
+
{
|
|
32319
|
+
name: "repository",
|
|
32320
|
+
type: "string",
|
|
32321
|
+
required: false,
|
|
32322
|
+
description: "Repository id from GET /ticket/v1/repositories; omit for the default tickets container."
|
|
32323
|
+
}
|
|
32324
|
+
]
|
|
32325
|
+
},
|
|
32264
32326
|
{
|
|
32265
32327
|
resource: "ticket.tickets",
|
|
32266
32328
|
method: "list",
|
|
@@ -35680,6 +35742,15 @@ var browserViewerHeartbeat = (options) => (options.client ?? client).post({
|
|
|
35680
35742
|
...options.headers
|
|
35681
35743
|
}
|
|
35682
35744
|
});
|
|
35745
|
+
var browserGetSessionFrame = (options) => (options.client ?? client).get({
|
|
35746
|
+
security: [{
|
|
35747
|
+
key: "BrowserBearer",
|
|
35748
|
+
scheme: "bearer",
|
|
35749
|
+
type: "http"
|
|
35750
|
+
}],
|
|
35751
|
+
url: "/browser/v1/sessions/{sessionId}/frame",
|
|
35752
|
+
...options
|
|
35753
|
+
});
|
|
35683
35754
|
var browserListContexts = (options) => (options?.client ?? client).get({
|
|
35684
35755
|
security: [{
|
|
35685
35756
|
key: "BrowserBearer",
|
|
@@ -35768,6 +35839,15 @@ var browserStreamSession = (options) => (options.client ?? client).sse.get({
|
|
|
35768
35839
|
url: "/browser/v1/sessions/{sessionId}/stream",
|
|
35769
35840
|
...options
|
|
35770
35841
|
});
|
|
35842
|
+
var browserStreamSessionFrames = (options) => (options.client ?? client).sse.get({
|
|
35843
|
+
security: [{
|
|
35844
|
+
key: "BrowserBearer",
|
|
35845
|
+
scheme: "bearer",
|
|
35846
|
+
type: "http"
|
|
35847
|
+
}],
|
|
35848
|
+
url: "/browser/v1/sessions/{sessionId}/frames",
|
|
35849
|
+
...options
|
|
35850
|
+
});
|
|
35771
35851
|
var browserSeleniumUnsupported = (options) => (options?.client ?? client).get({
|
|
35772
35852
|
security: [{
|
|
35773
35853
|
key: "BrowserBearer",
|
|
@@ -44187,6 +44267,19 @@ var ticketGetRepositories = (options) => (options?.client ?? client).get({
|
|
|
44187
44267
|
url: "/ticket/v1/repositories",
|
|
44188
44268
|
...options
|
|
44189
44269
|
});
|
|
44270
|
+
var ticketPatchRepositoriesId = (options) => (options.client ?? client).patch({
|
|
44271
|
+
security: [{
|
|
44272
|
+
key: "BearerAuth",
|
|
44273
|
+
scheme: "bearer",
|
|
44274
|
+
type: "http"
|
|
44275
|
+
}, {
|
|
44276
|
+
key: "ApiKeyAuth",
|
|
44277
|
+
name: "X-API-Key",
|
|
44278
|
+
type: "apiKey"
|
|
44279
|
+
}],
|
|
44280
|
+
url: "/ticket/v1/repositories/{id}",
|
|
44281
|
+
...options
|
|
44282
|
+
});
|
|
44190
44283
|
|
|
44191
44284
|
// ../../packages/sdk/typescript/src/core/pagination.ts
|
|
44192
44285
|
class Page {
|
|
@@ -44634,6 +44727,7 @@ function createBrowser(transport) {
|
|
|
44634
44727
|
events: {
|
|
44635
44728
|
list: bind(transport, browserListEvents)
|
|
44636
44729
|
},
|
|
44730
|
+
frames: bindStream(transport, browserStreamSessionFrames),
|
|
44637
44731
|
handoff: {
|
|
44638
44732
|
complete: bind(transport, browserCompleteHandoff),
|
|
44639
44733
|
create: bind(transport, browserRequestHandoff)
|
|
@@ -44641,6 +44735,7 @@ function createBrowser(transport) {
|
|
|
44641
44735
|
list: bind(transport, browserListSessions),
|
|
44642
44736
|
retrieve: bind(transport, browserGetSession),
|
|
44643
44737
|
retrieveDebug: bind(transport, browserGetDebug),
|
|
44738
|
+
retrieveFrame: bind(transport, browserGetSessionFrame),
|
|
44644
44739
|
stream: bindStream(transport, browserStreamSession),
|
|
44645
44740
|
update: bind(transport, browserCloseSession),
|
|
44646
44741
|
viewer: {
|
|
@@ -45480,7 +45575,8 @@ function createTicket(transport) {
|
|
|
45480
45575
|
update: bind(transport, ticketPatchMilestonesNumber)
|
|
45481
45576
|
},
|
|
45482
45577
|
repositories: {
|
|
45483
|
-
list: bind(transport, ticketGetRepositories)
|
|
45578
|
+
list: bind(transport, ticketGetRepositories),
|
|
45579
|
+
update: bind(transport, ticketPatchRepositoriesId)
|
|
45484
45580
|
},
|
|
45485
45581
|
tickets: {
|
|
45486
45582
|
comments: {
|
|
@@ -49769,7 +49865,7 @@ function retop(store, id, top, rev) {
|
|
|
49769
49865
|
// ../../packages/canvas/document/src/connector.ts
|
|
49770
49866
|
var MAGNETS = ["auto", "center", "top", "right", "bottom", "left"];
|
|
49771
49867
|
var ARROWS = ["end", "start", "both", "none"];
|
|
49772
|
-
var ROUTES = ["straight"];
|
|
49868
|
+
var ROUTES = ["straight", "elbow"];
|
|
49773
49869
|
var ARROW_LENGTH_FACTOR = 6;
|
|
49774
49870
|
var ARROW_HALF_ANGLE_DEG = 25;
|
|
49775
49871
|
var EPSILON = 0.000000001;
|
|
@@ -49857,6 +49953,30 @@ function normalize(p) {
|
|
|
49857
49953
|
const l = Math.hypot(p.x, p.y);
|
|
49858
49954
|
return { x: p.x / l, y: p.y / l };
|
|
49859
49955
|
}
|
|
49956
|
+
function rectsOverlap(a, b) {
|
|
49957
|
+
return a.x < b.x + b.width && b.x < a.x + a.width && a.y < b.y + b.height && b.y < a.y + a.height;
|
|
49958
|
+
}
|
|
49959
|
+
function segmentCrossesBox(a, b, box) {
|
|
49960
|
+
const shrink = 0.000001;
|
|
49961
|
+
const dx = b.x - a.x;
|
|
49962
|
+
const dy = b.y - a.y;
|
|
49963
|
+
let t0 = 0;
|
|
49964
|
+
let t1 = 1;
|
|
49965
|
+
const slab = (start, delta, min, max) => {
|
|
49966
|
+
if (Math.abs(delta) < 0.000000000001)
|
|
49967
|
+
return start > min && start < max;
|
|
49968
|
+
const ta = (min - start) / delta;
|
|
49969
|
+
const tb = (max - start) / delta;
|
|
49970
|
+
t0 = Math.max(t0, Math.min(ta, tb));
|
|
49971
|
+
t1 = Math.min(t1, Math.max(ta, tb));
|
|
49972
|
+
return t0 <= t1;
|
|
49973
|
+
};
|
|
49974
|
+
if (!slab(a.x, dx, box.x + shrink, box.x + box.width - shrink))
|
|
49975
|
+
return false;
|
|
49976
|
+
if (!slab(a.y, dy, box.y + shrink, box.y + box.height - shrink))
|
|
49977
|
+
return false;
|
|
49978
|
+
return t1 > t0;
|
|
49979
|
+
}
|
|
49860
49980
|
function dashRanges(length, dash) {
|
|
49861
49981
|
const pattern = (dash ?? []).filter((d) => typeof d === "number" && Number.isFinite(d) && d > 0);
|
|
49862
49982
|
if (!pattern.length)
|
|
@@ -49878,40 +49998,106 @@ function n(value) {
|
|
|
49878
49998
|
const rounded = Math.round(value * 100) / 100;
|
|
49879
49999
|
return String(Object.is(rounded, -0) ? 0 : rounded);
|
|
49880
50000
|
}
|
|
50001
|
+
var isHorizontal = (side) => side === "left" || side === "right";
|
|
50002
|
+
function elbowPath(from, to, fromMagnet, toMagnet) {
|
|
50003
|
+
if (fromMagnet === "center" || toMagnet === "center")
|
|
50004
|
+
throw new OpRejectedError({
|
|
50005
|
+
code: "INVALID_VALUE",
|
|
50006
|
+
property: fromMagnet === "center" ? "fromMagnet" : "toMagnet",
|
|
50007
|
+
reason: "elbow routing needs an edge, not the centre"
|
|
50008
|
+
});
|
|
50009
|
+
const dx = centerOf(to.box).x - centerOf(from.box).x;
|
|
50010
|
+
const dy = centerOf(to.box).y - centerOf(from.box).y;
|
|
50011
|
+
const across = Math.abs(dx) > Math.abs(dy);
|
|
50012
|
+
const fromSide = fromMagnet === "auto" ? across ? dx > 0 ? "right" : "left" : dy > 0 ? "bottom" : "top" : fromMagnet;
|
|
50013
|
+
const toSide = toMagnet === "auto" ? across ? dx > 0 ? "left" : "right" : dy > 0 ? "top" : "bottom" : toMagnet;
|
|
50014
|
+
const p1 = magnetPoint(from.box, fromSide);
|
|
50015
|
+
const p2 = magnetPoint(to.box, toSide);
|
|
50016
|
+
const out = [p1];
|
|
50017
|
+
if (isHorizontal(fromSide) === isHorizontal(toSide)) {
|
|
50018
|
+
if (isHorizontal(fromSide)) {
|
|
50019
|
+
const midX = (p1.x + p2.x) / 2;
|
|
50020
|
+
out.push({ x: midX, y: p1.y }, { x: midX, y: p2.y });
|
|
50021
|
+
} else {
|
|
50022
|
+
const midY = (p1.y + p2.y) / 2;
|
|
50023
|
+
out.push({ x: p1.x, y: midY }, { x: p2.x, y: midY });
|
|
50024
|
+
}
|
|
50025
|
+
} else {
|
|
50026
|
+
out.push(isHorizontal(fromSide) ? { x: p2.x, y: p1.y } : { x: p1.x, y: p2.y });
|
|
50027
|
+
}
|
|
50028
|
+
out.push(p2);
|
|
50029
|
+
const kept = [];
|
|
50030
|
+
for (const p of out) {
|
|
50031
|
+
const last = kept[kept.length - 1];
|
|
50032
|
+
if (last && last.x === p.x && last.y === p.y)
|
|
50033
|
+
continue;
|
|
50034
|
+
if (last && kept.length >= 2) {
|
|
50035
|
+
const before = kept[kept.length - 2];
|
|
50036
|
+
if (before.x === last.x && last.x === p.x || before.y === last.y && last.y === p.y)
|
|
50037
|
+
kept.pop();
|
|
50038
|
+
}
|
|
50039
|
+
kept.push(p);
|
|
50040
|
+
}
|
|
50041
|
+
return kept;
|
|
50042
|
+
}
|
|
50043
|
+
function cumulative(points) {
|
|
50044
|
+
const cum = [0];
|
|
50045
|
+
for (let i = 1;i < points.length; i++)
|
|
50046
|
+
cum.push(cum[i - 1] + Math.hypot(points[i].x - points[i - 1].x, points[i].y - points[i - 1].y));
|
|
50047
|
+
return cum;
|
|
50048
|
+
}
|
|
50049
|
+
function pointAt(points, cum, s) {
|
|
50050
|
+
const total = cum[cum.length - 1];
|
|
50051
|
+
const at = Math.max(0, Math.min(s, total));
|
|
50052
|
+
let i = 0;
|
|
50053
|
+
while (i < points.length - 2 && cum[i + 1] < at)
|
|
50054
|
+
i++;
|
|
50055
|
+
const span = cum[i + 1] - cum[i];
|
|
50056
|
+
const f = span < EPSILON ? 0 : (at - cum[i]) / span;
|
|
50057
|
+
const a = points[i];
|
|
50058
|
+
const b = points[i + 1];
|
|
50059
|
+
return { x: a.x + (b.x - a.x) * f, y: a.y + (b.y - a.y) * f };
|
|
50060
|
+
}
|
|
49881
50061
|
function connectorGeometry(from, to, opts = {}) {
|
|
49882
50062
|
const arrow = opts.arrow ?? "end";
|
|
49883
50063
|
const strokeWidth = opts.strokeWidth ?? 1.5;
|
|
49884
50064
|
const labelPos = opts.labelPos ?? 0.5;
|
|
49885
50065
|
const fromMagnet = opts.fromMagnet ?? "auto";
|
|
49886
50066
|
const toMagnet = opts.toMagnet ?? "auto";
|
|
49887
|
-
|
|
49888
|
-
|
|
49889
|
-
const
|
|
49890
|
-
const
|
|
49891
|
-
const length =
|
|
50067
|
+
if (rectsOverlap(from.box, to.box))
|
|
50068
|
+
throw new OpRejectedError({ code: "INVALID_VALUE", property: "from", reason: "nodes overlap" });
|
|
50069
|
+
const points = (opts.route ?? "straight") === "elbow" ? elbowPath(from, to, fromMagnet, toMagnet) : [endPoint(from, fromMagnet, centerOf(to.box)), endPoint(to, toMagnet, centerOf(from.box))];
|
|
50070
|
+
const cum = cumulative(points);
|
|
50071
|
+
const length = cum[cum.length - 1];
|
|
50072
|
+
const p1 = points[0];
|
|
50073
|
+
const p2 = points[points.length - 1];
|
|
49892
50074
|
if (length < EPSILON || inside(p1, to.box) || inside(p2, from.box))
|
|
49893
50075
|
throw new OpRejectedError({ code: "INVALID_VALUE", property: "from", reason: "nodes overlap" });
|
|
49894
|
-
const
|
|
49895
|
-
const
|
|
50076
|
+
const dir1 = normalize({ x: points[1].x - p1.x, y: points[1].y - p1.y });
|
|
50077
|
+
const dir2 = normalize({ x: p2.x - points[points.length - 2].x, y: p2.y - points[points.length - 2].y });
|
|
50078
|
+
const back = { x: -dir2.x, y: -dir2.y };
|
|
49896
50079
|
const arrowHeads = [];
|
|
49897
50080
|
if (arrow === "end" || arrow === "both")
|
|
49898
50081
|
arrowHeads.push(arrowHead(p2, back, strokeWidth));
|
|
49899
50082
|
if (arrow === "start" || arrow === "both")
|
|
49900
|
-
arrowHeads.push(arrowHead(p1,
|
|
49901
|
-
const xs =
|
|
49902
|
-
const ys =
|
|
50083
|
+
arrowHeads.push(arrowHead(p1, dir1, strokeWidth));
|
|
50084
|
+
const xs = points.map((p) => p.x);
|
|
50085
|
+
const ys = points.map((p) => p.y);
|
|
49903
50086
|
for (const head of arrowHeads) {
|
|
49904
50087
|
xs.push(head.tip.x, head.left.x, head.right.x);
|
|
49905
50088
|
ys.push(head.tip.y, head.left.y, head.right.y);
|
|
49906
50089
|
}
|
|
49907
50090
|
const bbox = { x: Math.min(...xs), y: Math.min(...ys), width: Math.max(...xs) - Math.min(...xs), height: Math.max(...ys) - Math.min(...ys) };
|
|
49908
50091
|
const local = (p) => ({ x: p.x - bbox.x, y: p.y - bbox.y });
|
|
49909
|
-
const at = (t) => ({ x: p1.x + (p2.x - p1.x) * t, y: p1.y + (p2.y - p1.y) * t });
|
|
49910
50092
|
const parts = [];
|
|
49911
50093
|
for (const [start, end] of dashRanges(length, opts.dash)) {
|
|
49912
|
-
const
|
|
49913
|
-
|
|
49914
|
-
|
|
50094
|
+
const run = [pointAt(points, cum, start)];
|
|
50095
|
+
for (let i = 1;i < points.length - 1; i++)
|
|
50096
|
+
if (cum[i] > start + EPSILON && cum[i] < end - EPSILON)
|
|
50097
|
+
run.push(points[i]);
|
|
50098
|
+
run.push(pointAt(points, cum, end));
|
|
50099
|
+
const traced = run.length > 2 ? [...run, ...run.slice(0, -1).reverse()] : run;
|
|
50100
|
+
parts.push(traced.map((p, i) => `${i ? "L" : "M"}${n(local(p).x)} ${n(local(p).y)}`).join(""));
|
|
49915
50101
|
}
|
|
49916
50102
|
for (const head of arrowHeads) {
|
|
49917
50103
|
const t = local(head.tip);
|
|
@@ -49919,7 +50105,7 @@ function connectorGeometry(from, to, opts = {}) {
|
|
|
49919
50105
|
const r = local(head.right);
|
|
49920
50106
|
parts.push(`M${n(t.x)} ${n(t.y)}L${n(l.x)} ${n(l.y)}L${n(r.x)} ${n(r.y)}Z`);
|
|
49921
50107
|
}
|
|
49922
|
-
return { points: [p1, p2], arrowHeads, bbox, labelCenter:
|
|
50108
|
+
return { points: [p1, p2], polyline: points, arrowHeads, bbox, labelCenter: pointAt(points, cum, labelPos * length), geometry: parts.join("") };
|
|
49923
50109
|
}
|
|
49924
50110
|
// ../../packages/canvas/document/src/expand.ts
|
|
49925
50111
|
function defaultTheme(themes) {
|
|
@@ -50198,10 +50384,476 @@ function checkLiveNode(node2) {
|
|
|
50198
50384
|
return { warnings };
|
|
50199
50385
|
}
|
|
50200
50386
|
|
|
50387
|
+
// ../../packages/canvas/document/src/kit.ts
|
|
50388
|
+
function kitStampOf(node2) {
|
|
50389
|
+
const meta = node2?.metadata;
|
|
50390
|
+
const stamp = meta?.kit;
|
|
50391
|
+
if (!stamp || typeof stamp.key !== "string" || typeof stamp.version !== "number" || typeof stamp.name !== "string")
|
|
50392
|
+
return;
|
|
50393
|
+
return { name: stamp.name, version: stamp.version, key: stamp.key };
|
|
50394
|
+
}
|
|
50395
|
+
function remapRefs(node2, refId) {
|
|
50396
|
+
const { children, ...rest } = node2;
|
|
50397
|
+
const out = { ...rest };
|
|
50398
|
+
if (typeof out.ref === "string")
|
|
50399
|
+
out.ref = refId.get(out.ref) ?? out.ref;
|
|
50400
|
+
const descendants = out.descendants;
|
|
50401
|
+
if (descendants && typeof descendants === "object" && !Array.isArray(descendants)) {
|
|
50402
|
+
const mapped = {};
|
|
50403
|
+
for (const [path, value] of Object.entries(descendants)) {
|
|
50404
|
+
const rewritten = path.split("/").map((seg) => refId.get(seg) ?? seg).join("/");
|
|
50405
|
+
mapped[rewritten] = value;
|
|
50406
|
+
}
|
|
50407
|
+
out.descendants = mapped;
|
|
50408
|
+
}
|
|
50409
|
+
if (Array.isArray(children))
|
|
50410
|
+
out.children = children.map((c) => remapRefs(c, refId));
|
|
50411
|
+
return out;
|
|
50412
|
+
}
|
|
50413
|
+
function planKit(existing, kit) {
|
|
50414
|
+
const canvasId = new Map;
|
|
50415
|
+
const haveVersion = new Map;
|
|
50416
|
+
for (const node2 of existing) {
|
|
50417
|
+
if (canvasId.has(node2.key))
|
|
50418
|
+
continue;
|
|
50419
|
+
canvasId.set(node2.key, node2.id);
|
|
50420
|
+
haveVersion.set(node2.key, node2.version);
|
|
50421
|
+
}
|
|
50422
|
+
const refId = new Map;
|
|
50423
|
+
const keys2 = new Set;
|
|
50424
|
+
for (const component of kit.components) {
|
|
50425
|
+
const stamp = kitStampOf(component);
|
|
50426
|
+
if (!stamp)
|
|
50427
|
+
throw new Error(`kit ${kit.name}: component ${component.id} carries no metadata.kit stamp`);
|
|
50428
|
+
if (keys2.has(stamp.key))
|
|
50429
|
+
throw new Error(`kit ${kit.name}: duplicate component key ${stamp.key}`);
|
|
50430
|
+
keys2.add(stamp.key);
|
|
50431
|
+
refId.set(component.id, canvasId.get(stamp.key) ?? component.id);
|
|
50432
|
+
}
|
|
50433
|
+
const plan = { add: [], update: [], unchanged: 0, variables: Object.keys(kit.variables).length };
|
|
50434
|
+
for (const component of kit.components) {
|
|
50435
|
+
const stamp = kitStampOf(component);
|
|
50436
|
+
const id = refId.get(component.id);
|
|
50437
|
+
const node2 = id === component.id ? remapRefs(component, refId) : { ...remapRefs(component, refId), id };
|
|
50438
|
+
const version = haveVersion.get(stamp.key);
|
|
50439
|
+
if (version === undefined)
|
|
50440
|
+
plan.add.push(node2);
|
|
50441
|
+
else if (version >= kit.version)
|
|
50442
|
+
plan.unchanged++;
|
|
50443
|
+
else
|
|
50444
|
+
plan.update.push({ id, node: node2 });
|
|
50445
|
+
}
|
|
50446
|
+
return plan;
|
|
50447
|
+
}
|
|
50448
|
+
function existingKitNodesIn(store, kitName) {
|
|
50449
|
+
const out = [];
|
|
50450
|
+
const walk = (id) => {
|
|
50451
|
+
const row = store.get(id);
|
|
50452
|
+
if (!row)
|
|
50453
|
+
return;
|
|
50454
|
+
const stamp = kitStampOf(row.props);
|
|
50455
|
+
if (stamp && (kitName === undefined || stamp.name === kitName))
|
|
50456
|
+
out.push({ key: stamp.key, version: stamp.version, id });
|
|
50457
|
+
for (const child of store.children(id))
|
|
50458
|
+
walk(child);
|
|
50459
|
+
};
|
|
50460
|
+
for (const top of store.children(null))
|
|
50461
|
+
walk(top);
|
|
50462
|
+
return out;
|
|
50463
|
+
}
|
|
50464
|
+
function kitFrameIn(store, frame) {
|
|
50465
|
+
return store.children(null).find((id) => {
|
|
50466
|
+
const props = store.get(id)?.props;
|
|
50467
|
+
return props?.type === "frame" && props.name === frame;
|
|
50468
|
+
});
|
|
50469
|
+
}
|
|
50470
|
+
var componentName = (node2) => {
|
|
50471
|
+
const name = node2.name;
|
|
50472
|
+
return typeof name === "string" && name !== "" ? name : kitStampOf(node2).key;
|
|
50473
|
+
};
|
|
50474
|
+
function kitPlanNames(plan) {
|
|
50475
|
+
return { added: plan.add.map(componentName), updated: plan.update.map((u) => componentName(u.node)) };
|
|
50476
|
+
}
|
|
50477
|
+
function planRefs(plan) {
|
|
50478
|
+
const ids = new Set;
|
|
50479
|
+
const refs = [];
|
|
50480
|
+
const visit2 = (node2, collectIds) => {
|
|
50481
|
+
if (collectIds)
|
|
50482
|
+
ids.add(node2.id);
|
|
50483
|
+
if (node2.type === "ref" && typeof node2.ref === "string")
|
|
50484
|
+
refs.push(node2.ref);
|
|
50485
|
+
for (const child of Array.isArray(node2.children) ? node2.children : [])
|
|
50486
|
+
visit2(child, collectIds);
|
|
50487
|
+
};
|
|
50488
|
+
for (const node2 of plan.add)
|
|
50489
|
+
visit2(node2, true);
|
|
50490
|
+
for (const entry of plan.update)
|
|
50491
|
+
visit2(entry.node, false);
|
|
50492
|
+
return { refs, ids };
|
|
50493
|
+
}
|
|
50494
|
+
|
|
50495
|
+
// ../../packages/canvas/document/src/kit-builders.ts
|
|
50496
|
+
var PRAXIS_UI_LITERALS = {
|
|
50497
|
+
"v3-surface-2": "#F1F3F2",
|
|
50498
|
+
"v3-border": "#E3E7E4",
|
|
50499
|
+
"v3-border-strong": "#CDD3CF",
|
|
50500
|
+
"v3-fg": "#0D1310",
|
|
50501
|
+
"v3-fg-2": "#4A5550",
|
|
50502
|
+
"v3-fg-3": "#6E7872",
|
|
50503
|
+
"v3-green-50": "#EEFBF3",
|
|
50504
|
+
"v3-green-700": "#167A43",
|
|
50505
|
+
"v3-code-bg": "#0F1512",
|
|
50506
|
+
"v3-code-fg": "#D6E2DB",
|
|
50507
|
+
"v3-danger": "#D92D20",
|
|
50508
|
+
"v3-danger-soft": "#FEF0EE",
|
|
50509
|
+
"v3-warning": "#C76A00",
|
|
50510
|
+
"v3-warning-soft": "#FFF6E5",
|
|
50511
|
+
"v3-info": "#2563EB",
|
|
50512
|
+
"v3-info-soft": "#EEF4FF",
|
|
50513
|
+
"v3-font": "Geist",
|
|
50514
|
+
"v3-mono": "Geist Mono",
|
|
50515
|
+
"r-md": 8
|
|
50516
|
+
};
|
|
50517
|
+
function token(ctx, name) {
|
|
50518
|
+
return ctx.variables.has(name) ? `$${name}` : PRAXIS_UI_LITERALS[name];
|
|
50519
|
+
}
|
|
50520
|
+
var KIT_LIMITS = {
|
|
50521
|
+
tableRows: 200,
|
|
50522
|
+
codeLines: 200,
|
|
50523
|
+
keyWidth: 240,
|
|
50524
|
+
minColumn: 24
|
|
50525
|
+
};
|
|
50526
|
+
var COLUMN_GAP = 12;
|
|
50527
|
+
var ROW_PADDING = 10;
|
|
50528
|
+
var BODY_SIZE = 13;
|
|
50529
|
+
var HEADER_SIZE = 12;
|
|
50530
|
+
function invalid(property, reason) {
|
|
50531
|
+
throw new OpRejectedError({ code: "INVALID_VALUE", property, reason });
|
|
50532
|
+
}
|
|
50533
|
+
function optionKeys(value, allowed, name) {
|
|
50534
|
+
if (value === undefined || value === null)
|
|
50535
|
+
return {};
|
|
50536
|
+
if (typeof value !== "object" || Array.isArray(value))
|
|
50537
|
+
return invalid(name, "expected an options object");
|
|
50538
|
+
for (const key of Object.keys(value))
|
|
50539
|
+
if (!allowed.includes(key))
|
|
50540
|
+
return invalid(key, `${name} does not take ${key}`);
|
|
50541
|
+
return value;
|
|
50542
|
+
}
|
|
50543
|
+
function requiredString(value, property) {
|
|
50544
|
+
if (typeof value !== "string" || value === "")
|
|
50545
|
+
return invalid(property, "expected a non-empty string");
|
|
50546
|
+
return value;
|
|
50547
|
+
}
|
|
50548
|
+
function optionalString(value, property) {
|
|
50549
|
+
if (value === undefined || value === null)
|
|
50550
|
+
return;
|
|
50551
|
+
return requiredString(value, property);
|
|
50552
|
+
}
|
|
50553
|
+
function containerWidth(value, property) {
|
|
50554
|
+
if (value === undefined || value === null || value === "fill_container")
|
|
50555
|
+
return "fill_container";
|
|
50556
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0)
|
|
50557
|
+
return value;
|
|
50558
|
+
return invalid(property, 'expected a positive number or "fill_container"');
|
|
50559
|
+
}
|
|
50560
|
+
var TABLE_KEYS = ["columns", "rows", "zebra", "width"];
|
|
50561
|
+
var COLUMN_KEYS = ["key", "title", "width", "align"];
|
|
50562
|
+
var requestOf = (width) => typeof width === "number" ? width : KIT_LIMITS.minColumn;
|
|
50563
|
+
function planColumns(columns, total, gap = COLUMN_GAP) {
|
|
50564
|
+
const fills = columns.filter((c) => typeof c.width !== "number").length;
|
|
50565
|
+
if (total === null)
|
|
50566
|
+
return columns.map((c) => typeof c.width === "number" ? c.width : "fill_container");
|
|
50567
|
+
const available = Math.max(0, total - gap * Math.max(0, columns.length - 1));
|
|
50568
|
+
const pinned = columns.reduce((sum, c) => sum + (typeof c.width === "number" ? c.width : 0), 0);
|
|
50569
|
+
const leftover = available - pinned;
|
|
50570
|
+
if (leftover > 0) {
|
|
50571
|
+
if (!fills)
|
|
50572
|
+
return columns.map((c) => c.width);
|
|
50573
|
+
const share = round2(leftover / fills);
|
|
50574
|
+
return columns.map((c) => typeof c.width === "number" ? c.width : share);
|
|
50575
|
+
}
|
|
50576
|
+
const requested = columns.reduce((sum, c) => sum + requestOf(c.width), 0);
|
|
50577
|
+
const scale = requested > 0 ? available / requested : 1;
|
|
50578
|
+
return columns.map((c) => Math.max(1, round2(requestOf(c.width) * scale)));
|
|
50579
|
+
}
|
|
50580
|
+
var round2 = (n2) => Math.round(n2 * 100) / 100;
|
|
50581
|
+
function cellRow(name, cells) {
|
|
50582
|
+
return { type: "frame", name, layout: "horizontal", gap: COLUMN_GAP, padding: [ROW_PADDING, 0], width: "fill_container", children: cells };
|
|
50583
|
+
}
|
|
50584
|
+
function planTable(options, ctx) {
|
|
50585
|
+
const o = optionKeys(options, TABLE_KEYS, "Kit.Table");
|
|
50586
|
+
if (!Array.isArray(o.columns) || o.columns.length === 0)
|
|
50587
|
+
invalid("columns", "expected a non-empty array of { key, title }");
|
|
50588
|
+
const rows = o.rows;
|
|
50589
|
+
if (!Array.isArray(rows))
|
|
50590
|
+
invalid("rows", "expected an array of row objects");
|
|
50591
|
+
if (rows.length > KIT_LIMITS.tableRows)
|
|
50592
|
+
invalid("rows", `${rows.length} rows; a table renders at most ${KIT_LIMITS.tableRows} — split it, or build the frame by hand`);
|
|
50593
|
+
const columns = o.columns.map((raw, i) => {
|
|
50594
|
+
const c = optionKeys(raw, COLUMN_KEYS, `columns[${i}]`);
|
|
50595
|
+
const width2 = c.width;
|
|
50596
|
+
if (width2 !== undefined && width2 !== null && width2 !== "fill" && !(typeof width2 === "number" && Number.isFinite(width2) && width2 > 0))
|
|
50597
|
+
invalid(`columns[${i}].width`, 'expected a positive number or "fill"');
|
|
50598
|
+
const align = c.align;
|
|
50599
|
+
if (align !== undefined && align !== null && align !== "left" && align !== "right")
|
|
50600
|
+
invalid(`columns[${i}].align`, 'expected "left" or "right"');
|
|
50601
|
+
return { key: requiredString(c.key, `columns[${i}].key`), title: requiredString(c.title, `columns[${i}].title`), width: width2, align };
|
|
50602
|
+
});
|
|
50603
|
+
const width = containerWidth(o.width, "width");
|
|
50604
|
+
const widths = planColumns(columns, typeof width === "number" ? width : null, COLUMN_GAP);
|
|
50605
|
+
const font = token(ctx, "v3-font");
|
|
50606
|
+
const headerCell = (title, w, align) => ({
|
|
50607
|
+
type: "text",
|
|
50608
|
+
name: title,
|
|
50609
|
+
content: title,
|
|
50610
|
+
width: w,
|
|
50611
|
+
textGrowth: "fixed-width",
|
|
50612
|
+
fontFamily: font,
|
|
50613
|
+
fontSize: HEADER_SIZE,
|
|
50614
|
+
fontWeight: 600,
|
|
50615
|
+
fill: token(ctx, "v3-fg-2"),
|
|
50616
|
+
...align === "right" ? { textAlign: "right" } : {}
|
|
50617
|
+
});
|
|
50618
|
+
const dataCell = (title, content, w, align) => ({
|
|
50619
|
+
type: "text",
|
|
50620
|
+
name: title,
|
|
50621
|
+
content,
|
|
50622
|
+
width: w,
|
|
50623
|
+
textGrowth: "fixed-width",
|
|
50624
|
+
fontFamily: font,
|
|
50625
|
+
fontSize: BODY_SIZE,
|
|
50626
|
+
fill: token(ctx, "v3-fg"),
|
|
50627
|
+
...align === "right" ? { textAlign: "right" } : {}
|
|
50628
|
+
});
|
|
50629
|
+
const children = [
|
|
50630
|
+
{
|
|
50631
|
+
type: "frame",
|
|
50632
|
+
name: "Header",
|
|
50633
|
+
layout: "vertical",
|
|
50634
|
+
gap: 0,
|
|
50635
|
+
width: "fill_container",
|
|
50636
|
+
stroke: token(ctx, "v3-border-strong"),
|
|
50637
|
+
strokeWidth: { bottom: 1 },
|
|
50638
|
+
strokeAlignment: "inner",
|
|
50639
|
+
children: [cellRow("HeaderRow", columns.map((c, i) => headerCell(c.title, widths[i], c.align)))]
|
|
50640
|
+
}
|
|
50641
|
+
];
|
|
50642
|
+
rows.forEach((row, i) => {
|
|
50643
|
+
const record = row && typeof row === "object" && !Array.isArray(row) ? row : {};
|
|
50644
|
+
children.push({
|
|
50645
|
+
type: "frame",
|
|
50646
|
+
name: "Row",
|
|
50647
|
+
layout: "vertical",
|
|
50648
|
+
gap: 0,
|
|
50649
|
+
width: "fill_container",
|
|
50650
|
+
stroke: token(ctx, "v3-border"),
|
|
50651
|
+
strokeWidth: { bottom: 1 },
|
|
50652
|
+
strokeAlignment: "inner",
|
|
50653
|
+
...o.zebra === true && i % 2 === 1 ? { fill: token(ctx, "v3-surface-2") } : {},
|
|
50654
|
+
children: [cellRow("RowCells", columns.map((c, j) => dataCell(c.key, textOf(record[c.key]), widths[j], c.align)))]
|
|
50655
|
+
});
|
|
50656
|
+
});
|
|
50657
|
+
return { type: "frame", name: "Table", layout: "vertical", gap: 0, width, children };
|
|
50658
|
+
}
|
|
50659
|
+
function textOf(value) {
|
|
50660
|
+
if (value === undefined || value === null)
|
|
50661
|
+
return "";
|
|
50662
|
+
return typeof value === "string" ? value : String(value);
|
|
50663
|
+
}
|
|
50664
|
+
function requiredText(value, property) {
|
|
50665
|
+
if (typeof value !== "string" && typeof value !== "number")
|
|
50666
|
+
return invalid(property, "expected a string or number");
|
|
50667
|
+
return String(value);
|
|
50668
|
+
}
|
|
50669
|
+
var CALLOUT_KEYS = ["tone", "title", "body"];
|
|
50670
|
+
var CALLOUT_TONES = {
|
|
50671
|
+
info: { soft: "v3-info-soft", ink: "v3-info" },
|
|
50672
|
+
success: { soft: "v3-green-50", ink: "v3-green-700" },
|
|
50673
|
+
warning: { soft: "v3-warning-soft", ink: "v3-warning" },
|
|
50674
|
+
danger: { soft: "v3-danger-soft", ink: "v3-danger" }
|
|
50675
|
+
};
|
|
50676
|
+
function planCallout(options, ctx) {
|
|
50677
|
+
const o = optionKeys(options, CALLOUT_KEYS, "Kit.Callout");
|
|
50678
|
+
const tone = o.tone;
|
|
50679
|
+
if (typeof tone !== "string" || !Object.hasOwn(CALLOUT_TONES, tone))
|
|
50680
|
+
invalid("tone", `expected one of ${Object.keys(CALLOUT_TONES).join(", ")}`);
|
|
50681
|
+
const body = requiredString(o.body, "body");
|
|
50682
|
+
const title = optionalString(o.title, "title");
|
|
50683
|
+
const pair = CALLOUT_TONES[tone];
|
|
50684
|
+
const font = token(ctx, "v3-font");
|
|
50685
|
+
const bodyChildren = [];
|
|
50686
|
+
if (title !== undefined)
|
|
50687
|
+
bodyChildren.push({ type: "text", name: "Title", content: title, fontFamily: font, fontSize: BODY_SIZE, fontWeight: 600, fill: token(ctx, pair.ink) });
|
|
50688
|
+
bodyChildren.push({
|
|
50689
|
+
type: "text",
|
|
50690
|
+
name: "Body",
|
|
50691
|
+
content: body,
|
|
50692
|
+
fontFamily: font,
|
|
50693
|
+
fontSize: BODY_SIZE,
|
|
50694
|
+
lineHeight: 1.5,
|
|
50695
|
+
width: "fill_container",
|
|
50696
|
+
textGrowth: "fixed-width",
|
|
50697
|
+
fill: token(ctx, "v3-fg")
|
|
50698
|
+
});
|
|
50699
|
+
return {
|
|
50700
|
+
type: "frame",
|
|
50701
|
+
name: "Callout",
|
|
50702
|
+
layout: "horizontal",
|
|
50703
|
+
gap: 0,
|
|
50704
|
+
width: "fill_container",
|
|
50705
|
+
fill: token(ctx, pair.soft),
|
|
50706
|
+
cornerRadius: token(ctx, "r-md"),
|
|
50707
|
+
clip: true,
|
|
50708
|
+
children: [
|
|
50709
|
+
{ type: "rectangle", name: "Bar", width: 3, height: "fill_container", fill: token(ctx, pair.ink) },
|
|
50710
|
+
{ type: "frame", name: "Content", layout: "vertical", gap: 6, padding: [12, 14], width: "fill_container", children: bodyChildren }
|
|
50711
|
+
]
|
|
50712
|
+
};
|
|
50713
|
+
}
|
|
50714
|
+
var CODE_KEYS = ["lang", "text"];
|
|
50715
|
+
function planCode(options, ctx) {
|
|
50716
|
+
const o = optionKeys(options, CODE_KEYS, "Kit.Code");
|
|
50717
|
+
const lang = optionalString(o.lang, "lang");
|
|
50718
|
+
const text = requiredString(o.text, "text");
|
|
50719
|
+
const lines = text.split(`
|
|
50720
|
+
`);
|
|
50721
|
+
const shown = lines.length > KIT_LIMITS.codeLines ? [...lines.slice(0, KIT_LIMITS.codeLines), `… ${lines.length - KIT_LIMITS.codeLines} more lines`] : lines;
|
|
50722
|
+
const children = [];
|
|
50723
|
+
if (lang !== undefined)
|
|
50724
|
+
children.push({
|
|
50725
|
+
type: "text",
|
|
50726
|
+
name: "Lang",
|
|
50727
|
+
content: lang,
|
|
50728
|
+
width: "fill_container",
|
|
50729
|
+
textGrowth: "fixed-width",
|
|
50730
|
+
textAlign: "right",
|
|
50731
|
+
fontFamily: token(ctx, "v3-mono"),
|
|
50732
|
+
fontSize: 11,
|
|
50733
|
+
fill: token(ctx, "v3-fg-3")
|
|
50734
|
+
});
|
|
50735
|
+
children.push({
|
|
50736
|
+
type: "text",
|
|
50737
|
+
name: "Lines",
|
|
50738
|
+
content: shown.join(`
|
|
50739
|
+
`),
|
|
50740
|
+
fontFamily: token(ctx, "v3-mono"),
|
|
50741
|
+
fontSize: 12,
|
|
50742
|
+
lineHeight: 1.5,
|
|
50743
|
+
width: "fill_container",
|
|
50744
|
+
textGrowth: "fixed-width",
|
|
50745
|
+
fill: token(ctx, "v3-code-fg")
|
|
50746
|
+
});
|
|
50747
|
+
return {
|
|
50748
|
+
type: "frame",
|
|
50749
|
+
name: "Code",
|
|
50750
|
+
layout: "vertical",
|
|
50751
|
+
gap: 6,
|
|
50752
|
+
width: "fill_container",
|
|
50753
|
+
fill: token(ctx, "v3-code-bg"),
|
|
50754
|
+
cornerRadius: token(ctx, "r-md"),
|
|
50755
|
+
padding: 12,
|
|
50756
|
+
clip: true,
|
|
50757
|
+
children
|
|
50758
|
+
};
|
|
50759
|
+
}
|
|
50760
|
+
function indexed(index) {
|
|
50761
|
+
return /^\d+$/.test(index) ? index.padStart(2, "0") : index;
|
|
50762
|
+
}
|
|
50763
|
+
var SECTION_KEYS = ["index", "title", "subtitle"];
|
|
50764
|
+
function planSection(options, ctx) {
|
|
50765
|
+
const o = optionKeys(options, SECTION_KEYS, "Kit.Section");
|
|
50766
|
+
const title = requiredString(o.title, "title");
|
|
50767
|
+
const subtitle = optionalString(o.subtitle, "subtitle");
|
|
50768
|
+
const index = o.index === undefined || o.index === null ? undefined : textOf(o.index);
|
|
50769
|
+
if (index !== undefined && index === "")
|
|
50770
|
+
invalid("index", "expected a non-empty string or number");
|
|
50771
|
+
const font = token(ctx, "v3-font");
|
|
50772
|
+
const heading = {
|
|
50773
|
+
type: "frame",
|
|
50774
|
+
name: "Heading",
|
|
50775
|
+
layout: "horizontal",
|
|
50776
|
+
gap: 8,
|
|
50777
|
+
alignItems: "center",
|
|
50778
|
+
width: "fill_container",
|
|
50779
|
+
children: [
|
|
50780
|
+
...index === undefined ? [] : [{ type: "text", name: "Index", content: indexed(index), fontFamily: font, fontSize: 14, fill: token(ctx, "v3-fg-3") }],
|
|
50781
|
+
{ type: "text", name: "Title", content: title, fontFamily: font, fontSize: 20, fontWeight: 600, fill: token(ctx, "v3-fg"), width: "fill_container", textGrowth: "fixed-width" }
|
|
50782
|
+
]
|
|
50783
|
+
};
|
|
50784
|
+
const children = [heading];
|
|
50785
|
+
if (subtitle !== undefined)
|
|
50786
|
+
children.push({ type: "text", name: "Subtitle", content: subtitle, fontFamily: font, fontSize: BODY_SIZE, fill: token(ctx, "v3-fg-2"), width: "fill_container", textGrowth: "fixed-width" });
|
|
50787
|
+
return { type: "frame", name: "Section", layout: "vertical", gap: 4, padding: [0, 0, 16, 0], width: "fill_container", children };
|
|
50788
|
+
}
|
|
50789
|
+
function planKeyValue(rows, ctx) {
|
|
50790
|
+
if (!Array.isArray(rows) || rows.length === 0)
|
|
50791
|
+
invalid("rows", "expected a non-empty array of { key, value }");
|
|
50792
|
+
const font = token(ctx, "v3-font");
|
|
50793
|
+
const parsed = rows.map((raw, i) => {
|
|
50794
|
+
const r = optionKeys(raw, ["key", "value"], `rows[${i}]`);
|
|
50795
|
+
return { key: requiredString(r.key, `rows[${i}].key`), value: requiredText(r.value, `rows[${i}].value`) };
|
|
50796
|
+
});
|
|
50797
|
+
const measured = Math.max(...parsed.map((r) => ctx.measure({ content: r.key, fontFamily: String(font), fontSize: BODY_SIZE }).width));
|
|
50798
|
+
const keyWidth = Math.min(KIT_LIMITS.keyWidth, Math.max(1, Math.ceil(measured)));
|
|
50799
|
+
return {
|
|
50800
|
+
type: "frame",
|
|
50801
|
+
name: "KeyValue",
|
|
50802
|
+
layout: "vertical",
|
|
50803
|
+
gap: 0,
|
|
50804
|
+
width: "fill_container",
|
|
50805
|
+
children: parsed.map((r) => ({
|
|
50806
|
+
type: "frame",
|
|
50807
|
+
name: "KeyValueRow",
|
|
50808
|
+
layout: "horizontal",
|
|
50809
|
+
gap: 12,
|
|
50810
|
+
padding: [6, 0],
|
|
50811
|
+
width: "fill_container",
|
|
50812
|
+
children: [
|
|
50813
|
+
{ type: "text", name: "Key", content: r.key, fontFamily: font, fontSize: BODY_SIZE, fill: token(ctx, "v3-fg-3"), width: keyWidth, textGrowth: "fixed-width" },
|
|
50814
|
+
{ type: "text", name: "Value", content: r.value, fontFamily: font, fontSize: BODY_SIZE, fill: token(ctx, "v3-fg"), width: "fill_container", textGrowth: "fixed-width" }
|
|
50815
|
+
]
|
|
50816
|
+
}))
|
|
50817
|
+
};
|
|
50818
|
+
}
|
|
50819
|
+
var KIT_BUILDERS = {
|
|
50820
|
+
table: planTable,
|
|
50821
|
+
callout: planCallout,
|
|
50822
|
+
code: planCode,
|
|
50823
|
+
section: planSection,
|
|
50824
|
+
"key-value": planKeyValue
|
|
50825
|
+
};
|
|
50826
|
+
function planKitNode(kind, options, ctx) {
|
|
50827
|
+
const build = typeof kind === "string" && Object.hasOwn(KIT_BUILDERS, kind) ? KIT_BUILDERS[kind] : undefined;
|
|
50828
|
+
if (!build)
|
|
50829
|
+
return invalid("kind", `unknown builder ${JSON.stringify(kind)}; expected one of ${Object.keys(KIT_BUILDERS).join(", ")}`);
|
|
50830
|
+
return build(options, ctx);
|
|
50831
|
+
}
|
|
50832
|
+
|
|
50201
50833
|
// ../../packages/canvas/document/src/execute-api.ts
|
|
50834
|
+
var MOVING_KEYS = ["x", "y", "width", "height", "layout", "layoutPosition", "padding", "gap", "justifyContent", "alignItems", "cornerRadius", "rotation"];
|
|
50202
50835
|
var CONNECT_KEYS = new Set(["route", "fromMagnet", "toMagnet", "arrow", "label", "labelPos", "stroke", "strokeWidth", "dash", "behind", "parent", "name"]);
|
|
50836
|
+
function connectorMetaOf(props) {
|
|
50837
|
+
const meta = props?.metadata?.connector;
|
|
50838
|
+
if (!meta || typeof meta !== "object")
|
|
50839
|
+
return null;
|
|
50840
|
+
const m = meta;
|
|
50841
|
+
if (typeof m.from !== "string" || typeof m.to !== "string")
|
|
50842
|
+
return null;
|
|
50843
|
+
return {
|
|
50844
|
+
from: m.from,
|
|
50845
|
+
to: m.to,
|
|
50846
|
+
fromMagnet: m.fromMagnet ?? "auto",
|
|
50847
|
+
toMagnet: m.toMagnet ?? "auto",
|
|
50848
|
+
route: m.route ?? "straight",
|
|
50849
|
+
arrow: m.arrow ?? "end",
|
|
50850
|
+
labelPos: typeof m.labelPos === "number" ? m.labelPos : 0.5,
|
|
50851
|
+
...Array.isArray(m.dash) ? { dash: m.dash } : {},
|
|
50852
|
+
...typeof m.labelId === "string" ? { labelId: m.labelId } : {}
|
|
50853
|
+
};
|
|
50854
|
+
}
|
|
50203
50855
|
var MEASURE_KEYS = new Set(["fontFamily", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "width"]);
|
|
50204
|
-
function
|
|
50856
|
+
function invalid2(property, reason) {
|
|
50205
50857
|
throw new OpRejectedError({ code: "INVALID_VALUE", property, reason });
|
|
50206
50858
|
}
|
|
50207
50859
|
function pickOption(value, allowed, property, fallback) {
|
|
@@ -50209,33 +50861,37 @@ function pickOption(value, allowed, property, fallback) {
|
|
|
50209
50861
|
return fallback;
|
|
50210
50862
|
if (typeof value === "string" && allowed.includes(value))
|
|
50211
50863
|
return value;
|
|
50212
|
-
return
|
|
50864
|
+
return invalid2(property, `expected one of ${allowed.join(", ")}`);
|
|
50213
50865
|
}
|
|
50214
50866
|
function numberOption(value, property, fallback, positive = false) {
|
|
50215
50867
|
if (value === undefined || value === null)
|
|
50216
50868
|
return fallback;
|
|
50217
50869
|
if (typeof value !== "number" || !Number.isFinite(value) || positive && value <= 0)
|
|
50218
|
-
return
|
|
50870
|
+
return invalid2(property, positive ? "expected a positive number" : "expected a number");
|
|
50219
50871
|
return value;
|
|
50220
50872
|
}
|
|
50221
|
-
function
|
|
50873
|
+
function optionKeys2(value, allowed, name) {
|
|
50222
50874
|
if (value === undefined || value === null)
|
|
50223
50875
|
return {};
|
|
50224
50876
|
if (typeof value !== "object" || Array.isArray(value))
|
|
50225
|
-
return
|
|
50877
|
+
return invalid2(name, "expected an options object");
|
|
50226
50878
|
for (const key of Object.keys(value))
|
|
50227
50879
|
if (!allowed.has(key))
|
|
50228
|
-
return
|
|
50880
|
+
return invalid2(key, `${name} does not take ${key}`);
|
|
50229
50881
|
return value;
|
|
50230
50882
|
}
|
|
50231
50883
|
function dashOption(value) {
|
|
50232
50884
|
if (value === undefined || value === null)
|
|
50233
50885
|
return;
|
|
50234
50886
|
if (!Array.isArray(value) || !value.every((d) => typeof d === "number" && Number.isFinite(d) && d > 0))
|
|
50235
|
-
|
|
50887
|
+
invalid2("dash", "expected an array of positive numbers");
|
|
50236
50888
|
return value;
|
|
50237
50889
|
}
|
|
50238
|
-
var LIMITS = { ops: 5000, printBytes: 64 * 1024, screenshots: 4 };
|
|
50890
|
+
var LIMITS = { ops: 5000, printBytes: 64 * 1024, screenshots: 4, vectorize: 2 };
|
|
50891
|
+
var VECTORIZE_MODES = ["auto", "mono", "flat"];
|
|
50892
|
+
var VECTORIZE_KEYS = new Set(["mode", "maxColors", "allowComplex"]);
|
|
50893
|
+
var KIT_FRAME_GAP = 24;
|
|
50894
|
+
var KIT_FRAME_PADDING = 24;
|
|
50239
50895
|
var ID_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
50240
50896
|
function undeclared(node2, key) {
|
|
50241
50897
|
return node2[key] === undefined || node2[key] === null;
|
|
@@ -50278,16 +50934,20 @@ class ExecuteApi {
|
|
|
50278
50934
|
rev;
|
|
50279
50935
|
random;
|
|
50280
50936
|
measureText;
|
|
50937
|
+
kits;
|
|
50281
50938
|
document = "document";
|
|
50282
50939
|
layoutCache = new Map;
|
|
50283
50940
|
defaults = {};
|
|
50284
|
-
|
|
50941
|
+
connectors = new Map;
|
|
50942
|
+
connectorsIndexed = false;
|
|
50943
|
+
constructor(store, rec, bounds, rev, random = Math.random, measureText, kits) {
|
|
50285
50944
|
this.store = store;
|
|
50286
50945
|
this.rec = rec;
|
|
50287
50946
|
this.bounds = bounds;
|
|
50288
50947
|
this.rev = rev;
|
|
50289
50948
|
this.random = random;
|
|
50290
50949
|
this.measureText = measureText;
|
|
50950
|
+
this.kits = kits;
|
|
50291
50951
|
}
|
|
50292
50952
|
setDefaults(value) {
|
|
50293
50953
|
const raw = value;
|
|
@@ -50541,6 +51201,8 @@ class ExecuteApi {
|
|
|
50541
51201
|
patch.descendants = { ...row.props.descendants ?? {}, ...this.resolveDescendantKeys(row.props.ref, patch.descendants) };
|
|
50542
51202
|
this.warnProps({ ...patch, ...row.props.type === "ref" ? { ref: row.props.ref } : {} }, row.props.type, row.id);
|
|
50543
51203
|
this.commit({ op: "update", id: row.id, patch });
|
|
51204
|
+
if (MOVING_KEYS.some((k) => (k in patch)) || patch.descendants && this.store.get(row.id))
|
|
51205
|
+
this.finalizeConnectors();
|
|
50544
51206
|
}
|
|
50545
51207
|
Replace(path, nodeData) {
|
|
50546
51208
|
const inst = this.splitInstancePath(path);
|
|
@@ -50578,6 +51240,7 @@ class ExecuteApi {
|
|
|
50578
51240
|
const before = i > 0 ? this.store.get(siblings[i - 1]).ord : null;
|
|
50579
51241
|
const after = i < siblings.length ? this.store.get(siblings[i]).ord : null;
|
|
50580
51242
|
this.commit({ op: "move", id: row.id, parent: p, ord: between(before, after) });
|
|
51243
|
+
this.finalizeConnectors();
|
|
50581
51244
|
}
|
|
50582
51245
|
Delete(path) {
|
|
50583
51246
|
if (path === "document")
|
|
@@ -50587,6 +51250,7 @@ class ExecuteApi {
|
|
|
50587
51250
|
if (!this.store.get(path))
|
|
50588
51251
|
throw new OpRejectedError({ code: "NODE_NOT_FOUND", path });
|
|
50589
51252
|
this.commit({ op: "delete", id: path });
|
|
51253
|
+
this.finalizeConnectors();
|
|
50590
51254
|
}
|
|
50591
51255
|
MoveToBack(path) {
|
|
50592
51256
|
this.Move(path, undefined, 0);
|
|
@@ -50827,14 +51491,14 @@ class ExecuteApi {
|
|
|
50827
51491
|
}
|
|
50828
51492
|
MeasureText(content, options) {
|
|
50829
51493
|
if (typeof content !== "string")
|
|
50830
|
-
|
|
51494
|
+
invalid2("content", "expected a string");
|
|
50831
51495
|
if (!this.measureText)
|
|
50832
|
-
|
|
50833
|
-
const o =
|
|
51496
|
+
invalid2("MeasureText", "this host has no font set, so text cannot be measured");
|
|
51497
|
+
const o = optionKeys2(options, MEASURE_KEYS, "MeasureText");
|
|
50834
51498
|
if (typeof o.fontFamily !== "string" || o.fontFamily === "")
|
|
50835
|
-
|
|
51499
|
+
invalid2("fontFamily", "expected a font family name");
|
|
50836
51500
|
if (o.fontSize === undefined || o.fontSize === null)
|
|
50837
|
-
|
|
51501
|
+
invalid2("fontSize", "expected a positive number");
|
|
50838
51502
|
return this.measureText({
|
|
50839
51503
|
content,
|
|
50840
51504
|
fontFamily: o.fontFamily,
|
|
@@ -50850,59 +51514,45 @@ class ExecuteApi {
|
|
|
50850
51514
|
}
|
|
50851
51515
|
Connect(from, to, options) {
|
|
50852
51516
|
if (typeof from !== "string" || typeof to !== "string")
|
|
50853
|
-
|
|
51517
|
+
invalid2("from", "expected a node id");
|
|
50854
51518
|
if (from === to)
|
|
50855
|
-
|
|
51519
|
+
invalid2("to", "a node cannot be connected to itself");
|
|
50856
51520
|
this.rowOf(from);
|
|
50857
51521
|
this.rowOf(to);
|
|
50858
|
-
const o =
|
|
50859
|
-
if (o.route === "elbow")
|
|
50860
|
-
invalid("route", "elbow routing is not available yet");
|
|
51522
|
+
const o = optionKeys2(options, CONNECT_KEYS, "Connect");
|
|
50861
51523
|
const route = pickOption(o.route, ROUTES, "route", "straight");
|
|
50862
51524
|
const fromMagnet = pickOption(o.fromMagnet, MAGNETS, "fromMagnet", "auto");
|
|
50863
51525
|
const toMagnet = pickOption(o.toMagnet, MAGNETS, "toMagnet", "auto");
|
|
50864
51526
|
const arrow = pickOption(o.arrow, ARROWS, "arrow", "end");
|
|
50865
51527
|
const labelPos = numberOption(o.labelPos, "labelPos", 0.5);
|
|
50866
51528
|
if (labelPos < 0 || labelPos > 1)
|
|
50867
|
-
|
|
51529
|
+
invalid2("labelPos", "expected a number between 0 and 1");
|
|
50868
51530
|
const strokeWidth = numberOption(o.strokeWidth, "strokeWidth", 1.5, true);
|
|
50869
51531
|
const stroke = o.stroke === undefined || o.stroke === null ? "#64748B" : o.stroke;
|
|
50870
51532
|
if (typeof stroke !== "string")
|
|
50871
|
-
|
|
51533
|
+
invalid2("stroke", "expected a colour string");
|
|
50872
51534
|
const dash = dashOption(o.dash);
|
|
50873
51535
|
const behind = o.behind === undefined || o.behind === null ? true : o.behind;
|
|
50874
51536
|
if (typeof behind !== "boolean")
|
|
50875
|
-
|
|
51537
|
+
invalid2("behind", "expected a boolean");
|
|
50876
51538
|
const name = o.name === undefined || o.name === null ? "Connector" : o.name;
|
|
50877
51539
|
if (typeof name !== "string")
|
|
50878
|
-
|
|
51540
|
+
invalid2("name", "expected a string");
|
|
50879
51541
|
if (o.label !== undefined && o.label !== null && typeof o.label !== "string")
|
|
50880
|
-
|
|
50881
|
-
const
|
|
51542
|
+
invalid2("label", "expected a string");
|
|
51543
|
+
const ends = { from: this.connectorEnd(from, "from"), to: this.connectorEnd(to, "to") };
|
|
51544
|
+
const geom = connectorGeometry(ends.from, ends.to, { route, fromMagnet, toMagnet, arrow, strokeWidth, labelPos, dash });
|
|
50882
51545
|
const parent = o.parent === undefined || o.parent === null ? this.commonParent(from, to) : this.parentId(String(o.parent));
|
|
50883
51546
|
const target = parent ?? "document";
|
|
50884
51547
|
const origin = this.originOf(parent);
|
|
50885
51548
|
const absolute = this.inFlow(parent);
|
|
50886
51549
|
const place = (box) => ({ x: box.x - origin.x, y: box.y - origin.y, width: box.width, height: box.height, ...absolute ? { layoutPosition: "absolute" } : {} });
|
|
50887
|
-
|
|
50888
|
-
id: "",
|
|
50889
|
-
type: "path",
|
|
50890
|
-
name,
|
|
50891
|
-
...place(geom.bbox),
|
|
50892
|
-
viewBox: [0, 0, geom.bbox.width, geom.bbox.height],
|
|
50893
|
-
geometry: geom.geometry,
|
|
50894
|
-
fill: stroke,
|
|
50895
|
-
stroke,
|
|
50896
|
-
strokeWidth,
|
|
50897
|
-
metadata: { connector: { from, to, fromMagnet, toMagnet, route, arrow, labelPos } }
|
|
50898
|
-
});
|
|
50899
|
-
if (behind)
|
|
50900
|
-
this.Move(id, target, 0);
|
|
51550
|
+
let labelId;
|
|
50901
51551
|
if (typeof o.label === "string" && o.label !== "") {
|
|
50902
51552
|
const size = this.MeasureText(o.label, { fontFamily: "Inter", fontSize: 12 });
|
|
50903
51553
|
const width = size.width + 8;
|
|
50904
51554
|
const height = size.height + 4;
|
|
50905
|
-
this.Insert(target, {
|
|
51555
|
+
labelId = this.Insert(target, {
|
|
50906
51556
|
id: "",
|
|
50907
51557
|
type: "frame",
|
|
50908
51558
|
name: `${name}-label`,
|
|
@@ -50913,8 +51563,139 @@ class ExecuteApi {
|
|
|
50913
51563
|
children: [{ id: "", type: "text", x: 4, y: 2, content: o.label, fontFamily: "Inter", fontSize: 12, fill: "#334155" }]
|
|
50914
51564
|
});
|
|
50915
51565
|
}
|
|
51566
|
+
const id = this.Insert(target, {
|
|
51567
|
+
id: "",
|
|
51568
|
+
type: "path",
|
|
51569
|
+
name,
|
|
51570
|
+
...place(geom.bbox),
|
|
51571
|
+
viewBox: [0, 0, geom.bbox.width, geom.bbox.height],
|
|
51572
|
+
geometry: geom.geometry,
|
|
51573
|
+
fill: stroke,
|
|
51574
|
+
stroke,
|
|
51575
|
+
strokeWidth,
|
|
51576
|
+
metadata: { connector: { from, to, fromMagnet, toMagnet, route, arrow, labelPos, ...dash ? { dash } : {}, ...labelId ? { labelId } : {} } }
|
|
51577
|
+
});
|
|
51578
|
+
this.connectors.set(id, { from, to, fromMagnet, toMagnet, route, arrow, labelPos, ...dash ? { dash } : {}, ...labelId ? { labelId } : {} });
|
|
51579
|
+
if (behind)
|
|
51580
|
+
this.Move(id, target, 0);
|
|
51581
|
+
this.warnConnector(id, geom);
|
|
50916
51582
|
return id;
|
|
50917
51583
|
}
|
|
51584
|
+
finalizeConnectors() {
|
|
51585
|
+
if (!this.mutations)
|
|
51586
|
+
return;
|
|
51587
|
+
for (const id of this.knownConnectors())
|
|
51588
|
+
this.redrawConnector(id);
|
|
51589
|
+
}
|
|
51590
|
+
knownConnectors() {
|
|
51591
|
+
if (!this.connectorsIndexed) {
|
|
51592
|
+
this.connectorsIndexed = true;
|
|
51593
|
+
const walk = (parent) => {
|
|
51594
|
+
for (const id of this.store.children(parent)) {
|
|
51595
|
+
const props = this.store.get(id)?.props;
|
|
51596
|
+
if (!props)
|
|
51597
|
+
continue;
|
|
51598
|
+
const meta = connectorMetaOf(props);
|
|
51599
|
+
if (meta && !this.connectors.has(id))
|
|
51600
|
+
this.connectors.set(id, meta);
|
|
51601
|
+
walk(id);
|
|
51602
|
+
}
|
|
51603
|
+
};
|
|
51604
|
+
walk(null);
|
|
51605
|
+
}
|
|
51606
|
+
return [...this.connectors.keys()];
|
|
51607
|
+
}
|
|
51608
|
+
redrawConnector(id) {
|
|
51609
|
+
const row = this.store.get(id);
|
|
51610
|
+
const meta = row ? connectorMetaOf(row.props) : null;
|
|
51611
|
+
if (!row || !meta) {
|
|
51612
|
+
this.connectors.delete(id);
|
|
51613
|
+
return;
|
|
51614
|
+
}
|
|
51615
|
+
const from = this.absoluteOf(meta.from);
|
|
51616
|
+
const to = this.absoluteOf(meta.to);
|
|
51617
|
+
if (!from || !to || from.width === 0 && from.height === 0 || to.width === 0 && to.height === 0) {
|
|
51618
|
+
this.warnOnce("CONNECTOR_ENDPOINT_GONE", id, `connector ${String(row.props.name ?? id)}: ${meta.from} or ${meta.to} is gone or has no laid-out box; the line was left where it was`);
|
|
51619
|
+
return;
|
|
51620
|
+
}
|
|
51621
|
+
const end = (box2, path) => {
|
|
51622
|
+
const props = this.store.get(path).props;
|
|
51623
|
+
return { box: box2, shape: String(props.type), cornerRadius: typeof props.cornerRadius === "number" ? props.cornerRadius : 0 };
|
|
51624
|
+
};
|
|
51625
|
+
const geom = connectorGeometry(end(from, meta.from), end(to, meta.to), {
|
|
51626
|
+
route: meta.route,
|
|
51627
|
+
fromMagnet: meta.fromMagnet,
|
|
51628
|
+
toMagnet: meta.toMagnet,
|
|
51629
|
+
arrow: meta.arrow,
|
|
51630
|
+
labelPos: meta.labelPos,
|
|
51631
|
+
dash: meta.dash,
|
|
51632
|
+
strokeWidth: typeof row.props.strokeWidth === "number" ? row.props.strokeWidth : 1.5
|
|
51633
|
+
});
|
|
51634
|
+
const origin = this.originOf(row.parent);
|
|
51635
|
+
const box = { x: geom.bbox.x - origin.x, y: geom.bbox.y - origin.y, width: geom.bbox.width, height: geom.bbox.height };
|
|
51636
|
+
const viewBox = [0, 0, geom.bbox.width, geom.bbox.height];
|
|
51637
|
+
const patch = {};
|
|
51638
|
+
for (const [key, value] of Object.entries({ ...box, viewBox, geometry: geom.geometry }))
|
|
51639
|
+
if (JSON.stringify(row.props[key]) !== JSON.stringify(value))
|
|
51640
|
+
patch[key] = value;
|
|
51641
|
+
if (Object.keys(patch).length)
|
|
51642
|
+
this.commit({ op: "update", id, patch });
|
|
51643
|
+
if (meta.labelId) {
|
|
51644
|
+
const label = this.store.get(meta.labelId);
|
|
51645
|
+
const labelBox = this.absoluteOf(meta.labelId);
|
|
51646
|
+
if (label && labelBox) {
|
|
51647
|
+
const x = geom.labelCenter.x - labelBox.width / 2 - origin.x;
|
|
51648
|
+
const y = geom.labelCenter.y - labelBox.height / 2 - origin.y;
|
|
51649
|
+
const labelPatch = {};
|
|
51650
|
+
if (label.props.x !== x)
|
|
51651
|
+
labelPatch.x = x;
|
|
51652
|
+
if (label.props.y !== y)
|
|
51653
|
+
labelPatch.y = y;
|
|
51654
|
+
if (Object.keys(labelPatch).length)
|
|
51655
|
+
this.commit({ op: "update", id: meta.labelId, patch: labelPatch });
|
|
51656
|
+
}
|
|
51657
|
+
}
|
|
51658
|
+
this.warnConnector(id, geom);
|
|
51659
|
+
}
|
|
51660
|
+
warnOnce(code, nodeId, message) {
|
|
51661
|
+
if (this.rec.warnings.length >= 20)
|
|
51662
|
+
return;
|
|
51663
|
+
if (this.rec.warnings.some((w) => w.code === code && w.nodeId === nodeId))
|
|
51664
|
+
return;
|
|
51665
|
+
this.rec.warnings.push({ code, nodeId, message });
|
|
51666
|
+
}
|
|
51667
|
+
warnConnector(id, geom) {
|
|
51668
|
+
const row = this.store.get(id);
|
|
51669
|
+
if (!row)
|
|
51670
|
+
return;
|
|
51671
|
+
const meta = connectorMetaOf(row.props);
|
|
51672
|
+
const labelIds = new Set;
|
|
51673
|
+
for (const m of this.connectors.values())
|
|
51674
|
+
if (m.labelId)
|
|
51675
|
+
labelIds.add(m.labelId);
|
|
51676
|
+
let labelBox = null;
|
|
51677
|
+
for (const sibling of this.store.children(row.parent)) {
|
|
51678
|
+
const props = this.store.get(sibling)?.props;
|
|
51679
|
+
if (!props || sibling === id)
|
|
51680
|
+
continue;
|
|
51681
|
+
const box = this.absoluteOf(sibling);
|
|
51682
|
+
if (!box || box.width === 0 && box.height === 0)
|
|
51683
|
+
continue;
|
|
51684
|
+
if (sibling === meta?.labelId) {
|
|
51685
|
+
labelBox = box;
|
|
51686
|
+
continue;
|
|
51687
|
+
}
|
|
51688
|
+
if (!labelIds.has(sibling) && !this.connectors.has(sibling) && sibling !== meta?.from && sibling !== meta?.to) {
|
|
51689
|
+
for (let i = 1;i < geom.polyline.length; i++)
|
|
51690
|
+
if (segmentCrossesBox(geom.polyline[i - 1], geom.polyline[i], box)) {
|
|
51691
|
+
this.warnOnce("CONNECTOR_CROSSES_NODE", id, `line crosses ${String(props.name ?? sibling)}`);
|
|
51692
|
+
break;
|
|
51693
|
+
}
|
|
51694
|
+
}
|
|
51695
|
+
if (labelBox && rectsOverlap(labelBox, box))
|
|
51696
|
+
this.warnOnce("LABEL_OVERLAP", id, `label overlaps ${String(props.name ?? sibling)}`);
|
|
51697
|
+
}
|
|
51698
|
+
}
|
|
50918
51699
|
absoluteOf(path) {
|
|
50919
51700
|
if (path === null || path === "")
|
|
50920
51701
|
return { x: 0, y: 0, width: 0, height: 0 };
|
|
@@ -50929,14 +51710,14 @@ class ExecuteApi {
|
|
|
50929
51710
|
return { x: 0, y: 0 };
|
|
50930
51711
|
const box = this.absoluteOf(parent);
|
|
50931
51712
|
if (!box)
|
|
50932
|
-
|
|
51713
|
+
invalid2("parent", `${parent} has no laid-out box`);
|
|
50933
51714
|
return { x: box.x, y: box.y };
|
|
50934
51715
|
}
|
|
50935
51716
|
connectorEnd(id, property) {
|
|
50936
51717
|
const row = this.rowOf(id);
|
|
50937
51718
|
const box = this.absoluteOf(id);
|
|
50938
51719
|
if (!box || box.width === 0 && box.height === 0)
|
|
50939
|
-
|
|
51720
|
+
invalid2(property, `${id} has no laid-out box to attach to`);
|
|
50940
51721
|
return { box, shape: String(row.props.type), cornerRadius: typeof row.props.cornerRadius === "number" ? row.props.cornerRadius : 0 };
|
|
50941
51722
|
}
|
|
50942
51723
|
commonParent(a, b) {
|
|
@@ -50983,6 +51764,69 @@ class ExecuteApi {
|
|
|
50983
51764
|
return { x: minX, y: maxY + pad };
|
|
50984
51765
|
return { x: minX, y: minY - pad - input.height };
|
|
50985
51766
|
}
|
|
51767
|
+
KitPlan(kind, options) {
|
|
51768
|
+
const variables = this.store.variables();
|
|
51769
|
+
return planKitNode(kind, options, {
|
|
51770
|
+
variables: new Set(Object.keys(variables)),
|
|
51771
|
+
measure: (request) => {
|
|
51772
|
+
const family = typeof request.fontFamily === "string" && request.fontFamily.startsWith("$") ? variables[request.fontFamily.slice(1)]?.value : request.fontFamily;
|
|
51773
|
+
const { content, ...options2 } = { ...request, fontFamily: typeof family === "string" && family !== "" ? family : "Geist" };
|
|
51774
|
+
return this.MeasureText(content, options2);
|
|
51775
|
+
}
|
|
51776
|
+
});
|
|
51777
|
+
}
|
|
51778
|
+
ListKits() {
|
|
51779
|
+
return this.kits?.list() ?? [];
|
|
51780
|
+
}
|
|
51781
|
+
UseKit(name) {
|
|
51782
|
+
if (typeof name !== "string" || name === "")
|
|
51783
|
+
invalid2("name", "expected a kit name");
|
|
51784
|
+
const entry = this.kits?.get(name);
|
|
51785
|
+
if (!entry)
|
|
51786
|
+
invalid2("name", `unknown kit ${JSON.stringify(name)}; available: ${this.kits?.names().join(", ") || "none"}`);
|
|
51787
|
+
const plan = planKit(existingKitNodesIn(this.store, entry.kit.name), entry.kit);
|
|
51788
|
+
const { refs, ids } = planRefs(plan);
|
|
51789
|
+
for (const ref of refs)
|
|
51790
|
+
if (!ids.has(ref) && !this.store.get(ref))
|
|
51791
|
+
throw new OpRejectedError({ code: "UNKNOWN_REF", ref });
|
|
51792
|
+
this.SetVariables(entry.kit.variables, false);
|
|
51793
|
+
const frame = kitFrameIn(this.store, entry.frame) ?? this.createKitFrame(entry.frame);
|
|
51794
|
+
for (const node2 of plan.add)
|
|
51795
|
+
this.insertKitComponent(frame, null, node2);
|
|
51796
|
+
for (const { id, node: node2 } of plan.update) {
|
|
51797
|
+
const row = this.rowOf(id);
|
|
51798
|
+
this.commit({ op: "delete", id });
|
|
51799
|
+
this.insertKitComponent(row.parent, row.ord, node2);
|
|
51800
|
+
}
|
|
51801
|
+
const names = kitPlanNames(plan);
|
|
51802
|
+
return { version: entry.kit.version, added: names.added, updated: names.updated, unchanged: plan.unchanged, variables: plan.variables };
|
|
51803
|
+
}
|
|
51804
|
+
createKitFrame(name) {
|
|
51805
|
+
const at = this.FindEmptySpace({ width: 0, height: 0, direction: "right", padding: KIT_FRAME_GAP });
|
|
51806
|
+
return this.Insert("document", {
|
|
51807
|
+
id: "",
|
|
51808
|
+
type: "frame",
|
|
51809
|
+
name,
|
|
51810
|
+
x: at.x,
|
|
51811
|
+
y: at.y,
|
|
51812
|
+
layout: "vertical",
|
|
51813
|
+
gap: KIT_FRAME_GAP,
|
|
51814
|
+
padding: KIT_FRAME_PADDING
|
|
51815
|
+
});
|
|
51816
|
+
}
|
|
51817
|
+
insertKitComponent(parent, ord, node2) {
|
|
51818
|
+
const tree = applyTextDefaults(migrateLegacyProps(node2), this.defaults.text);
|
|
51819
|
+
const seen = new Set;
|
|
51820
|
+
const check = (n2) => {
|
|
51821
|
+
if (seen.has(n2.id) || this.store.get(n2.id))
|
|
51822
|
+
throw new OpRejectedError({ code: "INVALID_VALUE", property: "id", reason: `kit component id ${n2.id} is already taken on this canvas` });
|
|
51823
|
+
seen.add(n2.id);
|
|
51824
|
+
for (const child of Array.isArray(n2.children) ? n2.children : [])
|
|
51825
|
+
check(child);
|
|
51826
|
+
};
|
|
51827
|
+
check(tree);
|
|
51828
|
+
this.commit({ op: "insert", parent, ord: ord ?? between(this.lastOrd(parent), null), node: tree });
|
|
51829
|
+
}
|
|
50986
51830
|
Print(...values) {
|
|
50987
51831
|
const line = values.map((v) => typeof v === "string" ? v : JSON.stringify(v)).join(" ");
|
|
50988
51832
|
this.rec.printBytes += line.length;
|
|
@@ -50995,6 +51839,35 @@ class ExecuteApi {
|
|
|
50995
51839
|
if (this.rec.screenshots.length < LIMITS.screenshots)
|
|
50996
51840
|
this.rec.screenshots.push(id);
|
|
50997
51841
|
}
|
|
51842
|
+
Vectorize(frameId, fileId, opts) {
|
|
51843
|
+
if (typeof frameId !== "string" || frameId === "")
|
|
51844
|
+
invalid2("frameId", "expected a frame id");
|
|
51845
|
+
if (typeof fileId !== "string" || fileId === "")
|
|
51846
|
+
invalid2("fileId", "expected a file id");
|
|
51847
|
+
const options = optionKeys2(opts, VECTORIZE_KEYS, "Vectorize");
|
|
51848
|
+
const mode = options.mode === undefined || options.mode === null ? undefined : pickOption(options.mode, VECTORIZE_MODES, "mode", "auto");
|
|
51849
|
+
const maxColors = options.maxColors === undefined || options.maxColors === null ? undefined : options.maxColors;
|
|
51850
|
+
if (maxColors !== undefined && (typeof maxColors !== "number" || !Number.isInteger(maxColors) || maxColors < 1))
|
|
51851
|
+
invalid2("maxColors", "expected a positive integer");
|
|
51852
|
+
const allowComplex = options.allowComplex === undefined || options.allowComplex === null ? undefined : options.allowComplex;
|
|
51853
|
+
if (allowComplex !== undefined && typeof allowComplex !== "boolean")
|
|
51854
|
+
invalid2("allowComplex", "expected a boolean");
|
|
51855
|
+
if (this.rec.pendingVectorize.length >= LIMITS.vectorize)
|
|
51856
|
+
throw new Error(`SCRIPT_LIMIT: at most ${LIMITS.vectorize} Vectorize calls in one execute — ask for one image per execute, or trace one combined image`);
|
|
51857
|
+
const requestId = this.newRequestId();
|
|
51858
|
+
const carried = { ...mode === undefined ? {} : { mode }, ...maxColors === undefined ? {} : { maxColors }, ...allowComplex === undefined ? {} : { allowComplex } };
|
|
51859
|
+
this.rec.pendingVectorize.push({ requestId, frameId, fileId, ...Object.keys(carried).length ? { opts: carried } : {} });
|
|
51860
|
+
return { requestId };
|
|
51861
|
+
}
|
|
51862
|
+
newRequestId() {
|
|
51863
|
+
for (;; ) {
|
|
51864
|
+
let id = "vz-";
|
|
51865
|
+
for (let i = 0;i < 10; i++)
|
|
51866
|
+
id += ID_CHARS[Math.floor(this.random() * ID_CHARS.length)];
|
|
51867
|
+
if (!this.rec.pendingVectorize.some((p) => p.requestId === id))
|
|
51868
|
+
return id;
|
|
51869
|
+
}
|
|
51870
|
+
}
|
|
50998
51871
|
}
|
|
50999
51872
|
function toPen(e, depth, _resolved, _instances, shallow = false) {
|
|
51000
51873
|
const node2 = { ...e.props, id: e.path, type: e.type };
|
|
@@ -51947,7 +52820,7 @@ function startProgress(ctx, write = (text) => writeOutput({ stderr: text })) {
|
|
|
51947
52820
|
}
|
|
51948
52821
|
|
|
51949
52822
|
// src/main.ts
|
|
51950
|
-
var version = "0.3.0-dev.
|
|
52823
|
+
var version = "0.3.0-dev.ae46a71";
|
|
51951
52824
|
var commands = commandTree(operations);
|
|
51952
52825
|
var manual = [...workflows.map((w) => w.words), [API_WORD]];
|
|
51953
52826
|
function route(argv) {
|
|
@@ -52201,16 +53074,16 @@ Examples:
|
|
|
52201
53074
|
const cursor = result instanceof Page ? result.next_cursor : record(result).next_cursor ?? record(result).nextToken;
|
|
52202
53075
|
if (typeof cursor === "string" && cursor)
|
|
52203
53076
|
ctx.nextCommand = nextPageCommand(selected.command, parsed, cursor);
|
|
52204
|
-
const pageToken = pageTokenField(op),
|
|
52205
|
-
const firstPage = flags.all && !(result instanceof Page) &&
|
|
52206
|
-
if (flags.all && !(result instanceof Page) &&
|
|
52207
|
-
throw new UsageError(`--all cannot find the list in ${op.resource}.${op.method}'s response; page with --${
|
|
53077
|
+
const pageToken = pageTokenField(op), token2 = pageToken?.sdkName ?? pageToken?.name;
|
|
53078
|
+
const firstPage = flags.all && !(result instanceof Page) && token2 ? pageOf(result) : undefined;
|
|
53079
|
+
if (flags.all && !(result instanceof Page) && token2 && !firstPage)
|
|
53080
|
+
throw new UsageError(`--all cannot find the list in ${op.resource}.${op.method}'s response; page with --${token2.replace(/_/g, "-")} instead`);
|
|
52208
53081
|
if (firstPage) {
|
|
52209
53082
|
const items = [...firstPage.items];
|
|
52210
53083
|
const seen = new Set;
|
|
52211
53084
|
for (let next = firstPage.token;next && !seen.has(next); next = pageOf(result)?.token) {
|
|
52212
53085
|
seen.add(next);
|
|
52213
|
-
result = await owner[op.method]({ ...opts, query: { ...opts.query, [
|
|
53086
|
+
result = await owner[op.method]({ ...opts, query: { ...opts.query, [token2]: next } });
|
|
52214
53087
|
items.push(...pageOf(result)?.items ?? []);
|
|
52215
53088
|
}
|
|
52216
53089
|
ctx.nextCommand = undefined;
|