@fulate/import 1.0.19 → 2.0.11
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 +31 -24
- package/dist/fulate/codec.d.ts +32 -0
- package/dist/fulate/index.d.ts +13 -13
- package/dist/fulate/upgrade.d.ts +3 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.js +370 -170
- package/dist/sketch/converter.d.ts +1 -1
- package/dist/sketch/index.d.ts +3 -2
- package/dist/util/index.d.ts +2 -2
- package/package.json +28 -28
package/README.md
CHANGED
|
@@ -1,38 +1,45 @@
|
|
|
1
1
|
# `@fulate/import`
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
owner。
|
|
3
|
+
当前文件与剪贴板共用 v2 canonical payload 和同一张 codec map。Scene codec 递归装配 children,
|
|
4
|
+
element codec 只编码和创建自身。长期合同见 [Path/Line 规范](../../docs/specs/path-line-core.md#71-file-与-clipboard-v2)。
|
|
6
5
|
|
|
7
|
-
##
|
|
6
|
+
## 文件与自定义类型
|
|
8
7
|
|
|
9
8
|
```ts
|
|
10
9
|
import {
|
|
11
|
-
serializeSceneToJSON,
|
|
12
|
-
parseFileData,
|
|
13
|
-
restoreScene
|
|
10
|
+
elementV2Codecs, serializeSceneToJSON, parseFileData, restoreScene
|
|
14
11
|
} from "@fulate/import";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
import { vueShapeV2Codec } from "@fulate/vue";
|
|
13
|
+
import { eChartsV2Codec } from "@fulate/echart";
|
|
14
|
+
import { Select } from "@fulate/tools";
|
|
15
|
+
|
|
16
|
+
const codecs = new Map([
|
|
17
|
+
...elementV2Codecs,
|
|
18
|
+
["vue-component", vueShapeV2Codec],
|
|
19
|
+
["echarts", eChartsV2Codec]
|
|
20
|
+
]);
|
|
21
|
+
const select = new Select({ codecs });
|
|
22
|
+
const json = serializeSceneToJSON(root, codecs);
|
|
23
|
+
restoreScene(root, parseFileData(json), codecs);
|
|
19
24
|
```
|
|
20
25
|
|
|
21
|
-
|
|
22
|
-
`
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
文件选择取消或读取完成前 Root 已卸载时,文件导入返回 `false`;尚未激活的 Root 仍可导入。
|
|
26
|
-
`parseFileData()` 只执行 JSON parse;声明格式错误和 restore 错误直接传播。History 属于应用组合层,
|
|
27
|
-
成功恢复场景后由拥有 Select 的应用决定是否清空。
|
|
26
|
+
Map key 必须精确等于 DTO `type`。扩展提供 `ElementV2Codec.encode(element)` 与
|
|
27
|
+
`decode(payload)`;codec 不递归 children。按需要覆写 `getPersistentChildren()`,例如不保存组件运行时子树。
|
|
28
|
+
`encodeElement(element, codecs)` 返回独立递归 DTO;`decodeElement(data, codecs)` 按引用采用 canonical
|
|
29
|
+
payload、保留 key 与局部 IDs。Line 保存 `geometry` union;Polygon/VectorPath 保存 canonical records。
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
`serializeScene()` 保存 Root 配置及元素树;文件 marker 为 `__fulate_file__`,`version` 为 `2.1`。
|
|
32
|
+
`exportToFile(root, codecs, filename?, filter?)` 与 `importFromFile(root, codecs, filter?)` 提供浏览器文件入口。
|
|
33
|
+
取消选择文件或等待读取期间 Root 卸载时返回 `false`;未激活的 Root 仍可恢复。
|
|
34
|
+
`parseFileData()` 只执行 JSON parse,错误原样传播;`restoreScene()` 在版本不是 `2.1` 时先转换旧字段,
|
|
35
|
+
再使用同一 codec 恢复。输入文件数据按引用移交,转换会原位更新字段和版本;再次保存得到 `2.1`。
|
|
36
|
+
具体转换范围见上述格式规范;History 的清理由应用组合层决定。
|
|
30
37
|
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
`vectorPath` 的内建 v2 codec 创建 UI `EditorVectorPath`,恢复后可继续选择、Point 编辑与缩放。
|
|
39
|
+
`polygon` 创建 UI `Polygon`;两者的 `path` 都保存 Core `VectorPathGeometry`,按原局部 ID 恢复。
|
|
33
40
|
|
|
34
41
|
## Sketch
|
|
35
42
|
|
|
36
|
-
`importSketch(file)`
|
|
37
|
-
`importSketchFile(root,
|
|
38
|
-
|
|
43
|
+
`importSketch(file)` 返回 `{ fileData, images, warnings }`;
|
|
44
|
+
`importSketchFile(root, codecs, filter?)` 选择文件并恢复。Adapter 一次生成 canonical v2 geometry,
|
|
45
|
+
保留 compound Bézier/winding、two-point curve、mask chain 与 warnings;不需要另一套 Fulate reader。
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Element, type ElementPayload } from "@fulate/core";
|
|
2
|
+
import { type LineGeometry, type LineEndpointRelationPatch } from "@fulate/ui";
|
|
3
|
+
/** Persisted data contains canonical authored values, never creation intents. */
|
|
4
|
+
export interface ElementV2 extends ElementPayload {
|
|
5
|
+
children?: ElementV2[];
|
|
6
|
+
}
|
|
7
|
+
export interface LineV2 extends ElementPayload {
|
|
8
|
+
readonly type: "line";
|
|
9
|
+
geometry: LineGeometry;
|
|
10
|
+
/** Horizontal label fixed at half the effective route length. */
|
|
11
|
+
text?: string;
|
|
12
|
+
relations?: LineEndpointRelationPatch;
|
|
13
|
+
}
|
|
14
|
+
export interface EncodeContext {
|
|
15
|
+
/** Present for copying a subgraph: external relations become free endpoints. */
|
|
16
|
+
readonly sourceKeys: ReadonlySet<string>;
|
|
17
|
+
}
|
|
18
|
+
export interface ElementV2Codec {
|
|
19
|
+
encode(element: Element, context?: EncodeContext): ElementPayload;
|
|
20
|
+
decode(data: ElementPayload, keyMap?: ReadonlyMap<string, string>): Element;
|
|
21
|
+
}
|
|
22
|
+
export type ElementV2Codecs = ReadonlyMap<string, ElementV2Codec>;
|
|
23
|
+
/** Compose extensions with this map at the application boundary; keys are exact DTO types. */
|
|
24
|
+
export declare const elementV2Codecs: ElementV2Codecs;
|
|
25
|
+
/** The sole owner of persistent child recursion. */
|
|
26
|
+
export declare function encodeElement(element: Element, codecs: ElementV2Codecs, context?: EncodeContext): ElementV2;
|
|
27
|
+
export declare function decodeElement(data: ElementV2, codecs: ElementV2Codecs, keyMap?: ReadonlyMap<string, string>): Element;
|
|
28
|
+
/** Adopt a copied DTO graph, generate new element keys, and preserve owner-local IDs. */
|
|
29
|
+
export declare function decodeCopiedElements(data: readonly ElementV2[], codecs: ElementV2Codecs): {
|
|
30
|
+
elements: Element<import("@fulate/core").ElementProperties, import("@fulate/core").BaseElementOption<any>, Partial<Omit<import("@fulate/core").BaseElementOption<any>, "children" | "key">>, Partial<Omit<import("@fulate/core").BaseElementOption<any>, "children" | "key">>>[];
|
|
31
|
+
keyMap: Map<string, string>;
|
|
32
|
+
};
|
package/dist/fulate/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type
|
|
1
|
+
import type { Root, SkinOptions } from "@fulate/core";
|
|
2
|
+
import { type ElementFilter } from "../util";
|
|
3
|
+
import { type ElementV2, type ElementV2Codecs } from "./codec";
|
|
4
|
+
export * from "./codec";
|
|
3
5
|
export type { ElementFilter };
|
|
4
|
-
export
|
|
5
|
-
export type DeserializeFactories = ReadonlyMap<string, DeserializeFactory> | Readonly<Record<string, DeserializeFactory>>;
|
|
6
|
+
export declare const FULATE_FILE_VERSION = 2.1;
|
|
6
7
|
export interface FileData {
|
|
7
|
-
[key: string]: any;
|
|
8
8
|
__fulate_file__: true;
|
|
9
|
-
|
|
9
|
+
/** Read versions at the file boundary; all current writers emit FULATE_FILE_VERSION. */
|
|
10
|
+
version: number;
|
|
10
11
|
root?: {
|
|
11
12
|
viewport?: {
|
|
12
13
|
x?: number;
|
|
@@ -19,12 +20,11 @@ export interface FileData {
|
|
|
19
20
|
width?: number;
|
|
20
21
|
height?: number;
|
|
21
22
|
};
|
|
22
|
-
children:
|
|
23
|
+
children: ElementV2[];
|
|
23
24
|
}
|
|
24
|
-
export declare function serializeScene(root: Root, filter?: ElementFilter): FileData;
|
|
25
|
-
export declare function serializeSceneToJSON(root: Root, filter?: ElementFilter): string;
|
|
26
|
-
export declare function
|
|
27
|
-
export declare function restoreScene(root: Root, fileData: FileData, filter?: ElementFilter, factories?: DeserializeFactories): void;
|
|
25
|
+
export declare function serializeScene(root: Root, codecs: ElementV2Codecs, filter?: ElementFilter): FileData;
|
|
26
|
+
export declare function serializeSceneToJSON(root: Root, codecs: ElementV2Codecs, filter?: ElementFilter): string;
|
|
27
|
+
export declare function restoreScene(root: Root, data: FileData, codecs: ElementV2Codecs, filter?: ElementFilter): void;
|
|
28
28
|
export declare function parseFileData(json: string): FileData;
|
|
29
|
-
export declare function exportToFile(root: Root, filename?: string, filter?: ElementFilter): void;
|
|
30
|
-
export declare function importFromFile(root: Root,
|
|
29
|
+
export declare function exportToFile(root: Root, codecs: ElementV2Codecs, filename?: string, filter?: ElementFilter): void;
|
|
30
|
+
export declare function importFromFile(root: Root, codecs: ElementV2Codecs, filter?: ElementFilter): Promise<boolean>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export type { ImportResult, Importer } from "./types";
|
|
2
2
|
export { importSketch, importSketchFile, SketchImporter } from "./sketch";
|
|
3
|
-
export
|
|
4
|
-
export type {
|
|
5
|
-
export type { ElementFilter, DeserializeFn, RestoreOptions } from "./util";
|
|
3
|
+
export * from "./fulate";
|
|
4
|
+
export type { RestoreOptions } from "./util";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Element, Layer, Shape } from "@fulate/core";
|
|
2
|
-
import { Circle, Group, Image, Line, LineTree, Polygon, Rectangle, RippleOverlay, ScrollView, Text, Triangle,
|
|
1
|
+
import { Element, Layer, Shape, createAuthoredLineSubpath, createVectorPathGeometry, generateNodeKey } from "@fulate/core";
|
|
2
|
+
import { Circle, EditorVectorPath, Group, Image, Line, LineTree, Polygon, Rectangle, RippleOverlay, ScrollView, Text, Triangle, Workspace, createManualLineGeometry, materializeEffectiveEndpointPoints, remapLineTreeRelations } from "@fulate/ui";
|
|
3
3
|
import { loadAsync } from "jszip";
|
|
4
|
-
import {
|
|
4
|
+
import { isNil, isUndefined } from "lodash-es";
|
|
5
5
|
//#region packages/import/src/sketch/parser.ts
|
|
6
6
|
async function parseSketchFile(data) {
|
|
7
7
|
const zip = await loadAsync(data instanceof File ? await data.arrayBuffer() : data);
|
|
@@ -38,6 +38,361 @@ async function readJSON(zip, path) {
|
|
|
38
38
|
return JSON.parse(text);
|
|
39
39
|
}
|
|
40
40
|
//#endregion
|
|
41
|
+
//#region packages/import/src/fulate/codec.ts
|
|
42
|
+
function codec(Constructor) {
|
|
43
|
+
return {
|
|
44
|
+
encode: (element) => element.toJSON(),
|
|
45
|
+
decode: ({ type, ...properties }) => new Constructor(properties)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function encodeLine(element, context) {
|
|
49
|
+
const line = element;
|
|
50
|
+
const data = line.toJSON();
|
|
51
|
+
if (!context || !line.headRelation && !line.tailRelation) return data;
|
|
52
|
+
const vertices = line.getEffectiveLineVerticesView();
|
|
53
|
+
let headPoint, tailPoint;
|
|
54
|
+
const relations = { ...data.relations };
|
|
55
|
+
for (const end of ["head", "tail"]) {
|
|
56
|
+
const relation = line[end === "head" ? "headRelation" : "tailRelation"];
|
|
57
|
+
if (!relation || context.sourceKeys.has(relation.target.elementKey)) continue;
|
|
58
|
+
const point = end === "head" ? vertices[0].point : vertices[vertices.length - 1].point;
|
|
59
|
+
const copied = {
|
|
60
|
+
x: point.x,
|
|
61
|
+
y: point.y
|
|
62
|
+
};
|
|
63
|
+
if (end === "head") headPoint = copied;
|
|
64
|
+
else tailPoint = copied;
|
|
65
|
+
delete relations[end];
|
|
66
|
+
}
|
|
67
|
+
const geometry = materializeEffectiveEndpointPoints(data.geometry, headPoint, tailPoint);
|
|
68
|
+
if (geometry !== data.geometry) Object.assign(data, line.resolvePointGeometryPatch(geometry));
|
|
69
|
+
if (relations.head || relations.tail) data.relations = relations;
|
|
70
|
+
else delete data.relations;
|
|
71
|
+
return data;
|
|
72
|
+
}
|
|
73
|
+
var lineCodec = {
|
|
74
|
+
encode: encodeLine,
|
|
75
|
+
decode(data, keyMap) {
|
|
76
|
+
const { type, ...properties } = data;
|
|
77
|
+
if (keyMap && properties.relations) {
|
|
78
|
+
const remap = (relation) => relation && {
|
|
79
|
+
...relation,
|
|
80
|
+
target: {
|
|
81
|
+
...relation.target,
|
|
82
|
+
elementKey: keyMap.get(relation.target.elementKey)
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
properties.relations = {
|
|
86
|
+
head: remap(properties.relations.head),
|
|
87
|
+
tail: remap(properties.relations.tail)
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return new Line(properties);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
/** Compose extensions with this map at the application boundary; keys are exact DTO types. */
|
|
94
|
+
var elementV2Codecs = new Map([
|
|
95
|
+
["element", codec(Element)],
|
|
96
|
+
["shape", codec(Shape)],
|
|
97
|
+
["layer", codec(Layer)],
|
|
98
|
+
["rectangle", codec(Rectangle)],
|
|
99
|
+
["circle", codec(Circle)],
|
|
100
|
+
["triangle", codec(Triangle)],
|
|
101
|
+
["polygon", codec(Polygon)],
|
|
102
|
+
["vectorPath", codec(EditorVectorPath)],
|
|
103
|
+
["text", codec(Text)],
|
|
104
|
+
["image", codec(Image)],
|
|
105
|
+
["workspace", codec(Workspace)],
|
|
106
|
+
["group", codec(Group)],
|
|
107
|
+
["scrollview", codec(ScrollView)],
|
|
108
|
+
["line", lineCodec],
|
|
109
|
+
["lineTree", {
|
|
110
|
+
encode(element, context) {
|
|
111
|
+
const tree = element;
|
|
112
|
+
const data = tree.toJSON();
|
|
113
|
+
if (context) {
|
|
114
|
+
const topology = data.topology;
|
|
115
|
+
let changed = false;
|
|
116
|
+
const points = topology.points.map((point) => {
|
|
117
|
+
if (!point.relation || context.sourceKeys.has(point.relation.target.elementKey)) return point;
|
|
118
|
+
changed = true;
|
|
119
|
+
const { relation, ...anchor } = point;
|
|
120
|
+
const effective = tree.transform.getResolvedPoint(point.anchorId).point;
|
|
121
|
+
return {
|
|
122
|
+
...anchor,
|
|
123
|
+
point: {
|
|
124
|
+
x: effective.x,
|
|
125
|
+
y: effective.y
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
if (changed) Object.assign(data, tree.resolvePointTopologyPatch({
|
|
130
|
+
...topology,
|
|
131
|
+
points
|
|
132
|
+
}));
|
|
133
|
+
}
|
|
134
|
+
return data;
|
|
135
|
+
},
|
|
136
|
+
decode({ type, ...properties }, keyMap) {
|
|
137
|
+
if (keyMap) properties.topology = remapLineTreeRelations(properties.topology, keyMap);
|
|
138
|
+
return new LineTree(properties);
|
|
139
|
+
}
|
|
140
|
+
}],
|
|
141
|
+
["ripple", codec(RippleOverlay)]
|
|
142
|
+
]);
|
|
143
|
+
/** The sole owner of persistent child recursion. */
|
|
144
|
+
function encodeElement(element, codecs, context) {
|
|
145
|
+
const data = codecs.get(element.type).encode(element, context);
|
|
146
|
+
const children = element.getPersistentChildren();
|
|
147
|
+
if (children.length) data.children = children.map((child) => encodeElement(child, codecs, context));
|
|
148
|
+
return data;
|
|
149
|
+
}
|
|
150
|
+
function decodeElement(data, codecs, keyMap) {
|
|
151
|
+
const { children, ...payload } = data;
|
|
152
|
+
if (keyMap) payload.key = keyMap.get(data.key);
|
|
153
|
+
const element = codecs.get(payload.type).decode(payload, keyMap);
|
|
154
|
+
if (children) element.replaceChildren(...children.map((child) => decodeElement(child, codecs, keyMap)));
|
|
155
|
+
return element;
|
|
156
|
+
}
|
|
157
|
+
/** Adopt a copied DTO graph, generate new element keys, and preserve owner-local IDs. */
|
|
158
|
+
function decodeCopiedElements(data, codecs) {
|
|
159
|
+
const keyMap = /* @__PURE__ */ new Map();
|
|
160
|
+
const allocate = (entry) => {
|
|
161
|
+
keyMap.set(entry.key, generateNodeKey());
|
|
162
|
+
entry.children?.forEach(allocate);
|
|
163
|
+
};
|
|
164
|
+
data.forEach(allocate);
|
|
165
|
+
return {
|
|
166
|
+
elements: data.map((entry) => decodeElement(entry, codecs, keyMap)),
|
|
167
|
+
keyMap
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region packages/import/src/util/index.ts
|
|
172
|
+
function defaultAppend(els, root) {
|
|
173
|
+
root.append(...els);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* 通用场景恢复模板:
|
|
177
|
+
* 1. 应用 root 配置(resize、viewport、Skin)
|
|
178
|
+
* 2. reset viewport
|
|
179
|
+
* 3. 移除旧元素(由 filter 决定)
|
|
180
|
+
* 4. 反序列化并添加 children(由 append 决定)
|
|
181
|
+
* 5. requestRender
|
|
182
|
+
*/
|
|
183
|
+
function restoreScene$1(options) {
|
|
184
|
+
const { root, fileData, codecs, append, filter } = options;
|
|
185
|
+
const toRemove = filter ? root.children.filter((child) => filter(child)) : [];
|
|
186
|
+
if (fileData.root) {
|
|
187
|
+
const { viewport, skin, width, height } = fileData.root;
|
|
188
|
+
if (skin) {
|
|
189
|
+
const { text, ...paint } = skin;
|
|
190
|
+
Object.assign(root.skin, paint);
|
|
191
|
+
if (text) Object.assign(root.skin.text, text);
|
|
192
|
+
}
|
|
193
|
+
if (!isNil(width) && !isNil(height)) root.resize(width, height);
|
|
194
|
+
if (viewport) root.viewport.restore({
|
|
195
|
+
x: viewport.x ?? 0,
|
|
196
|
+
y: viewport.y ?? 0,
|
|
197
|
+
scale: viewport.scale ?? 1
|
|
198
|
+
});
|
|
199
|
+
else root.viewport.reset();
|
|
200
|
+
} else root.viewport.reset();
|
|
201
|
+
if (toRemove.length) root.removeChild(...toRemove);
|
|
202
|
+
const els = fileData.children.map((data) => decodeElement(data, codecs));
|
|
203
|
+
if (els.length) (append ?? defaultAppend)(els, root);
|
|
204
|
+
root.invalidateAll();
|
|
205
|
+
}
|
|
206
|
+
function pickFile(accept) {
|
|
207
|
+
return new Promise((resolve) => {
|
|
208
|
+
const input = document.createElement("input");
|
|
209
|
+
input.type = "file";
|
|
210
|
+
input.accept = accept;
|
|
211
|
+
input.onchange = () => resolve(input.files?.[0] ?? null);
|
|
212
|
+
input.oncancel = () => resolve(null);
|
|
213
|
+
input.click();
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
function arrayBufferToDataURL(buf, mime) {
|
|
217
|
+
const bytes = new Uint8Array(buf);
|
|
218
|
+
let binary = "";
|
|
219
|
+
for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
|
|
220
|
+
return `data:${mime};base64,${btoa(binary)}`;
|
|
221
|
+
}
|
|
222
|
+
function guessMimeType(path) {
|
|
223
|
+
switch (path.split(".").pop()?.toLowerCase()) {
|
|
224
|
+
case "jpg":
|
|
225
|
+
case "jpeg": return "image/jpeg";
|
|
226
|
+
case "png": return "image/png";
|
|
227
|
+
case "gif": return "image/gif";
|
|
228
|
+
case "webp": return "image/webp";
|
|
229
|
+
case "svg": return "image/svg+xml";
|
|
230
|
+
default: return "image/png";
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region packages/import/src/fulate/upgrade.ts
|
|
235
|
+
/** Consume the previous file payload before the current codecs create scene owners. */
|
|
236
|
+
function upgradeFileData(data) {
|
|
237
|
+
const elements = /* @__PURE__ */ new Map();
|
|
238
|
+
const previousPortTargets = /* @__PURE__ */ new Set();
|
|
239
|
+
const relation = (target) => {
|
|
240
|
+
previousPortTargets.add(target.elementKey);
|
|
241
|
+
return {
|
|
242
|
+
kind: "endpoint-binding",
|
|
243
|
+
target: {
|
|
244
|
+
elementKey: target.elementKey,
|
|
245
|
+
portId: target.anchorType
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
const relations = (head, tail) => ({
|
|
250
|
+
...head ? { head: relation(head) } : {},
|
|
251
|
+
...tail ? { tail: relation(tail) } : {}
|
|
252
|
+
});
|
|
253
|
+
const visit = (element) => {
|
|
254
|
+
elements.set(element.key, element);
|
|
255
|
+
if (element.anchors !== void 0) {
|
|
256
|
+
const totals = /* @__PURE__ */ new Map();
|
|
257
|
+
const positions = /* @__PURE__ */ new Map();
|
|
258
|
+
for (const { edge } of element.anchors) totals.set(edge, (totals.get(edge) ?? 0) + 1);
|
|
259
|
+
element.ports = element.anchors.length === 0 ? true : element.anchors.map(({ edge, ...port }) => {
|
|
260
|
+
const index = (positions.get(edge) ?? 0) + 1;
|
|
261
|
+
positions.set(edge, index);
|
|
262
|
+
return {
|
|
263
|
+
...port,
|
|
264
|
+
position: {
|
|
265
|
+
edge,
|
|
266
|
+
ratio: index / (totals.get(edge) + 1)
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
});
|
|
270
|
+
delete element.anchors;
|
|
271
|
+
}
|
|
272
|
+
switch (element.type) {
|
|
273
|
+
case "line":
|
|
274
|
+
if (element.linePoints !== void 0) {
|
|
275
|
+
const points = element.linePoints;
|
|
276
|
+
element.geometry = {
|
|
277
|
+
mode: "manual",
|
|
278
|
+
path: createAuthoredLineSubpath(points.map(({ x, y }) => ({
|
|
279
|
+
x,
|
|
280
|
+
y
|
|
281
|
+
})), false)
|
|
282
|
+
};
|
|
283
|
+
const head = points[0]?.anchor;
|
|
284
|
+
const tail = points.length > 1 ? points[points.length - 1].anchor : void 0;
|
|
285
|
+
if (head || tail) element.relations = relations(head, tail);
|
|
286
|
+
delete element.linePoints;
|
|
287
|
+
} else if (element.path !== void 0) {
|
|
288
|
+
element.geometry = {
|
|
289
|
+
mode: "manual",
|
|
290
|
+
path: element.path
|
|
291
|
+
};
|
|
292
|
+
delete element.path;
|
|
293
|
+
}
|
|
294
|
+
if (element.endpoints !== void 0) {
|
|
295
|
+
element.relations = relations(element.endpoints.head, element.endpoints.tail);
|
|
296
|
+
delete element.endpoints;
|
|
297
|
+
}
|
|
298
|
+
if (data.version === 1) {
|
|
299
|
+
element.tailDecoration ??= "arrow";
|
|
300
|
+
element.strokeColor ??= "#333333";
|
|
301
|
+
}
|
|
302
|
+
break;
|
|
303
|
+
case "polygon":
|
|
304
|
+
if (element.contour !== void 0) {
|
|
305
|
+
element.path = { subpaths: [element.contour] };
|
|
306
|
+
delete element.contour;
|
|
307
|
+
} else if (element.points !== void 0) {
|
|
308
|
+
element.path = { subpaths: [createAuthoredLineSubpath(element.points, true)] };
|
|
309
|
+
delete element.points;
|
|
310
|
+
}
|
|
311
|
+
break;
|
|
312
|
+
case "vectorPath":
|
|
313
|
+
if (element.commands !== void 0) {
|
|
314
|
+
element.path = createVectorPathGeometry(element.commands);
|
|
315
|
+
delete element.commands;
|
|
316
|
+
}
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
element.children?.forEach(visit);
|
|
320
|
+
};
|
|
321
|
+
data.children.forEach(visit);
|
|
322
|
+
for (const key of previousPortTargets) {
|
|
323
|
+
const target = elements.get(key);
|
|
324
|
+
if (target && target.ports === void 0) target.ports = true;
|
|
325
|
+
}
|
|
326
|
+
const root = data.root;
|
|
327
|
+
if (root?.textDefaults !== void 0) {
|
|
328
|
+
root.skin = {
|
|
329
|
+
...root.skin,
|
|
330
|
+
text: root.textDefaults
|
|
331
|
+
};
|
|
332
|
+
delete root.textDefaults;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
//#endregion
|
|
336
|
+
//#region packages/import/src/fulate/index.ts
|
|
337
|
+
var FULATE_FILE_VERSION = 2.1;
|
|
338
|
+
function serializeScene(root, codecs, filter) {
|
|
339
|
+
return {
|
|
340
|
+
__fulate_file__: true,
|
|
341
|
+
version: FULATE_FILE_VERSION,
|
|
342
|
+
root: root.toJSON(),
|
|
343
|
+
children: root.children.filter((child) => !filter || filter(child)).map((child) => encodeElement(child, codecs))
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
function serializeSceneToJSON(root, codecs, filter) {
|
|
347
|
+
return JSON.stringify(serializeScene(root, codecs, filter));
|
|
348
|
+
}
|
|
349
|
+
function restoreScene(root, data, codecs, filter) {
|
|
350
|
+
if (data.version !== 2.1) {
|
|
351
|
+
upgradeFileData(data);
|
|
352
|
+
data.version = FULATE_FILE_VERSION;
|
|
353
|
+
}
|
|
354
|
+
restoreScene$1({
|
|
355
|
+
root,
|
|
356
|
+
fileData: data,
|
|
357
|
+
codecs,
|
|
358
|
+
filter
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
function parseFileData(json) {
|
|
362
|
+
return JSON.parse(json);
|
|
363
|
+
}
|
|
364
|
+
function exportToFile(root, codecs, filename = "fulate-design.json", filter) {
|
|
365
|
+
const blob = new Blob([serializeSceneToJSON(root, codecs, filter)], { type: "application/json" });
|
|
366
|
+
const url = URL.createObjectURL(blob);
|
|
367
|
+
const anchor = document.createElement("a");
|
|
368
|
+
anchor.href = url;
|
|
369
|
+
anchor.download = filename;
|
|
370
|
+
anchor.click();
|
|
371
|
+
URL.revokeObjectURL(url);
|
|
372
|
+
}
|
|
373
|
+
async function importFromFile(root, codecs, filter) {
|
|
374
|
+
const file = await pickFile(".json");
|
|
375
|
+
if (!file) return false;
|
|
376
|
+
const data = parseFileData(await file.text());
|
|
377
|
+
if (root.isUnmounted) return false;
|
|
378
|
+
restoreScene(root, data, codecs, filter);
|
|
379
|
+
return true;
|
|
380
|
+
}
|
|
381
|
+
//#endregion
|
|
382
|
+
//#region packages/import/src/sketch/image.ts
|
|
383
|
+
/**
|
|
384
|
+
* Extract the image ref path from a bitmap layer and resolve it
|
|
385
|
+
* to a data URL using the images extracted from the zip.
|
|
386
|
+
*/
|
|
387
|
+
function resolveImageSrc(layer, images) {
|
|
388
|
+
const ref = layer.image;
|
|
389
|
+
if (!ref) return void 0;
|
|
390
|
+
const refPath = ref._ref;
|
|
391
|
+
const buf = images.get(refPath);
|
|
392
|
+
if (!buf) return void 0;
|
|
393
|
+
return arrayBufferToDataURL(buf, guessMimeType(refPath));
|
|
394
|
+
}
|
|
395
|
+
//#endregion
|
|
41
396
|
//#region packages/import/src/sketch/style.ts
|
|
42
397
|
function sketchColorToCSS(c) {
|
|
43
398
|
const r = Math.round(c.red * 255);
|
|
@@ -190,83 +545,6 @@ function isItalicFont(name) {
|
|
|
190
545
|
return /italic|oblique/i.test(name);
|
|
191
546
|
}
|
|
192
547
|
//#endregion
|
|
193
|
-
//#region packages/import/src/util/index.ts
|
|
194
|
-
function defaultAppend(els, root) {
|
|
195
|
-
root.append(...els);
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* 通用场景恢复模板:
|
|
199
|
-
* 1. 应用 root 配置(resize、viewport、Skin)
|
|
200
|
-
* 2. reset viewport
|
|
201
|
-
* 3. 移除旧元素(由 filter 决定)
|
|
202
|
-
* 4. 反序列化并添加 children(由 append 决定)
|
|
203
|
-
* 5. requestRender
|
|
204
|
-
*/
|
|
205
|
-
function restoreScene$1(options) {
|
|
206
|
-
const { root, fileData, deserialize, append, filter } = options;
|
|
207
|
-
const toRemove = filter ? root.children.filter((child) => filter(child)) : [];
|
|
208
|
-
if (fileData.root) {
|
|
209
|
-
const { viewport, skin, width, height } = fileData.root;
|
|
210
|
-
if (skin) {
|
|
211
|
-
const { text, ...paint } = skin;
|
|
212
|
-
Object.assign(root.skin, paint);
|
|
213
|
-
if (text) Object.assign(root.skin.text, text);
|
|
214
|
-
}
|
|
215
|
-
if (!isNil(width) && !isNil(height)) root.resize(width, height);
|
|
216
|
-
if (viewport) root.viewport.restore({
|
|
217
|
-
x: viewport.x ?? 0,
|
|
218
|
-
y: viewport.y ?? 0,
|
|
219
|
-
scale: viewport.scale ?? 1
|
|
220
|
-
});
|
|
221
|
-
else root.viewport.reset();
|
|
222
|
-
} else root.viewport.reset();
|
|
223
|
-
if (toRemove.length) root.removeChild(...toRemove);
|
|
224
|
-
const els = fileData.children.map((data) => deserialize(data));
|
|
225
|
-
if (els.length) (append ?? defaultAppend)(els, root);
|
|
226
|
-
root.invalidateAll();
|
|
227
|
-
}
|
|
228
|
-
function pickFile(accept) {
|
|
229
|
-
return new Promise((resolve) => {
|
|
230
|
-
const input = document.createElement("input");
|
|
231
|
-
input.type = "file";
|
|
232
|
-
input.accept = accept;
|
|
233
|
-
input.onchange = () => resolve(input.files?.[0] ?? null);
|
|
234
|
-
input.oncancel = () => resolve(null);
|
|
235
|
-
input.click();
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
function arrayBufferToDataURL(buf, mime) {
|
|
239
|
-
const bytes = new Uint8Array(buf);
|
|
240
|
-
let binary = "";
|
|
241
|
-
for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
|
|
242
|
-
return `data:${mime};base64,${btoa(binary)}`;
|
|
243
|
-
}
|
|
244
|
-
function guessMimeType(path) {
|
|
245
|
-
switch (path.split(".").pop()?.toLowerCase()) {
|
|
246
|
-
case "jpg":
|
|
247
|
-
case "jpeg": return "image/jpeg";
|
|
248
|
-
case "png": return "image/png";
|
|
249
|
-
case "gif": return "image/gif";
|
|
250
|
-
case "webp": return "image/webp";
|
|
251
|
-
case "svg": return "image/svg+xml";
|
|
252
|
-
default: return "image/png";
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
//#endregion
|
|
256
|
-
//#region packages/import/src/sketch/image.ts
|
|
257
|
-
/**
|
|
258
|
-
* Extract the image ref path from a bitmap layer and resolve it
|
|
259
|
-
* to a data URL using the images extracted from the zip.
|
|
260
|
-
*/
|
|
261
|
-
function resolveImageSrc(layer, images) {
|
|
262
|
-
const ref = layer.image;
|
|
263
|
-
if (!ref) return void 0;
|
|
264
|
-
const refPath = ref._ref;
|
|
265
|
-
const buf = images.get(refPath);
|
|
266
|
-
if (!buf) return void 0;
|
|
267
|
-
return arrayBufferToDataURL(buf, guessMimeType(refPath));
|
|
268
|
-
}
|
|
269
|
-
//#endregion
|
|
270
548
|
//#region packages/import/src/sketch/converter.ts
|
|
271
549
|
function convertSketchToFileData(sketch) {
|
|
272
550
|
const warnings = [];
|
|
@@ -288,7 +566,7 @@ function convertSketchToFileData(sketch) {
|
|
|
288
566
|
return {
|
|
289
567
|
fileData: {
|
|
290
568
|
__fulate_file__: true,
|
|
291
|
-
version:
|
|
569
|
+
version: FULATE_FILE_VERSION,
|
|
292
570
|
children
|
|
293
571
|
},
|
|
294
572
|
images: imageDataURLs,
|
|
@@ -408,7 +686,7 @@ function flattenLayer(layer, ctx) {
|
|
|
408
686
|
assignLinePath(base, layer);
|
|
409
687
|
break;
|
|
410
688
|
case "polygon":
|
|
411
|
-
|
|
689
|
+
assignPolygonPath(base, layer);
|
|
412
690
|
break;
|
|
413
691
|
case "vectorPath":
|
|
414
692
|
assignVectorPath(base, layer);
|
|
@@ -430,6 +708,7 @@ function buildBase(layer, type, ctx) {
|
|
|
430
708
|
if (ctx.flipV) top = ctx.offsetY + (ctx.groupH - layer.frame.y - layer.frame.height);
|
|
431
709
|
const base = {
|
|
432
710
|
type,
|
|
711
|
+
key: generateNodeKey(),
|
|
433
712
|
left,
|
|
434
713
|
top,
|
|
435
714
|
width: layer.frame.width,
|
|
@@ -513,13 +792,13 @@ function convertShapeGroup(layer, ctx) {
|
|
|
513
792
|
return null;
|
|
514
793
|
}
|
|
515
794
|
const base = buildBase(layer, "vectorPath", ctx);
|
|
516
|
-
base.path = paths.flatMap((path) => createVectorPathCommands(path, (point) => parseShapeGroupPoint(point, path)));
|
|
795
|
+
base.path = createVectorPathGeometry(paths.flatMap((path) => createVectorPathCommands(path, (point) => parseShapeGroupPoint(point, path))));
|
|
517
796
|
applyInheritedFlips(base, ctx);
|
|
518
797
|
return base;
|
|
519
798
|
}
|
|
520
799
|
function assignVectorPath(base, layer) {
|
|
521
800
|
const { width, height } = layer.frame;
|
|
522
|
-
base.path = createVectorPathCommands(layer, (point) => parseSketchPoint(point, width, height));
|
|
801
|
+
base.path = createVectorPathGeometry(createVectorPathCommands(layer, (point) => parseSketchPoint(point, width, height)));
|
|
523
802
|
}
|
|
524
803
|
function createVectorPathCommands(layer, resolvePoint) {
|
|
525
804
|
const points = layer.points;
|
|
@@ -569,11 +848,11 @@ function parseShapeGroupPoint(point, path) {
|
|
|
569
848
|
y: top + y
|
|
570
849
|
};
|
|
571
850
|
}
|
|
572
|
-
function
|
|
851
|
+
function assignPolygonPath(base, layer) {
|
|
573
852
|
const points = layer.points;
|
|
574
853
|
if (!points?.length) return;
|
|
575
854
|
const { width, height } = layer.frame;
|
|
576
|
-
base.
|
|
855
|
+
base.path = { subpaths: [createAuthoredLineSubpath(points.map((p) => parseSketchPoint(p.point, width, height)), true)] };
|
|
577
856
|
}
|
|
578
857
|
function assignLinePath(base, layer) {
|
|
579
858
|
const points = layer.points;
|
|
@@ -595,10 +874,10 @@ function assignLinePath(base, layer) {
|
|
|
595
874
|
const origin = parsed[0];
|
|
596
875
|
base.left += origin.x;
|
|
597
876
|
base.top += origin.y;
|
|
598
|
-
base.
|
|
877
|
+
base.geometry = createManualLineGeometry(parsed.map((p) => ({
|
|
599
878
|
x: p.x - origin.x,
|
|
600
879
|
y: p.y - origin.y
|
|
601
|
-
}));
|
|
880
|
+
})));
|
|
602
881
|
delete base.width;
|
|
603
882
|
delete base.height;
|
|
604
883
|
if (base.borderColor) {
|
|
@@ -613,10 +892,8 @@ function assignLinePath(base, layer) {
|
|
|
613
892
|
}
|
|
614
893
|
function parseSketchPoint(str, frameW, frameH) {
|
|
615
894
|
const match = str.match(/\{([^,]+),\s*([^}]+)\}/);
|
|
616
|
-
if (!match) throw new Error(`Invalid Sketch point: ${str}`);
|
|
617
895
|
const x = parseFloat(match[1]);
|
|
618
896
|
const y = parseFloat(match[2]);
|
|
619
|
-
if (!Number.isFinite(x) || !Number.isFinite(y)) throw new Error(`Invalid Sketch point: ${str}`);
|
|
620
897
|
return {
|
|
621
898
|
x: x * frameW,
|
|
622
899
|
y: y * frameH
|
|
@@ -640,7 +917,7 @@ var SketchImporter = class {
|
|
|
640
917
|
async function importSketch(file) {
|
|
641
918
|
return convertSketchToFileData(await parseSketchFile(file));
|
|
642
919
|
}
|
|
643
|
-
async function importSketchFile(root,
|
|
920
|
+
async function importSketchFile(root, codecs, filter) {
|
|
644
921
|
const file = await pickFile(".sketch");
|
|
645
922
|
if (!file) return false;
|
|
646
923
|
const result = await importSketch(file);
|
|
@@ -649,12 +926,11 @@ async function importSketchFile(root, deserialize, filter) {
|
|
|
649
926
|
restoreScene$1({
|
|
650
927
|
root,
|
|
651
928
|
fileData: result.fileData,
|
|
652
|
-
|
|
929
|
+
codecs,
|
|
653
930
|
filter,
|
|
654
931
|
append: (els, root) => {
|
|
655
932
|
const layer = new Layer();
|
|
656
933
|
const workspace = new Workspace({
|
|
657
|
-
key: "workspace",
|
|
658
934
|
width: 1920,
|
|
659
935
|
height: 1080
|
|
660
936
|
});
|
|
@@ -665,80 +941,4 @@ async function importSketchFile(root, deserialize, filter) {
|
|
|
665
941
|
return true;
|
|
666
942
|
}
|
|
667
943
|
//#endregion
|
|
668
|
-
|
|
669
|
-
var FILE_MARKER = "__fulate_file__";
|
|
670
|
-
var FILE_VERSION = 2;
|
|
671
|
-
var builtInFactories = Object.fromEntries(Object.entries({
|
|
672
|
-
element: Element,
|
|
673
|
-
shape: Shape,
|
|
674
|
-
layer: Layer,
|
|
675
|
-
rectangle: Rectangle,
|
|
676
|
-
circle: Circle,
|
|
677
|
-
triangle: Triangle,
|
|
678
|
-
polygon: Polygon,
|
|
679
|
-
vectorPath: VectorPath,
|
|
680
|
-
text: Text,
|
|
681
|
-
image: Image,
|
|
682
|
-
workspace: Workspace,
|
|
683
|
-
group: Group,
|
|
684
|
-
scrollview: ScrollView,
|
|
685
|
-
line: Line,
|
|
686
|
-
lineTree: LineTree,
|
|
687
|
-
ripple: RippleOverlay
|
|
688
|
-
}).map(([type, Constructor]) => [type, (data) => {
|
|
689
|
-
const { type, children, ...options } = data;
|
|
690
|
-
return new Constructor(options);
|
|
691
|
-
}]));
|
|
692
|
-
function resolveFactory(type, factories) {
|
|
693
|
-
let custom;
|
|
694
|
-
if (factories instanceof Map) custom = factories.get(type);
|
|
695
|
-
else if (factories && has(factories, [type])) custom = factories[type];
|
|
696
|
-
return custom ?? builtInFactories[type];
|
|
697
|
-
}
|
|
698
|
-
function serializeScene(root, filter) {
|
|
699
|
-
return {
|
|
700
|
-
[FILE_MARKER]: true,
|
|
701
|
-
version: FILE_VERSION,
|
|
702
|
-
root: root.toJSON(),
|
|
703
|
-
children: root.children.filter((child) => !filter || filter(child)).map((child) => child.toJSON())
|
|
704
|
-
};
|
|
705
|
-
}
|
|
706
|
-
function serializeSceneToJSON(root, filter) {
|
|
707
|
-
return JSON.stringify(serializeScene(root, filter));
|
|
708
|
-
}
|
|
709
|
-
function deserializeElement(data, factories) {
|
|
710
|
-
const element = resolveFactory(data.type, factories)(data);
|
|
711
|
-
if (data.children) element.replaceChildren(...data.children.map((child) => deserializeElement(child, factories)));
|
|
712
|
-
return element;
|
|
713
|
-
}
|
|
714
|
-
function restoreScene(root, fileData, filter, factories) {
|
|
715
|
-
restoreScene$1({
|
|
716
|
-
root,
|
|
717
|
-
fileData,
|
|
718
|
-
deserialize: (data) => deserializeElement(data, factories),
|
|
719
|
-
filter
|
|
720
|
-
});
|
|
721
|
-
}
|
|
722
|
-
function parseFileData(json) {
|
|
723
|
-
return JSON.parse(json);
|
|
724
|
-
}
|
|
725
|
-
function exportToFile(root, filename = "fulate-design.json", filter) {
|
|
726
|
-
const json = serializeSceneToJSON(root, filter);
|
|
727
|
-
const blob = new Blob([json], { type: "application/json" });
|
|
728
|
-
const url = URL.createObjectURL(blob);
|
|
729
|
-
const anchor = document.createElement("a");
|
|
730
|
-
anchor.href = url;
|
|
731
|
-
anchor.download = filename;
|
|
732
|
-
anchor.click();
|
|
733
|
-
URL.revokeObjectURL(url);
|
|
734
|
-
}
|
|
735
|
-
async function importFromFile(root, filter, factories) {
|
|
736
|
-
const file = await pickFile(".json");
|
|
737
|
-
if (!file) return false;
|
|
738
|
-
const fileData = parseFileData(await file.text());
|
|
739
|
-
if (root.isUnmounted) return false;
|
|
740
|
-
restoreScene(root, fileData, filter, factories);
|
|
741
|
-
return true;
|
|
742
|
-
}
|
|
743
|
-
//#endregion
|
|
744
|
-
export { SketchImporter, deserializeElement, exportToFile, importFromFile, importSketch, importSketchFile, parseFileData, restoreScene, serializeScene, serializeSceneToJSON };
|
|
944
|
+
export { FULATE_FILE_VERSION, SketchImporter, decodeCopiedElements, decodeElement, elementV2Codecs, encodeElement, exportToFile, importFromFile, importSketch, importSketchFile, parseFileData, restoreScene, serializeScene, serializeSceneToJSON };
|
package/dist/sketch/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Root } from "@fulate/core";
|
|
2
2
|
import type { Importer, ImportResult } from "../types";
|
|
3
|
-
import type { ElementFilter
|
|
3
|
+
import type { ElementFilter } from "../util";
|
|
4
|
+
import type { ElementV2Codecs } from "../fulate/codec";
|
|
4
5
|
export declare class SketchImporter implements Importer {
|
|
5
6
|
import(file: File | ArrayBuffer): Promise<ImportResult>;
|
|
6
7
|
}
|
|
7
8
|
export declare function importSketch(file: File | ArrayBuffer): Promise<ImportResult>;
|
|
8
|
-
export declare function importSketchFile(root: Root,
|
|
9
|
+
export declare function importSketchFile(root: Root, codecs: ElementV2Codecs, filter?: ElementFilter): Promise<boolean>;
|
package/dist/util/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Root, Element } from "@fulate/core";
|
|
2
2
|
import type { FileData } from "../fulate";
|
|
3
|
+
import { type ElementV2Codecs } from "../fulate/codec";
|
|
3
4
|
export type ElementFilter = (element: Element) => boolean;
|
|
4
|
-
export type DeserializeFn = (data: any) => Element;
|
|
5
5
|
export interface RestoreOptions {
|
|
6
6
|
root: Root;
|
|
7
7
|
fileData: FileData;
|
|
8
|
-
|
|
8
|
+
codecs: ElementV2Codecs;
|
|
9
9
|
/** 决定把反序列化后的元素添加到哪里、怎么添加 */
|
|
10
10
|
append?: (els: Element[], root: Root) => void;
|
|
11
11
|
/** 决定清除哪些旧元素,不传则不清除 */
|
package/package.json
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@fulate/import",
|
|
3
|
-
"version": "
|
|
4
|
-
"type": "module",
|
|
5
|
-
"main": "./dist/index.js",
|
|
6
|
-
"types": "./dist/index.d.ts",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"types": "./dist/index.d.ts",
|
|
10
|
-
"import": "./dist/index.js"
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
"files": [
|
|
14
|
-
"dist"
|
|
15
|
-
],
|
|
16
|
-
"license": "MIT",
|
|
17
|
-
"scripts": {
|
|
18
|
-
"test": "vitest run --config vitest.config.ts",
|
|
19
|
-
"test:watch": "vitest --config vitest.config.ts"
|
|
20
|
-
},
|
|
21
|
-
"dependencies": {
|
|
22
|
-
"@fulate/share": "
|
|
23
|
-
"@fulate/core": "
|
|
24
|
-
"@fulate/ui": "
|
|
25
|
-
"jszip": "^3.10.1",
|
|
26
|
-
"lodash-es": "^4.17.22"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@fulate/import",
|
|
3
|
+
"version": "2.0.11",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"scripts": {
|
|
18
|
+
"test": "vitest run --config vitest.config.ts",
|
|
19
|
+
"test:watch": "vitest --config vitest.config.ts"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@fulate/share": "2.0.11",
|
|
23
|
+
"@fulate/core": "2.0.11",
|
|
24
|
+
"@fulate/ui": "2.0.11",
|
|
25
|
+
"jszip": "^3.10.1",
|
|
26
|
+
"lodash-es": "^4.17.22"
|
|
27
|
+
}
|
|
28
|
+
}
|