wildcrane-artifact-sdk 0.1.0 → 0.1.1
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 +32 -4
- package/dist/builtin/compare.json +15 -0
- package/dist/builtin/html.json +6 -0
- package/dist/builtin/image.json +1 -0
- package/dist/builtin/index.d.ts +2 -0
- package/dist/builtin/index.js +13 -0
- package/dist/builtin/markdown.json +9 -0
- package/dist/builtin/spritesheet.json +23 -0
- package/dist/builtin/storyboard.json +33 -0
- package/dist/builtin/studio.json +488 -0
- package/dist/builtin/tiled.json +11 -0
- package/dist/builtin/video.json +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1 -0
- package/dist/internal/asset-formats.d.ts +16 -0
- package/dist/internal/asset-formats.js +61 -0
- package/dist/internal/asset-store.d.ts +109 -0
- package/dist/internal/asset-store.js +5 -0
- package/dist/internal/collect.d.ts +43 -0
- package/dist/internal/collect.js +154 -0
- package/dist/internal/document.d.ts +7 -0
- package/dist/internal/document.js +9 -0
- package/dist/internal/file-references.d.ts +6 -0
- package/dist/internal/file-references.js +29 -0
- package/dist/internal/format/captions.d.ts +6 -0
- package/dist/internal/format/captions.js +31 -0
- package/dist/internal/format/compare.d.ts +34 -0
- package/dist/internal/format/compare.js +59 -0
- package/dist/internal/format/spritesheet.d.ts +25 -0
- package/dist/internal/format/spritesheet.js +50 -0
- package/dist/internal/format/storyboard.d.ts +8 -0
- package/dist/internal/format/storyboard.js +21 -0
- package/dist/internal/format/studio.d.ts +68 -0
- package/dist/internal/format/studio.js +58 -0
- package/dist/internal/hyperframe-document.d.ts +14 -0
- package/dist/internal/hyperframe-document.js +80 -0
- package/dist/internal/manifest.d.ts +48 -0
- package/dist/internal/manifest.js +102 -0
- package/dist/internal/markdown-code.d.ts +3 -0
- package/dist/internal/markdown-code.js +51 -0
- package/dist/internal/markdown-destinations.d.ts +7 -0
- package/dist/internal/markdown-destinations.js +52 -0
- package/dist/internal/mockup-tag.d.ts +194 -0
- package/dist/internal/mockup-tag.js +8 -0
- package/dist/internal/previews.d.ts +163 -0
- package/dist/internal/previews.js +798 -0
- package/dist/internal/references.d.ts +65 -0
- package/dist/internal/references.js +209 -0
- package/dist/internal/schema.d.ts +2 -0
- package/dist/internal/schema.js +83 -0
- package/dist/internal/storyboard.d.ts +84 -0
- package/dist/internal/storyboard.js +71 -0
- package/dist/internal/tags.d.ts +37 -0
- package/dist/internal/tags.js +66 -0
- package/dist/internal/task-assets.d.ts +122 -0
- package/dist/internal/task-assets.js +87 -0
- package/dist/internal/web-references.d.ts +21 -0
- package/dist/internal/web-references.js +162 -0
- package/package.json +2 -2
- package/src/builtin/compare.json +15 -0
- package/src/builtin/html.json +6 -0
- package/src/builtin/image.json +1 -0
- package/src/builtin/index.ts +15 -0
- package/src/builtin/markdown.json +9 -0
- package/src/builtin/spritesheet.json +23 -0
- package/src/builtin/storyboard.json +33 -0
- package/src/builtin/studio.json +488 -0
- package/src/builtin/tiled.json +11 -0
- package/src/builtin/video.json +1 -0
- package/src/index.ts +4 -0
- package/src/internal/asset-formats.ts +66 -0
- package/src/internal/asset-store.ts +41 -0
- package/src/internal/collect.ts +158 -0
- package/src/internal/document.ts +12 -0
- package/src/internal/file-references.ts +34 -0
- package/src/internal/format/captions.ts +34 -0
- package/src/internal/format/compare.ts +63 -0
- package/src/internal/format/spritesheet.ts +53 -0
- package/src/internal/format/storyboard.ts +22 -0
- package/src/internal/format/studio.ts +69 -0
- package/src/internal/hyperframe-document.ts +75 -0
- package/src/internal/manifest.ts +124 -0
- package/src/internal/markdown-code.ts +48 -0
- package/src/internal/markdown-destinations.ts +45 -0
- package/src/internal/mockup-tag.ts +128 -0
- package/src/internal/previews.ts +766 -0
- package/src/internal/references.ts +195 -0
- package/src/internal/schema.ts +69 -0
- package/src/internal/storyboard.ts +127 -0
- package/src/internal/tags.ts +94 -0
- package/src/internal/task-assets.ts +114 -0
- package/src/internal/web-references.ts +160 -0
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ publish it to your WildCrane account. When an agent submits an artifact of that
|
|
|
5
5
|
page draws it with your component.
|
|
6
6
|
|
|
7
7
|
```
|
|
8
|
-
|
|
8
|
+
app.wildcrane.ai ──postMessage──▶ <hash>.wildcraneusercontent.com (your bundle)
|
|
9
9
|
holds the sign-in, sandboxed iframe, no network,
|
|
10
10
|
validates and saves sees only the artifact it is handed
|
|
11
11
|
```
|
|
@@ -13,7 +13,7 @@ review.wildcrane.ai ──postMessage──▶ <hash>.wildcraneusercontent.com (
|
|
|
13
13
|
- **Yours alone**: a component draws artifacts only on tasks your account started.
|
|
14
14
|
- **No network**: `connect-src 'none'`, so not even `fetch` of your own files; bundle every script, style, font and image, and import data instead of fetching it.
|
|
15
15
|
- **Saving**: only the account's owners get `readOnly: false`. A save becomes the artifact's
|
|
16
|
-
next version
|
|
16
|
+
next version. Approving stays on the review page.
|
|
17
17
|
- **Pinned**: an artifact version keeps the component version that was newest when it was
|
|
18
18
|
written; publishing later changes nothing already submitted.
|
|
19
19
|
|
|
@@ -37,8 +37,26 @@ A folder of static files with `index.html` at its top, at most 10 MB, any framew
|
|
|
37
37
|
- **`version`**: semver, published once.
|
|
38
38
|
- **`types`**: the artifact types it draws, each `@<your GitHub handle>/<name>`, lowercase.
|
|
39
39
|
- **`schema`**: optional JSON Schema every save must match. The review page checks `type`,
|
|
40
|
-
`enum`, `const`, `properties`, `required`, `additionalProperties`, `items`, `minItems`,
|
|
40
|
+
`enum`, `const`, `anyOf`, `properties`, `required`, `additionalProperties`, `items`, `minItems`,
|
|
41
41
|
`maxItems`, `minLength`, `maxLength`, `pattern`, `minimum` and `maximum`. A save is at most 256 KB.
|
|
42
|
+
- **`references`**: optional; where the content names other files of the task, so the page
|
|
43
|
+
hands them to you. `{ "json": "/path" }` is a field (`*` for every item), `{ "text": "regex" }`
|
|
44
|
+
the first group of each case-insensitive match in text content, split by `list` when set.
|
|
45
|
+
|
|
46
|
+
A subtitle track over its video, the video's artifact id in `video`:
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"types": ["@your-handle/subtitles"],
|
|
51
|
+
"schema": { "type": "object", "required": ["video", "cues"] },
|
|
52
|
+
"references": [{ "json": "/video" }]
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
const { data, contentType } = bridge.files[bridge.artifact.content.video];
|
|
58
|
+
video.src = URL.createObjectURL(new Blob([data], { type: contentType }));
|
|
59
|
+
```
|
|
42
60
|
|
|
43
61
|
```sh
|
|
44
62
|
npm install wildcrane-artifact-sdk
|
|
@@ -49,6 +67,7 @@ import { connect } from "wildcrane-artifact-sdk";
|
|
|
49
67
|
|
|
50
68
|
const bridge = await connect();
|
|
51
69
|
// bridge.artifact: { type, name, version, content } or { …, file: { data: ArrayBuffer, contentType } }
|
|
70
|
+
// bridge.files: { [reference]: { data, contentType } }, the files `references` point at
|
|
52
71
|
// bridge.readOnly, bridge.locale ("zh" | "en"), bridge.theme ("light" | "dark")
|
|
53
72
|
await bridge.save(next); // rejects with the reason, in bridge.locale
|
|
54
73
|
bridge.onChange((ctx) => redraw(ctx));
|
|
@@ -65,7 +84,8 @@ WILDCRANE_API_KEY=wck_… npx wildcrane-artifact-sdk publish dist
|
|
|
65
84
|
|
|
66
85
|
Every file in the folder but dot files goes into the bundle. With Vite, put the manifest in
|
|
67
86
|
`public/` and publish `dist`. Then submit an artifact of your type:
|
|
68
|
-
`POST /v1/tasks/{id}/artifacts { "type": "@your-handle/subtitles"
|
|
87
|
+
`POST /v1/tasks/{id}/artifacts { "type": "@your-handle/subtitles" }`; it is reviewed with the
|
|
88
|
+
card's current phase.
|
|
69
89
|
`GET /v1/components` lists what you published; `DELETE
|
|
70
90
|
/v1/components/{name}/versions/{version}` removes a version, and artifacts pinned to it show that
|
|
71
91
|
their preview cannot be drawn.
|
|
@@ -78,3 +98,11 @@ manifest, then `npm run example`.
|
|
|
78
98
|
## Develop
|
|
79
99
|
|
|
80
100
|
`npm install`, then `npm run lint`.
|
|
101
|
+
|
|
102
|
+
## 仓库内接入
|
|
103
|
+
|
|
104
|
+
- **组件清单**:内置组件的清单在 `src/builtin/*.json`,与第三方同一写法;SDK 只按清单的 `references` 与 `schema` 收集依赖、校验内容,不为内置类型单写规则。
|
|
105
|
+
- **依赖收集**:`src/internal/collect.ts` 从卡片正文出发走完可达图,按依赖顺序输出,文件里的问题记在该文件上;Runner 上传与 `akb raw validate` 共用它,文件读取与路径边界由调用方提供。
|
|
106
|
+
- **网页依赖**:页面引用的图片、字体各自上传一次,上传时引用改写为 artifact ID;审阅页把文件交给沙箱页面,由页面自建地址。
|
|
107
|
+
- **内置预览**:`src/internal/previews.ts` 通过 SDK `Context` 读取内容,按卡片清单固定版本并统一权限与错误;网页只提供鉴权服务和显示外框。
|
|
108
|
+
- **打包边界**:Runner 和网页直接打包内部源码;浏览器入口不依赖 Node,内部模块不属于公开 API,第三方继续使用 `connect()`。
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "compare",
|
|
3
|
+
"title": { "en": "Compare", "zh": "对比" },
|
|
4
|
+
"types": ["compare"],
|
|
5
|
+
"schema": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["a", "b"],
|
|
8
|
+
"properties": { "a": { "type": "string" }, "b": { "type": "string" } }
|
|
9
|
+
},
|
|
10
|
+
"references": [
|
|
11
|
+
{ "json": "/a", "types": ["storyboard", "compare", "spritesheet", "studio"] },
|
|
12
|
+
{ "json": "/b", "types": ["storyboard", "compare", "spritesheet", "studio"] },
|
|
13
|
+
{ "json": "/shots", "types": ["storyboard", "compare", "spritesheet", "studio"] }
|
|
14
|
+
]
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "name": "image", "title": { "en": "Image", "zh": "图片" }, "types": ["image"] }
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// 内置组件的清单,与第三方的 wildcrane.component.json 同一写法。
|
|
2
|
+
import compare from './compare.json';
|
|
3
|
+
import html from './html.json';
|
|
4
|
+
import image from './image.json';
|
|
5
|
+
import markdown from './markdown.json';
|
|
6
|
+
import spritesheet from './spritesheet.json';
|
|
7
|
+
import storyboard from './storyboard.json';
|
|
8
|
+
import tiled from './tiled.json';
|
|
9
|
+
import video from './video.json';
|
|
10
|
+
import studio from './studio.json';
|
|
11
|
+
// akb 的打包把 JSON 当文本读入。
|
|
12
|
+
const read = (m) => (typeof m === 'string' ? JSON.parse(m) : m);
|
|
13
|
+
export default [html, image, video, markdown, storyboard, compare, studio, tiled, spritesheet].map(read);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "spritesheet",
|
|
3
|
+
"title": { "en": "Sprite animation", "zh": "精灵动画" },
|
|
4
|
+
"types": ["spritesheet"],
|
|
5
|
+
"schema": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["frames", "meta"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"frames": {
|
|
10
|
+
"anyOf": [
|
|
11
|
+
{ "type": "array", "minItems": 1, "items": { "type": "object", "required": ["frame"] } },
|
|
12
|
+
{ "type": "object", "additionalProperties": { "type": "object", "required": ["frame"] } }
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
"meta": {
|
|
16
|
+
"type": "object",
|
|
17
|
+
"required": ["app", "image"],
|
|
18
|
+
"properties": { "app": { "type": "string", "pattern": "codeandweb\\.com/texturepacker" }, "image": { "type": "string" } }
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"references": [{ "json": "/meta/image" }]
|
|
23
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "storyboard",
|
|
3
|
+
"title": { "en": "Storyboard", "zh": "分镜" },
|
|
4
|
+
"types": ["storyboard"],
|
|
5
|
+
"schema": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"anyOf": [{ "required": ["shots"] }, { "required": ["slides"] }],
|
|
8
|
+
"properties": {
|
|
9
|
+
"shots": {
|
|
10
|
+
"type": "array",
|
|
11
|
+
"items": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"properties": { "frames": { "type": "array", "items": { "type": "object", "properties": { "src": { "type": "string" } } } } }
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"slides": {
|
|
17
|
+
"type": "array",
|
|
18
|
+
"items": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"properties": {
|
|
21
|
+
"preview": { "type": "object", "properties": { "src": { "type": "string" } } },
|
|
22
|
+
"assets": { "type": "array", "items": { "type": "string" } }
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"references": [
|
|
29
|
+
{ "json": "/shots/*/frames/*/src", "types": ["storyboard", "compare", "spritesheet", "studio"] },
|
|
30
|
+
{ "json": "/slides/*/preview/src", "types": ["storyboard", "compare", "spritesheet", "studio"] },
|
|
31
|
+
{ "json": "/slides/*/assets/*" }
|
|
32
|
+
]
|
|
33
|
+
}
|