fabricjs-document-engine 1.0.2 → 1.1.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 +181 -10
- package/README.zh-CN.md +181 -10
- package/dist/assets/asset-manifest.d.cts +3 -0
- package/dist/assets/asset-manifest.d.ts +3 -0
- package/dist/assets/asset-pipeline.cjs +22 -10
- package/dist/assets/asset-pipeline.d.cts +5 -1
- package/dist/assets/asset-pipeline.d.ts +5 -1
- package/dist/assets/asset-pipeline.js +22 -10
- package/dist/assets/font-check.cjs +9 -1
- package/dist/assets/font-check.js +9 -1
- package/dist/assets/image-check.cjs +88 -6
- package/dist/assets/image-check.d.cts +17 -0
- package/dist/assets/image-check.d.ts +17 -0
- package/dist/assets/image-check.js +88 -7
- package/dist/commands/clipboard.cjs +136 -0
- package/dist/commands/clipboard.d.cts +47 -0
- package/dist/commands/clipboard.d.ts +47 -0
- package/dist/commands/clipboard.js +135 -0
- package/dist/commands/layers.cjs +97 -0
- package/dist/commands/layers.d.cts +39 -0
- package/dist/commands/layers.d.ts +39 -0
- package/dist/commands/layers.js +92 -0
- package/dist/engine/create-document-engine.cjs +85 -14
- package/dist/engine/create-document-engine.d.cts +20 -1
- package/dist/engine/create-document-engine.d.ts +20 -1
- package/dist/engine/create-document-engine.js +86 -15
- package/dist/engine/errors.d.cts +1 -1
- package/dist/engine/errors.d.ts +1 -1
- package/dist/export/batch-render.cjs +172 -0
- package/dist/export/batch-render.d.cts +43 -0
- package/dist/export/batch-render.d.ts +43 -0
- package/dist/export/batch-render.js +171 -0
- package/dist/export/export-options.cjs +18 -1
- package/dist/export/export-options.d.cts +23 -0
- package/dist/export/export-options.d.ts +23 -0
- package/dist/export/export-options.js +18 -2
- package/dist/export/preflight-export.cjs +11 -2
- package/dist/export/preflight-export.d.cts +1 -1
- package/dist/export/preflight-export.d.ts +1 -1
- package/dist/export/preflight-export.js +11 -2
- package/dist/export/render-export.cjs +18 -3
- package/dist/export/render-export.js +18 -4
- package/dist/export/svg/embed-assets.cjs +249 -0
- package/dist/export/svg/embed-assets.js +249 -0
- package/dist/export/svg/overrides.cjs +32 -0
- package/dist/export/svg/overrides.js +32 -0
- package/dist/export/svg/text-on-path.cjs +252 -0
- package/dist/export/svg/text-on-path.js +249 -0
- package/dist/fabric/fabric-adapter.cjs +46 -5
- package/dist/fabric/fabric-adapter.js +46 -5
- package/dist/fabric/object-registry.cjs +1 -1
- package/dist/fabric/object-registry.js +1 -1
- package/dist/import/svg-import.cjs +256 -0
- package/dist/import/svg-import.d.cts +50 -0
- package/dist/import/svg-import.d.ts +50 -0
- package/dist/import/svg-import.js +256 -0
- package/dist/index.cjs +12 -0
- package/dist/index.d.cts +9 -4
- package/dist/index.d.ts +9 -4
- package/dist/index.js +4 -1
- package/dist/pdf/export-pdf.cjs +440 -0
- package/dist/pdf/export-pdf.d.cts +73 -0
- package/dist/pdf/export-pdf.d.ts +73 -0
- package/dist/pdf/export-pdf.js +440 -0
- package/dist/pdf/fonts.cjs +115 -0
- package/dist/pdf/fonts.d.cts +12 -0
- package/dist/pdf/fonts.d.ts +12 -0
- package/dist/pdf/fonts.js +112 -0
- package/dist/pdf/page-layout.cjs +79 -0
- package/dist/pdf/page-layout.d.cts +51 -0
- package/dist/pdf/page-layout.d.ts +51 -0
- package/dist/pdf/page-layout.js +76 -0
- package/dist/pdf/text-decorations.cjs +108 -0
- package/dist/pdf/text-decorations.js +107 -0
- package/dist/pdf.cjs +7 -0
- package/dist/pdf.d.cts +4 -0
- package/dist/pdf.d.ts +4 -0
- package/dist/pdf.js +3 -0
- package/dist/react/use-layers.cjs +53 -0
- package/dist/react/use-layers.d.cts +10 -0
- package/dist/react/use-layers.d.ts +10 -0
- package/dist/react/use-layers.js +53 -0
- package/dist/react.cjs +2 -0
- package/dist/react.d.cts +3 -1
- package/dist/react.d.ts +3 -1
- package/dist/react.js +2 -1
- package/dist/util/concurrency.cjs +28 -0
- package/dist/util/concurrency.js +27 -0
- package/package.json +30 -3
package/dist/react.js
CHANGED
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
import { useDocumentEngine } from "./react/use-document-engine.js";
|
|
3
3
|
import { useDocumentState } from "./react/use-document-state.js";
|
|
4
4
|
import { useDocumentEvent } from "./react/use-document-event.js";
|
|
5
|
+
import { useLayers } from "./react/use-layers.js";
|
|
5
6
|
import { DocumentEngineProvider, useEngine } from "./react/engine-context.js";
|
|
6
|
-
export { DocumentEngineProvider, useDocumentEngine, useDocumentEvent, useDocumentState, useEngine };
|
|
7
|
+
export { DocumentEngineProvider, useDocumentEngine, useDocumentEvent, useDocumentState, useEngine, useLayers };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/util/concurrency.ts
|
|
2
|
+
/**
|
|
3
|
+
* Runs `work` for every item with at most `limit` running at once, and
|
|
4
|
+
* returns the results in the order of `items`.
|
|
5
|
+
*/
|
|
6
|
+
async function mapWithConcurrency(items, limit, work) {
|
|
7
|
+
const results = new Array(items.length);
|
|
8
|
+
const workers = Math.max(1, Math.min(Math.floor(limit) || 1, items.length));
|
|
9
|
+
let next = 0;
|
|
10
|
+
async function runWorker() {
|
|
11
|
+
while (next < items.length) {
|
|
12
|
+
const index = next;
|
|
13
|
+
next += 1;
|
|
14
|
+
results[index] = await work(items[index], index);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
await Promise.all(Array.from({ length: workers }, runWorker));
|
|
18
|
+
return results;
|
|
19
|
+
}
|
|
20
|
+
/** Lets the browser paint and handle input before the next piece of work. */
|
|
21
|
+
function yieldToEventLoop() {
|
|
22
|
+
const scheduler = globalThis.scheduler;
|
|
23
|
+
if (typeof scheduler?.yield === "function") return scheduler.yield();
|
|
24
|
+
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
exports.mapWithConcurrency = mapWithConcurrency;
|
|
28
|
+
exports.yieldToEventLoop = yieldToEventLoop;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/util/concurrency.ts
|
|
2
|
+
/**
|
|
3
|
+
* Runs `work` for every item with at most `limit` running at once, and
|
|
4
|
+
* returns the results in the order of `items`.
|
|
5
|
+
*/
|
|
6
|
+
async function mapWithConcurrency(items, limit, work) {
|
|
7
|
+
const results = new Array(items.length);
|
|
8
|
+
const workers = Math.max(1, Math.min(Math.floor(limit) || 1, items.length));
|
|
9
|
+
let next = 0;
|
|
10
|
+
async function runWorker() {
|
|
11
|
+
while (next < items.length) {
|
|
12
|
+
const index = next;
|
|
13
|
+
next += 1;
|
|
14
|
+
results[index] = await work(items[index], index);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
await Promise.all(Array.from({ length: workers }, runWorker));
|
|
18
|
+
return results;
|
|
19
|
+
}
|
|
20
|
+
/** Lets the browser paint and handle input before the next piece of work. */
|
|
21
|
+
function yieldToEventLoop() {
|
|
22
|
+
const scheduler = globalThis.scheduler;
|
|
23
|
+
if (typeof scheduler?.yield === "function") return scheduler.yield();
|
|
24
|
+
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { mapWithConcurrency, yieldToEventLoop };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fabricjs-document-engine",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"description": "Fabric.js save and load, undo and redo, and autosave for an existing canvas: stable object ids, custom objects,
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Fabric.js save and load, undo and redo, and autosave for an existing canvas: stable object ids, custom objects, copy and paste, SVG import, PNG, SVG and PDF export, and recovery.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fabricjs",
|
|
7
7
|
"fabric.js",
|
|
@@ -27,6 +27,12 @@
|
|
|
27
27
|
"object id",
|
|
28
28
|
"export svg",
|
|
29
29
|
"export image",
|
|
30
|
+
"text on path",
|
|
31
|
+
"import svg",
|
|
32
|
+
"layers",
|
|
33
|
+
"copy paste",
|
|
34
|
+
"pdf",
|
|
35
|
+
"export pdf",
|
|
30
36
|
"recovery",
|
|
31
37
|
"indexeddb",
|
|
32
38
|
"react",
|
|
@@ -91,6 +97,16 @@
|
|
|
91
97
|
"default": "./dist/react.cjs"
|
|
92
98
|
}
|
|
93
99
|
},
|
|
100
|
+
"./pdf": {
|
|
101
|
+
"import": {
|
|
102
|
+
"types": "./dist/pdf.d.ts",
|
|
103
|
+
"default": "./dist/pdf.js"
|
|
104
|
+
},
|
|
105
|
+
"require": {
|
|
106
|
+
"types": "./dist/pdf.d.cts",
|
|
107
|
+
"default": "./dist/pdf.cjs"
|
|
108
|
+
}
|
|
109
|
+
},
|
|
94
110
|
"./schema/document-v1.json": "./schema/document-v1.schema.json",
|
|
95
111
|
"./package.json": "./package.json"
|
|
96
112
|
},
|
|
@@ -109,7 +125,9 @@
|
|
|
109
125
|
},
|
|
110
126
|
"peerDependencies": {
|
|
111
127
|
"fabric": "^6.0.0 || ^7.0.0",
|
|
112
|
-
"react": "^18.0.0 || ^19.0.0"
|
|
128
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
129
|
+
"jspdf": "^4.0.0",
|
|
130
|
+
"svg2pdf.js": "^2.7.0"
|
|
113
131
|
},
|
|
114
132
|
"publishConfig": {
|
|
115
133
|
"access": "public",
|
|
@@ -136,10 +154,13 @@
|
|
|
136
154
|
"ajv": "^8.20.0",
|
|
137
155
|
"fabric": "^7.4.0",
|
|
138
156
|
"fabric6": "npm:fabric@^6.9.1",
|
|
157
|
+
"jspdf": "^4.2.1",
|
|
158
|
+
"pdfjs-dist": "^6.3.289",
|
|
139
159
|
"playwright": "^1.63.0",
|
|
140
160
|
"publint": "^0.3.24",
|
|
141
161
|
"react": "^19.3.0",
|
|
142
162
|
"react-dom": "^19.3.0",
|
|
163
|
+
"svg2pdf.js": "^2.8.1",
|
|
143
164
|
"tsdown": "^0.23.0",
|
|
144
165
|
"typescript": "^5.9.3",
|
|
145
166
|
"vitest": "^5.0.2"
|
|
@@ -147,6 +168,12 @@
|
|
|
147
168
|
"peerDependenciesMeta": {
|
|
148
169
|
"react": {
|
|
149
170
|
"optional": true
|
|
171
|
+
},
|
|
172
|
+
"jspdf": {
|
|
173
|
+
"optional": true
|
|
174
|
+
},
|
|
175
|
+
"svg2pdf.js": {
|
|
176
|
+
"optional": true
|
|
150
177
|
}
|
|
151
178
|
}
|
|
152
179
|
}
|