@hussmartinez/pdf-sdk 0.2.0 → 0.4.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 +36 -7
- package/dist/assets/processing/processing.worker.js +1 -1
- package/dist/index.d.ts +359 -53
- package/dist/index.js +233 -1
- package/dist/index.js.map +1 -0
- package/dist/lazy/{processing-worker-DU8GEYFs.js → processing-worker-DIP9ck2l.js} +2 -2
- package/dist/lazy/{processing-worker-DU8GEYFs.js.map → processing-worker-DIP9ck2l.js.map} +1 -1
- package/dist/react.d.ts +198 -172
- package/dist/react.js +487 -78
- package/dist/react.js.map +1 -1
- package/dist/shared/{en-BYB_GHqG.js → en-DKR-ngAZ.js} +391 -217
- package/dist/shared/en-DKR-ngAZ.js.map +1 -0
- package/dist/styles.css +19 -0
- package/formats/hm-pdf-command/v1.schema.json +162 -0
- package/formats/hm-pdf-plan/v1.schema.json +259 -0
- package/package.json +18 -10
- package/dist/shared/en-BYB_GHqG.js.map +0 -1
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://github.com/ie-huss-martinez/pdf-sdk/blob/main/formats/hm-pdf-plan/v1.schema.json",
|
|
4
|
+
"title": "hm-pdf-plan, version 1",
|
|
5
|
+
"description": "A pdf-sdk page plan: the pages in order, each a page of a source with an added rotation and its annotations, and form values per source (docs/formats/hm-pdf-plan.md, sdk-core ADR 0045). Positions and sizes are whole millionths of the page. Beyond this schema, readers check that each page's source is listed and has the page, that page keys are unique, that each page's annotation ids are unique, and that form values name listed sources.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["format", "version", "sources", "pages", "formValues"],
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"properties": {
|
|
10
|
+
"format": {
|
|
11
|
+
"const": "hm-pdf-plan"
|
|
12
|
+
},
|
|
13
|
+
"version": {
|
|
14
|
+
"const": 1
|
|
15
|
+
},
|
|
16
|
+
"sources": {
|
|
17
|
+
"description": "The sources by id.",
|
|
18
|
+
"type": "object",
|
|
19
|
+
"propertyNames": {
|
|
20
|
+
"$ref": "#/$defs/id"
|
|
21
|
+
},
|
|
22
|
+
"additionalProperties": {
|
|
23
|
+
"$ref": "#/$defs/source"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"pages": {
|
|
27
|
+
"type": "array",
|
|
28
|
+
"minItems": 1,
|
|
29
|
+
"items": {
|
|
30
|
+
"$ref": "#/$defs/page"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"formValues": {
|
|
34
|
+
"description": "Form values set in the editor, by source id, then field name.",
|
|
35
|
+
"type": "object",
|
|
36
|
+
"propertyNames": {
|
|
37
|
+
"$ref": "#/$defs/id"
|
|
38
|
+
},
|
|
39
|
+
"additionalProperties": {
|
|
40
|
+
"type": "object",
|
|
41
|
+
"minProperties": 1,
|
|
42
|
+
"propertyNames": {
|
|
43
|
+
"$ref": "#/$defs/fieldName"
|
|
44
|
+
},
|
|
45
|
+
"additionalProperties": {
|
|
46
|
+
"$ref": "#/$defs/fieldValue"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"$defs": {
|
|
52
|
+
"id": {
|
|
53
|
+
"description": "A page key, source id or annotation id: 1 to 128 Unicode code points.",
|
|
54
|
+
"type": "string",
|
|
55
|
+
"minLength": 1,
|
|
56
|
+
"maxLength": 128
|
|
57
|
+
},
|
|
58
|
+
"index": {
|
|
59
|
+
"description": "A zero-based position or page index.",
|
|
60
|
+
"type": "integer",
|
|
61
|
+
"minimum": 0,
|
|
62
|
+
"maximum": 9007199254740991
|
|
63
|
+
},
|
|
64
|
+
"keys": {
|
|
65
|
+
"description": "Page keys, at least one.",
|
|
66
|
+
"type": "array",
|
|
67
|
+
"minItems": 1,
|
|
68
|
+
"items": {
|
|
69
|
+
"$ref": "#/$defs/id"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"millionths": {
|
|
73
|
+
"description": "A position on the page, in whole millionths of its width or height, from 0 to 1,000,000.",
|
|
74
|
+
"type": "integer",
|
|
75
|
+
"minimum": 0,
|
|
76
|
+
"maximum": 1000000
|
|
77
|
+
},
|
|
78
|
+
"size": {
|
|
79
|
+
"description": "A stroke width or text size, in whole millionths of the page's height, from 1 to 1,000,000.",
|
|
80
|
+
"type": "integer",
|
|
81
|
+
"minimum": 1,
|
|
82
|
+
"maximum": 1000000
|
|
83
|
+
},
|
|
84
|
+
"point": {
|
|
85
|
+
"description": "A point on the page's unrotated media box: x from the left edge, y from the top edge.",
|
|
86
|
+
"type": "object",
|
|
87
|
+
"required": ["x", "y"],
|
|
88
|
+
"additionalProperties": false,
|
|
89
|
+
"properties": {
|
|
90
|
+
"x": {
|
|
91
|
+
"$ref": "#/$defs/millionths"
|
|
92
|
+
},
|
|
93
|
+
"y": {
|
|
94
|
+
"$ref": "#/$defs/millionths"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"color": {
|
|
99
|
+
"description": "#rrggbb, in lowercase.",
|
|
100
|
+
"type": "string",
|
|
101
|
+
"pattern": "^#[0-9a-f]{6}$"
|
|
102
|
+
},
|
|
103
|
+
"stroke": {
|
|
104
|
+
"description": "A pen stroke, or a highlighter stroke, which is drawn translucent.",
|
|
105
|
+
"type": "object",
|
|
106
|
+
"required": ["id", "type", "points", "color", "width"],
|
|
107
|
+
"additionalProperties": false,
|
|
108
|
+
"properties": {
|
|
109
|
+
"id": {
|
|
110
|
+
"$ref": "#/$defs/id"
|
|
111
|
+
},
|
|
112
|
+
"type": {
|
|
113
|
+
"enum": ["pen", "highlight"]
|
|
114
|
+
},
|
|
115
|
+
"points": {
|
|
116
|
+
"type": "array",
|
|
117
|
+
"minItems": 1,
|
|
118
|
+
"maxItems": 10000,
|
|
119
|
+
"items": {
|
|
120
|
+
"$ref": "#/$defs/point"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"color": {
|
|
124
|
+
"$ref": "#/$defs/color"
|
|
125
|
+
},
|
|
126
|
+
"width": {
|
|
127
|
+
"$ref": "#/$defs/size"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
"textNote": {
|
|
132
|
+
"description": "A text note, drawn as text and never interpreted as markup. at is its top-left corner.",
|
|
133
|
+
"type": "object",
|
|
134
|
+
"required": ["id", "type", "at", "text", "size", "color"],
|
|
135
|
+
"additionalProperties": false,
|
|
136
|
+
"properties": {
|
|
137
|
+
"id": {
|
|
138
|
+
"$ref": "#/$defs/id"
|
|
139
|
+
},
|
|
140
|
+
"type": {
|
|
141
|
+
"const": "text"
|
|
142
|
+
},
|
|
143
|
+
"at": {
|
|
144
|
+
"$ref": "#/$defs/point"
|
|
145
|
+
},
|
|
146
|
+
"text": {
|
|
147
|
+
"$ref": "#/$defs/textValue"
|
|
148
|
+
},
|
|
149
|
+
"size": {
|
|
150
|
+
"$ref": "#/$defs/size"
|
|
151
|
+
},
|
|
152
|
+
"color": {
|
|
153
|
+
"$ref": "#/$defs/color"
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
"annotation": {
|
|
158
|
+
"description": "An annotation drawn on a page. Version 1 has no signatures.",
|
|
159
|
+
"oneOf": [
|
|
160
|
+
{
|
|
161
|
+
"$ref": "#/$defs/stroke"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"$ref": "#/$defs/textNote"
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
},
|
|
168
|
+
"textValue": {
|
|
169
|
+
"description": "Text of up to 10,000 Unicode code points.",
|
|
170
|
+
"type": "string",
|
|
171
|
+
"maxLength": 10000
|
|
172
|
+
},
|
|
173
|
+
"fieldName": {
|
|
174
|
+
"description": "A form field's name: 1 to 1,000 Unicode code points.",
|
|
175
|
+
"type": "string",
|
|
176
|
+
"minLength": 1,
|
|
177
|
+
"maxLength": 1000
|
|
178
|
+
},
|
|
179
|
+
"fieldValue": {
|
|
180
|
+
"description": "A text field's value, or whether a checkbox is checked.",
|
|
181
|
+
"oneOf": [
|
|
182
|
+
{
|
|
183
|
+
"$ref": "#/$defs/textValue"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"type": "boolean"
|
|
187
|
+
}
|
|
188
|
+
]
|
|
189
|
+
},
|
|
190
|
+
"asset": {
|
|
191
|
+
"description": "A content-addressed reference to a source's bytes. Documents never inline them.",
|
|
192
|
+
"type": "object",
|
|
193
|
+
"required": ["asset", "mediaType", "size"],
|
|
194
|
+
"additionalProperties": false,
|
|
195
|
+
"properties": {
|
|
196
|
+
"asset": {
|
|
197
|
+
"description": "sha256: and the lowercase hex SHA-256 of the bytes.",
|
|
198
|
+
"type": "string",
|
|
199
|
+
"pattern": "^sha256:[0-9a-f]{64}$"
|
|
200
|
+
},
|
|
201
|
+
"mediaType": {
|
|
202
|
+
"description": "The bytes' media type, such as application/pdf, in lowercase.",
|
|
203
|
+
"type": "string",
|
|
204
|
+
"maxLength": 255,
|
|
205
|
+
"pattern": "^[a-z0-9][a-z0-9!#$&^_.+-]*/[a-z0-9][a-z0-9!#$&^_.+-]*$"
|
|
206
|
+
},
|
|
207
|
+
"size": {
|
|
208
|
+
"description": "The size of the bytes.",
|
|
209
|
+
"type": "integer",
|
|
210
|
+
"minimum": 0,
|
|
211
|
+
"maximum": 9007199254740991
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
"source": {
|
|
216
|
+
"description": "A source document: its page count, and, once documents travel with their files, its content.",
|
|
217
|
+
"type": "object",
|
|
218
|
+
"required": ["pageCount"],
|
|
219
|
+
"additionalProperties": false,
|
|
220
|
+
"properties": {
|
|
221
|
+
"pageCount": {
|
|
222
|
+
"type": "integer",
|
|
223
|
+
"minimum": 1,
|
|
224
|
+
"maximum": 9007199254740991
|
|
225
|
+
},
|
|
226
|
+
"asset": {
|
|
227
|
+
"$ref": "#/$defs/asset"
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
"page": {
|
|
232
|
+
"description": "A page of a source, in plan order. Its key is stable while it moves.",
|
|
233
|
+
"type": "object",
|
|
234
|
+
"required": ["key", "source", "pageIndex", "rotation", "annotations"],
|
|
235
|
+
"additionalProperties": false,
|
|
236
|
+
"properties": {
|
|
237
|
+
"key": {
|
|
238
|
+
"$ref": "#/$defs/id"
|
|
239
|
+
},
|
|
240
|
+
"source": {
|
|
241
|
+
"$ref": "#/$defs/id"
|
|
242
|
+
},
|
|
243
|
+
"pageIndex": {
|
|
244
|
+
"$ref": "#/$defs/index"
|
|
245
|
+
},
|
|
246
|
+
"rotation": {
|
|
247
|
+
"description": "Degrees, clockwise, added to the page's own /Rotate.",
|
|
248
|
+
"enum": [0, 90, 180, 270]
|
|
249
|
+
},
|
|
250
|
+
"annotations": {
|
|
251
|
+
"type": "array",
|
|
252
|
+
"items": {
|
|
253
|
+
"$ref": "#/$defs/annotation"
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hussmartinez/pdf-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Client-side PDF SDK: a headless core, a React editor and a custom element. Files never leave the device.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -36,10 +36,12 @@
|
|
|
36
36
|
"default": "./dist/element.js"
|
|
37
37
|
},
|
|
38
38
|
"./styles.css": "./dist/styles.css",
|
|
39
|
+
"./formats/*": "./formats/*",
|
|
39
40
|
"./package.json": "./package.json"
|
|
40
41
|
},
|
|
41
42
|
"files": [
|
|
42
43
|
"dist",
|
|
44
|
+
"formats",
|
|
43
45
|
"NOTICE"
|
|
44
46
|
],
|
|
45
47
|
"engines": {
|
|
@@ -47,7 +49,7 @@
|
|
|
47
49
|
},
|
|
48
50
|
"dependencies": {
|
|
49
51
|
"@hussmartinez/sdk-core": "^0.4.4",
|
|
50
|
-
"@hussmartinez/ui": "^0.
|
|
52
|
+
"@hussmartinez/ui": "^0.8.0"
|
|
51
53
|
},
|
|
52
54
|
"peerDependencies": {
|
|
53
55
|
"react": ">=18.3",
|
|
@@ -68,19 +70,21 @@
|
|
|
68
70
|
"@changesets/changelog-github": "^1.0.1",
|
|
69
71
|
"@changesets/cli": "^3.0.3",
|
|
70
72
|
"@commitlint/cli": "^21.2.4",
|
|
71
|
-
"@hussmartinez/sdk-config": "^0.
|
|
73
|
+
"@hussmartinez/sdk-config": "^0.9.0",
|
|
72
74
|
"@microsoft/api-extractor": "^7.60.1",
|
|
73
75
|
"@size-limit/file": "^14.3.0",
|
|
74
76
|
"@types/node": "^24.19.2",
|
|
75
77
|
"@types/react": "^19.3.0",
|
|
76
78
|
"@types/react-dom": "^19.3.0",
|
|
77
79
|
"@vitest/browser-playwright": "5.1.0",
|
|
80
|
+
"ajv": "^8.20.0",
|
|
78
81
|
"dependency-cruiser": "^18.7.2",
|
|
82
|
+
"fast-check": "^4.10.2",
|
|
79
83
|
"husky": "^9.1.7",
|
|
80
84
|
"lint-staged": "^17.6.0",
|
|
81
85
|
"pdfjs-dist": "6.5.438",
|
|
82
86
|
"pdfstudio": "0.4.0",
|
|
83
|
-
"playwright": "
|
|
87
|
+
"playwright": "1.65.1",
|
|
84
88
|
"publint": "^0.3.25",
|
|
85
89
|
"react": "^19.3.0",
|
|
86
90
|
"react-dom": "^19.3.0",
|
|
@@ -93,22 +97,26 @@
|
|
|
93
97
|
},
|
|
94
98
|
"scripts": {
|
|
95
99
|
"changeset": "changeset",
|
|
96
|
-
"lint": "biome check .",
|
|
100
|
+
"lint": "biome check . && node tools/check-hidden-unicode.ts",
|
|
97
101
|
"lint:css": "stylelint \"**/*.css\" --allow-empty-input",
|
|
98
102
|
"lint:deps": "hm-lint-deps src",
|
|
99
103
|
"typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.test.json",
|
|
100
104
|
"build": "vite build && pnpm check:api",
|
|
101
105
|
"test": "vitest run --project unit",
|
|
102
|
-
"test:browser": "vitest run --project browser",
|
|
103
|
-
"test:browser:all": "vitest run --project browser --mode all-browsers",
|
|
106
|
+
"test:browser": "hm-in-image vitest run --project browser",
|
|
107
|
+
"test:browser:all": "hm-in-image vitest run --project browser --mode all-browsers",
|
|
108
|
+
"conformance:update": "vitest run --project unit test/conformance --update",
|
|
104
109
|
"check:single-copy": "hm-check-single-copy",
|
|
110
|
+
"check:playwright-image": "hm-check-playwright-image",
|
|
105
111
|
"check:size": "size-limit",
|
|
106
112
|
"check:api": "tsc -p tsconfig.build.json && api-extractor run && api-extractor run -c api-extractor.react.json && api-extractor run -c api-extractor.element.json && hm-check-api-reports --main api/pdf-sdk.api.md --types dist/index.d.ts api/pdf-sdk-react.api.md api/pdf-sdk-element.api.md",
|
|
107
113
|
"check:package": "publint run --pack pnpm --strict && attw --pack . --profile esm-only --exclude-entrypoints ./styles.css",
|
|
108
114
|
"api:update": "tsc -p tsconfig.build.json && api-extractor run --local && api-extractor run -c api-extractor.react.json --local && api-extractor run -c api-extractor.element.json --local && hm-check-api-reports --main api/pdf-sdk.api.md --types dist/index.d.ts api/pdf-sdk-react.api.md api/pdf-sdk-element.api.md",
|
|
109
|
-
"verify": "pnpm lint && pnpm lint:css && pnpm typecheck && pnpm lint:deps && pnpm check:single-copy && pnpm build && pnpm test && pnpm test:browser && pnpm build:examples && pnpm test:e2e && pnpm check:size && pnpm check:api && pnpm check:package",
|
|
110
|
-
"verify:fast": "pnpm typecheck && pnpm test && pnpm lint:deps && pnpm check:single-copy && pnpm check:api",
|
|
115
|
+
"verify": "pnpm lint && pnpm lint:css && pnpm typecheck && pnpm lint:deps && pnpm check:single-copy && pnpm check:playwright-image && pnpm build && pnpm test && pnpm test:browser && pnpm build:examples && pnpm test:e2e && pnpm test:visual && pnpm check:size && pnpm check:api && pnpm check:package",
|
|
116
|
+
"verify:fast": "pnpm typecheck && pnpm test && pnpm lint:deps && pnpm check:single-copy && pnpm check:playwright-image && pnpm check:api",
|
|
111
117
|
"build:examples": "pnpm --filter \"./examples/*\" build",
|
|
112
|
-
"test:e2e": "pnpm --filter @hussmartinez/pdf-sdk-e2e test:e2e"
|
|
118
|
+
"test:e2e": "pnpm --filter @hussmartinez/pdf-sdk-e2e test:e2e",
|
|
119
|
+
"test:visual": "hm-test-visual",
|
|
120
|
+
"test:visual:update": "hm-test-visual --update"
|
|
113
121
|
}
|
|
114
122
|
}
|