krillplayer-plugin 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/cli.js +179 -164
- package/package.json +3 -2
- package/skill/krillplayer-plugin/SKILL.md +2 -1
- package/skill/krillplayer-plugin/assets/samples/file-share/plugin.ts +1 -20
- package/skill/krillplayer-plugin/assets/samples/media-server/plugin.ts +1 -35
- package/skill/krillplayer-plugin/assets/samples/network-share/plugin.ts +1 -20
- package/skill/krillplayer-plugin/references/choosing-a-kind.md +2 -2
- package/skill/krillplayer-plugin/references/contract.d.ts +60 -99
- package/skill/krillplayer-plugin/references/errors-and-fixes.md +1 -1
- package/skill/krillplayer-plugin/assets/samples/file-share/cases/library-empty-folder.json +0 -11
- package/skill/krillplayer-plugin/assets/samples/file-share/cases/library-folder-gone-not-found.json +0 -12
- package/skill/krillplayer-plugin/assets/samples/file-share/cases/library-folder-lists-subfolders-and-media.json +0 -28
- package/skill/krillplayer-plugin/assets/samples/file-share/cases/library-folder-second-page.json +0 -22
- package/skill/krillplayer-plugin/assets/samples/file-share/cases/library-folder-skips-subtitles.json +0 -21
- package/skill/krillplayer-plugin/assets/samples/file-share/cases/library-root-first-page.json +0 -25
- package/skill/krillplayer-plugin/assets/samples/file-share/cases/library-root-second-page.json +0 -22
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/library-changes-everything-first-page.json +0 -74
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/library-changes-everything-last-page.json +0 -86
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/library-changes-nothing-new.json +0 -12
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/library-changes-since-a-token-with-a-removal.json +0 -88
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/library-ids-first-page.json +0 -15
- package/skill/krillplayer-plugin/assets/samples/media-server/cases/library-ids-last-page.json +0 -14
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-empty-folder.json +0 -60
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-folder-gives-size-and-modified-time.json +0 -78
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-folder-gone-not-found.json +0 -60
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-folder-second-page.json +0 -71
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-read-a-range.json +0 -62
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-read-an-info-file.json +0 -62
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-read-file-gone-not-found.json +0 -62
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-root.json +0 -84
- package/skill/krillplayer-plugin/assets/samples/network-share/cases/library-source-offline-retryable.json +0 -61
package/README.md
CHANGED
|
@@ -84,3 +84,8 @@ npx krillplayer-plugin skill
|
|
|
84
84
|
- 没签过名的插件从某一版起签名,App 也请用户确认一次:拿到你更新地址的人不能悄悄钉上他自己的钥匙。
|
|
85
85
|
- 签了名的插件换托管地址时,新地址上的版本用同一把钥匙签,用户从新地址添加,App 认得是同一个插件:登录与授权都留着,以后从新地址查更新。没签名的插件只能靠旧地址重定向。
|
|
86
86
|
- 私钥只留在你自己手里,不要放进仓库、持续集成或插件里。
|
|
87
|
+
|
|
88
|
+
## 更新记录
|
|
89
|
+
|
|
90
|
+
- **0.1.2**:契约去掉资料库槽位 `library`(`list`、`read`、`changes`、`ids`)与能力 `library`、`libraryChanges`,App 不再整库扫描来源。还导出 `library` 的插件打包失败,删掉这个导出即可;已经装着的旧版本照常运行,App 不调它。契约修订号不变。
|
|
91
|
+
- **0.1.1**:契约加上在直播间发弹幕的 `danmaku.send`(能力 `danmakuSend`)。
|
package/dist/cli.js
CHANGED
|
@@ -69,7 +69,6 @@ var Capability = enumeration("Capability", [
|
|
|
69
69
|
"music",
|
|
70
70
|
"play",
|
|
71
71
|
"resolve",
|
|
72
|
-
"library",
|
|
73
72
|
"resources",
|
|
74
73
|
"subtitles",
|
|
75
74
|
"subtitleSearch",
|
|
@@ -79,8 +78,8 @@ var Capability = enumeration("Capability", [
|
|
|
79
78
|
"login",
|
|
80
79
|
"playbackReport",
|
|
81
80
|
"views",
|
|
82
|
-
"
|
|
83
|
-
"
|
|
81
|
+
"danmakuSend",
|
|
82
|
+
"browseLists"
|
|
84
83
|
]);
|
|
85
84
|
var Media = enumeration("Media", ["video", "audio"]);
|
|
86
85
|
var ChannelKind = enumeration("ChannelKind", ["creator", "station", "podcast"]);
|
|
@@ -228,6 +227,8 @@ var Folder = object("Folder", { kind: constant("folder"), ...collectionBase });
|
|
|
228
227
|
var Collection = union("Collection", "kind", [Series, Season, BoxSet, Playlist, Folder], "CollectionContent");
|
|
229
228
|
var Entry = wrapped("Entry", "type", { item: Item, channel: Channel, collection: Collection });
|
|
230
229
|
var PagedEntry = paged(Entry);
|
|
230
|
+
var BrowseListKind = enumeration("BrowseListKind", ["video", "live", "audio", "file"]);
|
|
231
|
+
var BrowseList = object("BrowseList", { id: string, title: string, kind: BrowseListKind });
|
|
231
232
|
var ArtistRef = object("ArtistRef", { id: string, name: string, image: optional(string) });
|
|
232
233
|
var albumRef = {
|
|
233
234
|
id: string,
|
|
@@ -280,33 +281,6 @@ var Lyrics = object("Lyrics", {
|
|
|
280
281
|
synced: boolean,
|
|
281
282
|
lines: array(object("LyricsLine", { start: optional(number), end: optional(number), text: string, translation: optional(string) }))
|
|
282
283
|
});
|
|
283
|
-
var LibraryDirectory = object("LibraryDirectory", {
|
|
284
|
-
type: constant("directory"),
|
|
285
|
-
path: string,
|
|
286
|
-
name: string,
|
|
287
|
-
modified: optional(number),
|
|
288
|
-
tag: optional(string)
|
|
289
|
-
});
|
|
290
|
-
var LibraryFile = object("LibraryFile", {
|
|
291
|
-
type: constant("file"),
|
|
292
|
-
path: string,
|
|
293
|
-
name: string,
|
|
294
|
-
itemId: string,
|
|
295
|
-
media: Media,
|
|
296
|
-
size: optional(integer),
|
|
297
|
-
modified: optional(number),
|
|
298
|
-
tag: optional(string)
|
|
299
|
-
});
|
|
300
|
-
var LibraryIdentified = object("LibraryIdentified", { type: constant("identified"), item: Item, series: optional(Series) });
|
|
301
|
-
var LibraryEntry = union("LibraryEntry", "type", [LibraryDirectory, LibraryFile, LibraryIdentified]);
|
|
302
|
-
var PagedLibraryEntry = paged(LibraryEntry);
|
|
303
|
-
var LibraryChanges = object("LibraryChanges", {
|
|
304
|
-
entries: array(LibraryEntry),
|
|
305
|
-
removed: optional(array(string)),
|
|
306
|
-
next: optional(string),
|
|
307
|
-
since: string
|
|
308
|
-
});
|
|
309
|
-
var LibraryIds = object("LibraryIds", { ids: array(string), next: optional(string) });
|
|
310
284
|
var FilesProtocol = enumeration("FilesProtocol", ["smb", "local"]);
|
|
311
285
|
var FileEntry = object("FileEntry", {
|
|
312
286
|
name: string,
|
|
@@ -343,7 +317,8 @@ var Parameter = object("Parameter", {
|
|
|
343
317
|
options: optional(array(Option)),
|
|
344
318
|
dynamicOptions: optional(boolean),
|
|
345
319
|
dependsOn: optional(array(string)),
|
|
346
|
-
visibleWhen: optional(array(object("ParameterCondition", { name: string, values: array(string) })))
|
|
320
|
+
visibleWhen: optional(array(object("ParameterCondition", { name: string, values: array(string) }))),
|
|
321
|
+
perSource: optional(boolean)
|
|
347
322
|
});
|
|
348
323
|
var Contributions = object("Contributions", {
|
|
349
324
|
playerPanels: optional(array(object("PlayerPanelContribution", { id: string, title: string, kinds: array(ItemKind) }))),
|
|
@@ -368,6 +343,8 @@ var PluginManifest = object("PluginManifest", {
|
|
|
368
343
|
hosts: array(string),
|
|
369
344
|
userProvidedURLs: optional(boolean),
|
|
370
345
|
readsCredentials: optional(boolean),
|
|
346
|
+
loginRequired: optional(boolean),
|
|
347
|
+
singleSource: optional(boolean),
|
|
371
348
|
// 图片地址里不参与缓存键的查询参数名(不分大小写),例如每次都换的令牌与盐(ADR 0015「图片」)。尺寸参数内核另外固定去掉,不用写。
|
|
372
349
|
imageCacheIgnoredParameters: optional(array(string)),
|
|
373
350
|
// 要用 krillplayer.files 时写哪种协议(contract.md 6.1)。连哪台主机、哪个共享、用什么账号由内核向用户要,不写在 parameters 里,插件也读不到。
|
|
@@ -441,27 +418,20 @@ var Playable = object("Playable", {
|
|
|
441
418
|
// 这一路的原始文件名,给字幕插件与弹幕插件匹配用(contract.md 3.1);不给时内核用条目的文件名或标题。
|
|
442
419
|
filename: optional(string)
|
|
443
420
|
});
|
|
444
|
-
var PageLink = object("PageLink", {
|
|
445
|
-
page: string,
|
|
446
|
-
title: optional(string),
|
|
447
|
-
values: optional(map(string))
|
|
448
|
-
});
|
|
449
421
|
var Card = object("Card", {
|
|
450
|
-
kind: enumeration("CardKind", ["entry", "
|
|
422
|
+
kind: enumeration("CardKind", ["entry", "comment"]),
|
|
451
423
|
title: string,
|
|
452
424
|
subtitle: optional(string),
|
|
453
425
|
caption: optional(string),
|
|
454
426
|
image: optional(string),
|
|
455
427
|
text: optional(string),
|
|
456
428
|
time: optional(number),
|
|
457
|
-
entry: optional(Entry)
|
|
458
|
-
open: optional(PageLink)
|
|
429
|
+
entry: optional(Entry)
|
|
459
430
|
});
|
|
460
431
|
var Section = object("Section", {
|
|
461
|
-
layout: enumeration("SectionLayout", ["row", "grid", "list"
|
|
432
|
+
layout: enumeration("SectionLayout", ["row", "grid", "list"]),
|
|
462
433
|
title: optional(string),
|
|
463
|
-
cards: array(Card)
|
|
464
|
-
more: optional(PageLink)
|
|
434
|
+
cards: array(Card)
|
|
465
435
|
});
|
|
466
436
|
var ComponentPage = object("ComponentPage", {
|
|
467
437
|
title: optional(string),
|
|
@@ -472,7 +442,6 @@ var ComponentPage = object("ComponentPage", {
|
|
|
472
442
|
empty: optional(string)
|
|
473
443
|
}, "PageContent");
|
|
474
444
|
var ActionResult = object("ActionResult", {
|
|
475
|
-
open: optional(PageLink),
|
|
476
445
|
message: optional(string)
|
|
477
446
|
});
|
|
478
447
|
var ChannelStatus = object("ChannelStatus", {
|
|
@@ -644,7 +613,7 @@ var RSSFeed = object("RSSFeed", {
|
|
|
644
613
|
episodes: array(RSSEpisode)
|
|
645
614
|
});
|
|
646
615
|
var WorkKind = enumeration("WorkKind", ["movie", "series"]);
|
|
647
|
-
var ListName = enumeration("ListName", ["trending", "popular", "topRated", "upcoming", "onAir"]);
|
|
616
|
+
var ListName = enumeration("ListName", ["trending", "popular", "topRated", "upcoming", "nowPlaying", "onAir"]);
|
|
648
617
|
var Genre = enumeration("Genre", [
|
|
649
618
|
"action",
|
|
650
619
|
"adventure",
|
|
@@ -670,6 +639,21 @@ var Genre = enumeration("Genre", [
|
|
|
670
639
|
"war",
|
|
671
640
|
"western"
|
|
672
641
|
]);
|
|
642
|
+
var Network = enumeration("Network", [
|
|
643
|
+
"netflix",
|
|
644
|
+
"hbo",
|
|
645
|
+
"disneyPlus",
|
|
646
|
+
"appleTv",
|
|
647
|
+
"primeVideo",
|
|
648
|
+
"hulu",
|
|
649
|
+
"peacock",
|
|
650
|
+
"paramountPlus",
|
|
651
|
+
"iqiyi",
|
|
652
|
+
"tencentVideo",
|
|
653
|
+
"youku",
|
|
654
|
+
"bilibili",
|
|
655
|
+
"mangoTv"
|
|
656
|
+
]);
|
|
673
657
|
var Work = object("Work", {
|
|
674
658
|
kind: WorkKind,
|
|
675
659
|
ids: Ids,
|
|
@@ -683,6 +667,7 @@ var PagedWork = paged(Work);
|
|
|
683
667
|
var MetadataSearchOptions = object("MetadataSearchOptions", { year: optional(integer), cursor: optional(string) });
|
|
684
668
|
var MetadataListOptions = object("MetadataListOptions", {
|
|
685
669
|
genre: optional(Genre),
|
|
670
|
+
network: optional(Network),
|
|
686
671
|
country: optional(string),
|
|
687
672
|
year: optional(integer),
|
|
688
673
|
cursor: optional(string)
|
|
@@ -767,11 +752,14 @@ var CryptoKey = object("CryptoKey", {
|
|
|
767
752
|
});
|
|
768
753
|
var CryptoKeyPair = object("CryptoKeyPair", { publicKey: CryptoKey, privateKey: CryptoKey });
|
|
769
754
|
var SLOT_RULES = {
|
|
755
|
+
// 导出 lists 的是具名列表(contract.md 2.1),list、parameters、options 都按列表的 id 问,能力是 browseLists 而不是 browse:
|
|
756
|
+
// 只认 browse 的旧内核不会按一份列表的老样子去调它,不认识的 browseLists 跳过。没导出 lists 的是只有一份列表的特例。
|
|
770
757
|
browse: {
|
|
771
|
-
functions: ["parameters", "options", "list", "search", "channel", "collection", "schedule"],
|
|
758
|
+
functions: ["lists", "parameters", "options", "list", "search", "channel", "collection", "schedule"],
|
|
772
759
|
required: ["list"],
|
|
773
760
|
pairs: [],
|
|
774
|
-
capabilities: { browse: ["list"] }
|
|
761
|
+
capabilities: { browse: ["list"], browseLists: ["lists"] },
|
|
762
|
+
supersedes: { browseLists: "browse" }
|
|
775
763
|
},
|
|
776
764
|
// 没有音乐内容的实例 sections 返回空数组,内核就不在音乐里显示它(contract.md 2.2)。
|
|
777
765
|
music: {
|
|
@@ -781,14 +769,6 @@ var SLOT_RULES = {
|
|
|
781
769
|
capabilities: { music: ["sections"] }
|
|
782
770
|
},
|
|
783
771
|
play: { functions: ["start"], required: ["start"], pairs: [], capabilities: { play: ["start"] } },
|
|
784
|
-
// 文件类来源导出 list(与可选的 read),媒体服务器导出 changes 与 ids(contract.md 2.10)。两样能力分开:只认 library 的旧内核
|
|
785
|
-
// 见到只导出 changes 的插件时不会去调它没有的 list,不认识的 libraryChanges 跳过。
|
|
786
|
-
library: {
|
|
787
|
-
functions: ["list", "read", "changes", "ids"],
|
|
788
|
-
required: [],
|
|
789
|
-
pairs: [["changes", "ids"]],
|
|
790
|
-
capabilities: { library: ["list"], libraryChanges: ["changes"] }
|
|
791
|
-
},
|
|
792
772
|
// 资源插件(contract.md 2.5):按作品回答有没有可播的版本。
|
|
793
773
|
resources: { functions: ["find"], required: ["find"], pairs: [], capabilities: { resources: ["find"] } },
|
|
794
774
|
// 只导出 search 的是字幕插件,不是自带字幕的来源(contract.md 第 2 节)。
|
|
@@ -813,12 +793,14 @@ var SLOT_RULES = {
|
|
|
813
793
|
capabilities: { login: ["methods"] }
|
|
814
794
|
},
|
|
815
795
|
playbackReport: { functions: ["report"], required: ["report"], pairs: [], capabilities: { playbackReport: ["report"] } },
|
|
816
|
-
|
|
796
|
+
// 组件页面 page 去掉了(ADR 0040),剩下播放器面板与卡片操作。
|
|
797
|
+
views: { functions: ["panel", "action"], required: [], pairs: [], capabilities: { views: ["panel", "action"] } },
|
|
817
798
|
// 顶层的 parameters 不算能力(contract.md 第 2 节)。
|
|
818
799
|
parameters: { functions: ["options"], required: ["options"], pairs: [], capabilities: {} }
|
|
819
800
|
};
|
|
820
801
|
var SLOT_RETURNS = {
|
|
821
802
|
browse: {
|
|
803
|
+
lists: { schema: array(BrowseList) },
|
|
822
804
|
parameters: { schema: array(Parameter) },
|
|
823
805
|
options: { schema: array(Option) },
|
|
824
806
|
list: { schema: PagedEntry },
|
|
@@ -839,7 +821,6 @@ var SLOT_RETURNS = {
|
|
|
839
821
|
lyrics: { schema: Lyrics, nullable: true }
|
|
840
822
|
},
|
|
841
823
|
play: { start: { schema: Playable } },
|
|
842
|
-
library: { list: { schema: PagedLibraryEntry }, read: { schema: bytes }, changes: { schema: LibraryChanges }, ids: { schema: LibraryIds } },
|
|
843
824
|
resources: { find: { schema: array(ResourceVersion) } },
|
|
844
825
|
subtitles: { list: { schema: array(SubtitleTrack) }, search: { schema: array(SubtitleTrack) }, fetch: { schema: Subtitle } },
|
|
845
826
|
danmaku: {
|
|
@@ -856,7 +837,7 @@ var SLOT_RETURNS = {
|
|
|
856
837
|
poll: { schema: LoginPoll },
|
|
857
838
|
account: { schema: LoginAccount, nullable: true }
|
|
858
839
|
},
|
|
859
|
-
views: {
|
|
840
|
+
views: { panel: { schema: ComponentPage }, action: { schema: ActionResult } },
|
|
860
841
|
parameters: { options: { schema: array(Option) } },
|
|
861
842
|
resolve: { "": { schema: Resolved, nullable: true } }
|
|
862
843
|
};
|
|
@@ -891,6 +872,7 @@ var NOT_YET_USED = [
|
|
|
891
872
|
"ArtistPage.artist",
|
|
892
873
|
"ArtistRef.image",
|
|
893
874
|
"BoxSet.ancestors",
|
|
875
|
+
"BoxSet.ids",
|
|
894
876
|
"ChannelRef.image",
|
|
895
877
|
"ChannelRef.kind",
|
|
896
878
|
"ChannelStatus.latest",
|
|
@@ -948,15 +930,13 @@ var NOT_YET_USED = [
|
|
|
948
930
|
"Podcast.order",
|
|
949
931
|
"Podcast.summary",
|
|
950
932
|
"PodcastEpisode.episodeType",
|
|
951
|
-
"PodcastEpisode.index",
|
|
952
|
-
"PodcastEpisode.published",
|
|
953
|
-
"PodcastEpisode.season",
|
|
954
933
|
"PodcastEpisode.summary",
|
|
955
934
|
"ResolvedBrowse.entry",
|
|
956
935
|
"ScheduleEntry.id",
|
|
957
936
|
"ScheduleEntry.image",
|
|
958
937
|
"ScheduleEntry.summary",
|
|
959
938
|
"Season.ancestors",
|
|
939
|
+
"Season.ids",
|
|
960
940
|
"Series.ancestors",
|
|
961
941
|
"Song.disc",
|
|
962
942
|
"Song.index",
|
|
@@ -1168,6 +1148,18 @@ var CREDENTIAL_HEADERS = /* @__PURE__ */ new Set(["authorization", "cookie", "pr
|
|
|
1168
1148
|
function carries(text, secret) {
|
|
1169
1149
|
return text.includes(secret) || text.includes("%") && percentDecoded(text).includes(secret);
|
|
1170
1150
|
}
|
|
1151
|
+
var TOKEN_MINIMUM_LENGTH = 16;
|
|
1152
|
+
function looksLikeToken(secret) {
|
|
1153
|
+
const scalars = [...secret];
|
|
1154
|
+
if (scalars.length < TOKEN_MINIMUM_LENGTH) return false;
|
|
1155
|
+
const classes = /* @__PURE__ */ new Set();
|
|
1156
|
+
for (const scalar of scalars) {
|
|
1157
|
+
const code = scalar.codePointAt(0) ?? 0;
|
|
1158
|
+
classes.add(code >= 48 && code <= 57 ? 0 : code >= 97 && code <= 122 ? 1 : code >= 65 && code <= 90 ? 2 : 3);
|
|
1159
|
+
if (classes.size >= 2) return true;
|
|
1160
|
+
}
|
|
1161
|
+
return false;
|
|
1162
|
+
}
|
|
1171
1163
|
function percentDecoded(text) {
|
|
1172
1164
|
const input = new TextEncoder().encode(text);
|
|
1173
1165
|
const bytes2 = [];
|
|
@@ -1332,6 +1324,8 @@ var Chain = class {
|
|
|
1332
1324
|
once;
|
|
1333
1325
|
remembered;
|
|
1334
1326
|
secrets;
|
|
1327
|
+
// `derived-no-secrets` 查的那部分:像令牌的值(`looksLikeToken`)。删减请求头仍按全部凭证值。
|
|
1328
|
+
tokens;
|
|
1335
1329
|
use;
|
|
1336
1330
|
grants;
|
|
1337
1331
|
startsAtUserAddress = false;
|
|
@@ -1348,6 +1342,7 @@ var Chain = class {
|
|
|
1348
1342
|
this.once = lower(grants.once);
|
|
1349
1343
|
this.remembered = grants.remembered ?? {};
|
|
1350
1344
|
this.secrets = (grants.secrets ?? []).filter((secret) => secret !== "");
|
|
1345
|
+
this.tokens = this.secrets.filter(looksLikeToken);
|
|
1351
1346
|
}
|
|
1352
1347
|
classify(host) {
|
|
1353
1348
|
return this.user.has(host) ? "user" : this.declared.has(host) ? "declared" : "derived";
|
|
@@ -1491,7 +1486,7 @@ var Chain = class {
|
|
|
1491
1486
|
);
|
|
1492
1487
|
}
|
|
1493
1488
|
const carried = [address.href, ...Object.keys(headers2), ...Object.values(headers2), ...frames ?? []];
|
|
1494
|
-
if (this.
|
|
1489
|
+
if (this.tokens.some((secret) => carried.some((text) => carries(text, secret)))) {
|
|
1495
1490
|
throw this.refuse("derived-no-secrets", address, `credentials may not be sent to ${address.host}, a host that is neither declared nor given by the user`);
|
|
1496
1491
|
}
|
|
1497
1492
|
}
|
|
@@ -1998,11 +1993,11 @@ function checkSearch(query, year) {
|
|
|
1998
1993
|
if (year !== void 0) checkYear(year);
|
|
1999
1994
|
return trimmed;
|
|
2000
1995
|
}
|
|
2001
|
-
function checkList(name2, kind, { genre, country, year }) {
|
|
2002
|
-
if (name2 === "upcoming" && kind === "series" || name2 === "onAir" && kind === "movie") {
|
|
1996
|
+
function checkList(name2, kind, { genre, country, year, network }) {
|
|
1997
|
+
if ((name2 === "upcoming" || name2 === "nowPlaying") && kind === "series" || name2 === "onAir" && kind === "movie") {
|
|
2003
1998
|
throw invalid(`${name2} has no ${kind} list`);
|
|
2004
1999
|
}
|
|
2005
|
-
const filtered = genre !== void 0 || country !== void 0 || year !== void 0;
|
|
2000
|
+
const filtered = genre !== void 0 || country !== void 0 || year !== void 0 || network !== void 0;
|
|
2006
2001
|
if (name2 !== "popular" && name2 !== "topRated") {
|
|
2007
2002
|
if (filtered) throw invalid(`${name2} cannot be filtered`);
|
|
2008
2003
|
return;
|
|
@@ -2010,6 +2005,7 @@ function checkList(name2, kind, { genre, country, year }) {
|
|
|
2010
2005
|
if (genre !== void 0 && !GENRES[kind].has(genre)) throw invalid(`genre ${genre} has no ${kind} list`);
|
|
2011
2006
|
if (country !== void 0 && !/^[A-Z]{2}$/.test(country)) throw invalid("country must be a two-letter ISO 3166-1 code");
|
|
2012
2007
|
if (year !== void 0) checkYear(year);
|
|
2008
|
+
if (network !== void 0 && kind === "movie") throw invalid("network has no movie list");
|
|
2013
2009
|
}
|
|
2014
2010
|
var fail = (message) => new TypeError(message);
|
|
2015
2011
|
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && !ArrayBuffer.isView(value);
|
|
@@ -2091,15 +2087,20 @@ function createMetadata(service) {
|
|
|
2091
2087
|
throw fail(`krillplayer.metadata.list needs a list name: ${ListName.values.join(", ")}`);
|
|
2092
2088
|
}
|
|
2093
2089
|
const checkedKind = kindOf(kind);
|
|
2094
|
-
const fields = optionsOf(options, ["genre", "country", "year", "cursor"], "list");
|
|
2090
|
+
const fields = optionsOf(options, ["genre", "country", "year", "network", "cursor"], "list");
|
|
2095
2091
|
const genre = textOf2(fields.genre, "genre");
|
|
2096
2092
|
if (genre !== void 0 && !Genre.values.includes(genre)) {
|
|
2097
2093
|
throw fail(`krillplayer.metadata.list: unknown genre ${genre}`);
|
|
2098
2094
|
}
|
|
2095
|
+
const network = textOf2(fields.network, "network");
|
|
2096
|
+
if (network !== void 0 && !Network.values.includes(network)) {
|
|
2097
|
+
throw fail(`krillplayer.metadata.list: unknown network ${network}`);
|
|
2098
|
+
}
|
|
2099
2099
|
const filter = {
|
|
2100
2100
|
...genre === void 0 ? {} : { genre },
|
|
2101
2101
|
...optional2("country", textOf2(fields.country, "country")),
|
|
2102
|
-
...optional2("year", integerOf(fields.year, "year"))
|
|
2102
|
+
...optional2("year", integerOf(fields.year, "year")),
|
|
2103
|
+
...network === void 0 ? {} : { network }
|
|
2103
2104
|
};
|
|
2104
2105
|
const cursor = textOf2(fields.cursor, "cursor");
|
|
2105
2106
|
return run2(() => metadata.list(name2, checkedKind, filter, cursor));
|
|
@@ -3781,16 +3782,21 @@ var isSecretParam = (value, names) => isSecretName(value) || names.has("u") && (
|
|
|
3781
3782
|
|
|
3782
3783
|
// trial-runner/credentials.ts
|
|
3783
3784
|
var REDACTED = "REDACTED";
|
|
3785
|
+
var REDACTED_TOKEN = "REDACTED-0000000000";
|
|
3786
|
+
var isRedacted = (value) => value === REDACTED || value === REDACTED_TOKEN;
|
|
3787
|
+
function fakeSecret(value) {
|
|
3788
|
+
return looksLikeToken(value) ? REDACTED_TOKEN : REDACTED;
|
|
3789
|
+
}
|
|
3784
3790
|
function fakeValue(value, index) {
|
|
3785
|
-
return /^\d+$/.test(value) ? String(9 - index % 9).repeat(value.length) :
|
|
3791
|
+
return /^\d+$/.test(value) ? String(9 - index % 9).repeat(value.length) : fakeSecret(value);
|
|
3786
3792
|
}
|
|
3787
3793
|
var isFakeId = (value) => /^(\d)\1*$/.test(value);
|
|
3788
3794
|
var SECRET_VALUES = [
|
|
3789
3795
|
/\bSESSDATA=(?!REDACTED\b)[^;&\s"]{8,}/,
|
|
3790
3796
|
/\bbili_jct=[0-9a-f]{16,}/i,
|
|
3791
|
-
/\bBearer\s+[\w.~+/-]{16,}/,
|
|
3797
|
+
/\bBearer\s+(?!(?:REDACTED-0{10}|REDACTED)(?![\w.~+/-]))[\w.~+/-]{16,}/,
|
|
3792
3798
|
/\beyJ[\w-]{8,}\.eyJ[\w-]{8,}\.[\w-]+/,
|
|
3793
|
-
/\b(?:access_key|access_token)=[\w.-]{16,}/
|
|
3799
|
+
/\b(?:access_key|access_token)=(?!(?:REDACTED-0{10}|REDACTED)(?![\w.-]))[\w.-]{16,}/
|
|
3794
3800
|
];
|
|
3795
3801
|
var redactSetCookie = (lines) => lines.split("\n").map((line) => line.replace(/^([^=;]*)=[^;]*/, `$1=${REDACTED}`)).join("\n");
|
|
3796
3802
|
var isRedactedSetCookie = (lines) => lines.split("\n").every((line) => new RegExp(`^[^=;]*=${REDACTED}(;|$)`).test(line));
|
|
@@ -3883,7 +3889,7 @@ function findingsIn(value, path, findings) {
|
|
|
3883
3889
|
const query = /^https?:\/\//.test(text) && URL.canParse(text) ? new URL(text).searchParams : queryOf(text);
|
|
3884
3890
|
if (query !== void 0) {
|
|
3885
3891
|
for (const [name2, entry] of query) {
|
|
3886
|
-
if (isSecretParam(name2, query) && entry
|
|
3892
|
+
if (isSecretParam(name2, query) && !isRedacted(entry) && entry !== "") findings.push(`${path}: query parameter ${name2}`);
|
|
3887
3893
|
}
|
|
3888
3894
|
}
|
|
3889
3895
|
return;
|
|
@@ -3899,7 +3905,7 @@ function findingsIn(value, path, findings) {
|
|
|
3899
3905
|
return;
|
|
3900
3906
|
}
|
|
3901
3907
|
for (const [key, entry] of Object.entries(value)) {
|
|
3902
|
-
const redacted = entry
|
|
3908
|
+
const redacted = isRedacted(entry) || typeof entry === "string" && isFakeId(entry) || key.toLowerCase() === "set-cookie" && typeof entry === "string" && isRedactedSetCookie(entry);
|
|
3903
3909
|
if (isSecretName(key) && typeof entry === "string" && !redacted && entry !== "") {
|
|
3904
3910
|
findings.push(`${path}.${key}: ${key}`);
|
|
3905
3911
|
}
|
|
@@ -4730,6 +4736,94 @@ function optional3(fields) {
|
|
|
4730
4736
|
return Object.fromEntries(Object.entries(fields).filter((entry) => entry[1] !== void 0));
|
|
4731
4737
|
}
|
|
4732
4738
|
|
|
4739
|
+
// trial-runner/capabilities.ts
|
|
4740
|
+
function inheritedFunctions(slot, functions) {
|
|
4741
|
+
const inherited = /* @__PURE__ */ new Set();
|
|
4742
|
+
for (let prototype = Object.getPrototypeOf(slot); prototype !== null; prototype = Object.getPrototypeOf(prototype)) {
|
|
4743
|
+
for (const member of Object.getOwnPropertyNames(prototype)) {
|
|
4744
|
+
if (functions.includes(member) && !Object.hasOwn(slot, member)) inherited.add(member);
|
|
4745
|
+
}
|
|
4746
|
+
}
|
|
4747
|
+
return [...inherited];
|
|
4748
|
+
}
|
|
4749
|
+
function capabilitiesOf(namespace) {
|
|
4750
|
+
const problems = [];
|
|
4751
|
+
const found = /* @__PURE__ */ new Set();
|
|
4752
|
+
for (const [name2, value] of Object.entries(namespace)) {
|
|
4753
|
+
const top = TOP_LEVEL_FUNCTIONS[name2];
|
|
4754
|
+
if (top !== void 0) {
|
|
4755
|
+
if (typeof value === "function") found.add(top);
|
|
4756
|
+
else problems.push(`${name2} must be a function`);
|
|
4757
|
+
continue;
|
|
4758
|
+
}
|
|
4759
|
+
const rule = SLOT_RULES[name2];
|
|
4760
|
+
if (rule === void 0) {
|
|
4761
|
+
problems.push(`exports ${name2}; plugins export only ${[...Object.keys(SLOT_RULES), ...Object.keys(TOP_LEVEL_FUNCTIONS)].join(", ")}`);
|
|
4762
|
+
continue;
|
|
4763
|
+
}
|
|
4764
|
+
if (typeof value !== "object" || value === null) {
|
|
4765
|
+
problems.push(`${name2} must be an object of functions`);
|
|
4766
|
+
continue;
|
|
4767
|
+
}
|
|
4768
|
+
const has = (member) => typeof slotMember(value, member) === "function";
|
|
4769
|
+
for (const member of Object.getOwnPropertyNames(value)) {
|
|
4770
|
+
if (!rule.functions.includes(member)) problems.push(`${name2}.${member} is not in the contract (${rule.functions.join(", ")})`);
|
|
4771
|
+
else if (!has(member)) problems.push(`${name2}.${member} must be a function`);
|
|
4772
|
+
}
|
|
4773
|
+
for (const member of inheritedFunctions(value, rule.functions)) {
|
|
4774
|
+
problems.push(`${name2}.${member} is inherited; slot functions must be the object's own properties (an object literal, not a class instance)`);
|
|
4775
|
+
}
|
|
4776
|
+
for (const member of rule.required) if (!has(member)) problems.push(`${name2} needs ${member}`);
|
|
4777
|
+
for (const [first, second] of rule.pairs) {
|
|
4778
|
+
if (has(first) !== has(second)) {
|
|
4779
|
+
const [present, missing] = has(first) ? [first, second] : [second, first];
|
|
4780
|
+
problems.push(`${name2}.${present} needs ${name2}.${missing}`);
|
|
4781
|
+
}
|
|
4782
|
+
}
|
|
4783
|
+
const matched = Object.entries(rule.capabilities).filter(([, any]) => any.some(has)).map(([capability]) => capability);
|
|
4784
|
+
const superseded = new Set(matched.flatMap((capability) => rule.supersedes?.[capability] ?? []));
|
|
4785
|
+
const generated = matched.filter((capability) => !superseded.has(capability));
|
|
4786
|
+
generated.forEach((capability) => found.add(capability));
|
|
4787
|
+
const all = Object.values(rule.capabilities).flat();
|
|
4788
|
+
if (all.length > 0 && generated.length === 0) problems.push(`${name2} needs one of ${all.join(", ")}`);
|
|
4789
|
+
}
|
|
4790
|
+
return { capabilities: Capability.values.filter((name2) => found.has(name2)), problems };
|
|
4791
|
+
}
|
|
4792
|
+
|
|
4793
|
+
// trial-runner/sandbox.ts
|
|
4794
|
+
import vm from "node:vm";
|
|
4795
|
+
var UTF8_LABELS = /* @__PURE__ */ new Set(["unicode-1-1-utf-8", "unicode11utf8", "unicode20utf8", "utf-8", "utf8", "x-unicode20utf8"]);
|
|
4796
|
+
var Utf8TextDecoder = class extends TextDecoder {
|
|
4797
|
+
constructor(label = "utf-8", options) {
|
|
4798
|
+
if (!UTF8_LABELS.has(String(label).trim().toLowerCase())) {
|
|
4799
|
+
throw new RangeError(`TextDecoder only supports utf-8, not ${label}`);
|
|
4800
|
+
}
|
|
4801
|
+
super("utf-8", options);
|
|
4802
|
+
}
|
|
4803
|
+
};
|
|
4804
|
+
async function loadPlugin(source, { identifier, allowCodeGeneration }) {
|
|
4805
|
+
const context = vm.createContext({}, { codeGeneration: { strings: allowCodeGeneration, wasm: false } });
|
|
4806
|
+
const remaining = vm.runInContext(`(() => {
|
|
4807
|
+
const allowed = new Set(${JSON.stringify([...PLUGIN_GLOBALS])});
|
|
4808
|
+
for (const name of Object.getOwnPropertyNames(globalThis)) if (!allowed.has(name)) delete globalThis[name];
|
|
4809
|
+
return Object.getOwnPropertyNames(globalThis).filter((name) => !allowed.has(name));
|
|
4810
|
+
})()`, context);
|
|
4811
|
+
if (remaining.length > 0) throw new Error(`could not remove globals: ${remaining.join(", ")}`);
|
|
4812
|
+
const global = vm.runInContext("globalThis", context);
|
|
4813
|
+
const silent = () => {
|
|
4814
|
+
};
|
|
4815
|
+
const consoleObject = Object.freeze({ debug: silent, trace: silent, log: silent, info: silent, warn: silent, error: silent });
|
|
4816
|
+
for (const [name2, value] of [["TextEncoder", TextEncoder], ["TextDecoder", Utf8TextDecoder], ["console", consoleObject]]) {
|
|
4817
|
+
Object.defineProperty(global, name2, { value, writable: true, configurable: true });
|
|
4818
|
+
}
|
|
4819
|
+
const module = new vm.SourceTextModule(source, { context, identifier });
|
|
4820
|
+
await module.link(() => {
|
|
4821
|
+
throw new Error("plugins cannot import modules");
|
|
4822
|
+
});
|
|
4823
|
+
await module.evaluate();
|
|
4824
|
+
return module.namespace;
|
|
4825
|
+
}
|
|
4826
|
+
|
|
4733
4827
|
// trial-runner/static-check.ts
|
|
4734
4828
|
import { Linter } from "eslint";
|
|
4735
4829
|
var globalsRule = {
|
|
@@ -4779,6 +4873,13 @@ var RESERVED_PARAMETER_PREFIX = "krillplayer.files.";
|
|
|
4779
4873
|
function checkManifest(manifest) {
|
|
4780
4874
|
const parameters = Array.isArray(manifest.parameters) ? manifest.parameters : [];
|
|
4781
4875
|
const problems = [];
|
|
4876
|
+
if (manifest.loginRequired === true && Array.isArray(manifest.capabilities) && !manifest.capabilities.includes("login")) {
|
|
4877
|
+
problems.push("loginRequired needs a login slot: export login so the user can log in when adding a source, or drop loginRequired");
|
|
4878
|
+
}
|
|
4879
|
+
for (const parameter of parameters) {
|
|
4880
|
+
if (typeof parameter !== "object" || parameter === null || parameter.perSource === void 0) continue;
|
|
4881
|
+
problems.push(`parameter ${String(parameter.name)} sets perSource, which only applies to settings: instance parameters already belong to one source`);
|
|
4882
|
+
}
|
|
4782
4883
|
for (const parameter of parameters) {
|
|
4783
4884
|
if (typeof parameter !== "object" || parameter === null) continue;
|
|
4784
4885
|
const { name: name2, dependsOn, visibleWhen } = parameter;
|
|
@@ -4826,6 +4927,7 @@ async function readPlugin(path) {
|
|
|
4826
4927
|
const manifest = JSON.parse(files2.get("manifest.json") ?? "{}");
|
|
4827
4928
|
const source = files2.get(scripts[0]);
|
|
4828
4929
|
const checked = checkPlugin(source);
|
|
4930
|
+
const capabilities = Array.isArray(manifest.capabilities) || checked.violations.length > 0 ? manifest.capabilities : await loadPlugin(source, { identifier: join3(path, scripts[0]), allowCodeGeneration: !checked.exports.includes("status") }).then((namespace) => capabilitiesOf(namespace).capabilities, () => void 0);
|
|
4829
4931
|
return {
|
|
4830
4932
|
id: manifest.id ?? basename(resolve(path)),
|
|
4831
4933
|
file: join3(path, scripts[0]),
|
|
@@ -4839,7 +4941,7 @@ async function readPlugin(path) {
|
|
|
4839
4941
|
dictionaries: dictionariesIn(files2),
|
|
4840
4942
|
exports: checked.exports,
|
|
4841
4943
|
// 清单用了内核留用的参数名(contract.md 6.1)和静态检查拦下的一样判红。
|
|
4842
|
-
violations: [...checked.violations, ...checkManifest(manifest).map((problem) => ` manifest.json: ${problem}`)]
|
|
4944
|
+
violations: [...checked.violations, ...checkManifest({ ...manifest, capabilities }).map((problem) => ` manifest.json: ${problem}`)]
|
|
4843
4945
|
};
|
|
4844
4946
|
}
|
|
4845
4947
|
var TRIAL_CAPABILITIES = new Set(Object.keys(createKrillPlayer({
|
|
@@ -4987,8 +5089,8 @@ async function recordCommand(pluginDirectory, { slot, call: callName, args, cred
|
|
|
4987
5089
|
const redacted = credentials === null ? null : Object.fromEntries(Object.entries(credentials).map(([key, value]) => [key, typeof value === "string" ? withOwnValuesReplaced(value, own) : REDACTED]));
|
|
4988
5090
|
const keptArgs = withOwnValuesReplaced(args, own);
|
|
4989
5091
|
const secret = new Set(plugin2.parameters.filter((parameter) => parameter.secret).map((parameter) => parameter.name));
|
|
4990
|
-
const kept = parameters === void 0 ? void 0 : Object.fromEntries(Object.entries(parameters).map(([name2, value]) => [name2, secret.has(name2) ?
|
|
4991
|
-
const keptKeys = appKeys === void 0 ? void 0 : Object.fromEntries(Object.
|
|
5092
|
+
const kept = parameters === void 0 ? void 0 : Object.fromEntries(Object.entries(parameters).map(([name2, value]) => [name2, secret.has(name2) ? fakeSecret(value) : value]));
|
|
5093
|
+
const keptKeys = appKeys === void 0 ? void 0 : Object.fromEntries(Object.entries(appKeys).map(([name2, key]) => [name2, fakeSecret(key)]));
|
|
4992
5094
|
const exchanges = withOwnValuesReplaced(
|
|
4993
5095
|
withoutValues(recording.exchanges, Object.values(appKeys ?? {}).filter((key) => key !== "")),
|
|
4994
5096
|
own
|
|
@@ -5025,7 +5127,7 @@ ${findings.join("\n")}`);
|
|
|
5025
5127
|
function withoutValues(value, secrets) {
|
|
5026
5128
|
if (secrets.length === 0) return value;
|
|
5027
5129
|
const walk = (item) => {
|
|
5028
|
-
if (typeof item === "string") return secrets.reduce((text, secret) => text.split(secret).join(
|
|
5130
|
+
if (typeof item === "string") return secrets.reduce((text, secret) => text.split(secret).join(fakeSecret(secret)), item);
|
|
5029
5131
|
if (Array.isArray(item)) return item.map(walk);
|
|
5030
5132
|
if (item !== null && typeof item === "object") return Object.fromEntries(Object.entries(item).map(([key, entry]) => [key, walk(entry)]));
|
|
5031
5133
|
return item;
|
|
@@ -5086,7 +5188,7 @@ function withOwnValuesReplaced(value, own) {
|
|
|
5086
5188
|
return walk(value);
|
|
5087
5189
|
}
|
|
5088
5190
|
function leftoverValues(testCase, own) {
|
|
5089
|
-
const checked = own.filter(({ value }) => value.length >= 3 && value
|
|
5191
|
+
const checked = own.filter(({ value }) => value.length >= 3 && !isRedacted(value));
|
|
5090
5192
|
if (checked.length === 0) return [];
|
|
5091
5193
|
const pattern = bytePattern(checked);
|
|
5092
5194
|
const values = new Set(checked.map(({ value }) => value));
|
|
@@ -5131,40 +5233,6 @@ if (false) {
|
|
|
5131
5233
|
}
|
|
5132
5234
|
}
|
|
5133
5235
|
|
|
5134
|
-
// trial-runner/sandbox.ts
|
|
5135
|
-
import vm from "node:vm";
|
|
5136
|
-
var UTF8_LABELS = /* @__PURE__ */ new Set(["unicode-1-1-utf-8", "unicode11utf8", "unicode20utf8", "utf-8", "utf8", "x-unicode20utf8"]);
|
|
5137
|
-
var Utf8TextDecoder = class extends TextDecoder {
|
|
5138
|
-
constructor(label = "utf-8", options) {
|
|
5139
|
-
if (!UTF8_LABELS.has(String(label).trim().toLowerCase())) {
|
|
5140
|
-
throw new RangeError(`TextDecoder only supports utf-8, not ${label}`);
|
|
5141
|
-
}
|
|
5142
|
-
super("utf-8", options);
|
|
5143
|
-
}
|
|
5144
|
-
};
|
|
5145
|
-
async function loadPlugin(source, { identifier, allowCodeGeneration }) {
|
|
5146
|
-
const context = vm.createContext({}, { codeGeneration: { strings: allowCodeGeneration, wasm: false } });
|
|
5147
|
-
const remaining = vm.runInContext(`(() => {
|
|
5148
|
-
const allowed = new Set(${JSON.stringify([...PLUGIN_GLOBALS])});
|
|
5149
|
-
for (const name of Object.getOwnPropertyNames(globalThis)) if (!allowed.has(name)) delete globalThis[name];
|
|
5150
|
-
return Object.getOwnPropertyNames(globalThis).filter((name) => !allowed.has(name));
|
|
5151
|
-
})()`, context);
|
|
5152
|
-
if (remaining.length > 0) throw new Error(`could not remove globals: ${remaining.join(", ")}`);
|
|
5153
|
-
const global = vm.runInContext("globalThis", context);
|
|
5154
|
-
const silent = () => {
|
|
5155
|
-
};
|
|
5156
|
-
const consoleObject = Object.freeze({ debug: silent, trace: silent, log: silent, info: silent, warn: silent, error: silent });
|
|
5157
|
-
for (const [name2, value] of [["TextEncoder", TextEncoder], ["TextDecoder", Utf8TextDecoder], ["console", consoleObject]]) {
|
|
5158
|
-
Object.defineProperty(global, name2, { value, writable: true, configurable: true });
|
|
5159
|
-
}
|
|
5160
|
-
const module = new vm.SourceTextModule(source, { context, identifier });
|
|
5161
|
-
await module.link(() => {
|
|
5162
|
-
throw new Error("plugins cannot import modules");
|
|
5163
|
-
});
|
|
5164
|
-
await module.evaluate();
|
|
5165
|
-
return module.namespace;
|
|
5166
|
-
}
|
|
5167
|
-
|
|
5168
5236
|
// packer/pack.ts
|
|
5169
5237
|
var TEMPLATES = fileURLToPath2(new URL("../templates/", import.meta.url));
|
|
5170
5238
|
var SAMPLES = fileURLToPath2(new URL("../samples/src/", import.meta.url));
|
|
@@ -5215,59 +5283,6 @@ async function dictionaries(directory) {
|
|
|
5215
5283
|
if (problems.length > 0) throw new Error(`${directory}: ${problems.join("; ")}`);
|
|
5216
5284
|
return result.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
5217
5285
|
}
|
|
5218
|
-
function inheritedFunctions(slot, functions) {
|
|
5219
|
-
const inherited = /* @__PURE__ */ new Set();
|
|
5220
|
-
for (let prototype = Object.getPrototypeOf(slot); prototype !== null; prototype = Object.getPrototypeOf(prototype)) {
|
|
5221
|
-
for (const member of Object.getOwnPropertyNames(prototype)) {
|
|
5222
|
-
if (functions.includes(member) && !Object.hasOwn(slot, member)) inherited.add(member);
|
|
5223
|
-
}
|
|
5224
|
-
}
|
|
5225
|
-
return [...inherited];
|
|
5226
|
-
}
|
|
5227
|
-
function capabilitiesOf(namespace) {
|
|
5228
|
-
const problems = [];
|
|
5229
|
-
const found = /* @__PURE__ */ new Set();
|
|
5230
|
-
for (const [name2, value] of Object.entries(namespace)) {
|
|
5231
|
-
const top = TOP_LEVEL_FUNCTIONS[name2];
|
|
5232
|
-
if (top !== void 0) {
|
|
5233
|
-
if (typeof value === "function") found.add(top);
|
|
5234
|
-
else problems.push(`${name2} must be a function`);
|
|
5235
|
-
continue;
|
|
5236
|
-
}
|
|
5237
|
-
const rule = SLOT_RULES[name2];
|
|
5238
|
-
if (rule === void 0) {
|
|
5239
|
-
problems.push(`exports ${name2}; plugins export only ${[...Object.keys(SLOT_RULES), ...Object.keys(TOP_LEVEL_FUNCTIONS)].join(", ")}`);
|
|
5240
|
-
continue;
|
|
5241
|
-
}
|
|
5242
|
-
if (typeof value !== "object" || value === null) {
|
|
5243
|
-
problems.push(`${name2} must be an object of functions`);
|
|
5244
|
-
continue;
|
|
5245
|
-
}
|
|
5246
|
-
const has = (member) => typeof slotMember(value, member) === "function";
|
|
5247
|
-
for (const member of Object.getOwnPropertyNames(value)) {
|
|
5248
|
-
if (!rule.functions.includes(member)) problems.push(`${name2}.${member} is not in the contract (${rule.functions.join(", ")})`);
|
|
5249
|
-
else if (!has(member)) problems.push(`${name2}.${member} must be a function`);
|
|
5250
|
-
}
|
|
5251
|
-
for (const member of inheritedFunctions(value, rule.functions)) {
|
|
5252
|
-
problems.push(`${name2}.${member} is inherited; slot functions must be the object's own properties (an object literal, not a class instance)`);
|
|
5253
|
-
}
|
|
5254
|
-
for (const member of rule.required) if (!has(member)) problems.push(`${name2} needs ${member}`);
|
|
5255
|
-
for (const [first, second] of rule.pairs) {
|
|
5256
|
-
if (has(first) !== has(second)) {
|
|
5257
|
-
const [present, missing] = has(first) ? [first, second] : [second, first];
|
|
5258
|
-
problems.push(`${name2}.${present} needs ${name2}.${missing}`);
|
|
5259
|
-
}
|
|
5260
|
-
}
|
|
5261
|
-
const generated = Object.entries(rule.capabilities).filter(([, any]) => any.some(has)).map(([capability]) => capability);
|
|
5262
|
-
generated.forEach((capability) => found.add(capability));
|
|
5263
|
-
const all = Object.values(rule.capabilities).flat();
|
|
5264
|
-
if (all.length > 0 && generated.length === 0) problems.push(`${name2} needs one of ${all.join(", ")}`);
|
|
5265
|
-
}
|
|
5266
|
-
if (found.has("library") && found.has("resources")) {
|
|
5267
|
-
problems.push("exports both library and resources; a source that lists all its content is scanned into the library, so it does not also answer find");
|
|
5268
|
-
}
|
|
5269
|
-
return { capabilities: Capability.values.filter((name2) => found.has(name2)), problems };
|
|
5270
|
-
}
|
|
5271
5286
|
function notYetUsedExports(namespace) {
|
|
5272
5287
|
const unused = new Set(NOT_YET_USED);
|
|
5273
5288
|
const exported2 = Object.entries(namespace).flatMap(([name2, value]) => TOP_LEVEL_FUNCTIONS[name2] !== void 0 ? [name2] : (SLOT_RULES[name2]?.functions ?? []).filter((member) => typeof slotMember(value, member) === "function").map((member) => `${name2}.${member}`));
|
|
@@ -5299,7 +5314,7 @@ async function pack(directory, warn = () => {
|
|
|
5299
5314
|
if (metadata.interfaceLevel > CONTRACT.interfaceLevel || metadata.contractRevision !== CONTRACT.revision) {
|
|
5300
5315
|
throw new Error(`${directory}/manifest.ts targets interface level ${metadata.interfaceLevel} revision ${metadata.contractRevision}; the contract is level ${CONTRACT.interfaceLevel} revision ${CONTRACT.revision}`);
|
|
5301
5316
|
}
|
|
5302
|
-
const reserved = checkManifest(metadata);
|
|
5317
|
+
const reserved = checkManifest({ ...metadata, capabilities });
|
|
5303
5318
|
if (reserved.length > 0) throw new Error(`${directory}/manifest.ts: ${reserved.join("; ")}`);
|
|
5304
5319
|
const locales = await dictionaries(directory);
|
|
5305
5320
|
if (locales.length > 0 && metadata.language === void 0) {
|