@zumer/snapdom-plugins 4.4.1 → 5.0.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.
Files changed (70) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +30 -83
  3. package/ascii-export.d.ts +0 -7
  4. package/ascii-export.js +0 -21
  5. package/index.d.ts +0 -3
  6. package/index.js +1 -4
  7. package/package.json +4 -19
  8. package/pdf/LICENSE +0 -21
  9. package/pdf/README.md +0 -22
  10. package/pdf/REFERENCE.md +0 -520
  11. package/pdf/src/frontmatter.js +0 -200
  12. package/pdf/src/furniture.js +0 -398
  13. package/pdf/src/index.js +0 -2415
  14. package/pdf/src/mega/README.md +0 -47
  15. package/pdf/src/mega/diag.js +0 -148
  16. package/pdf/src/mega/flow.js +0 -56
  17. package/pdf/src/mega/fonts.js +0 -287
  18. package/pdf/src/mega/forms.js +0 -479
  19. package/pdf/src/mega/labels.js +0 -43
  20. package/pdf/src/mega/meta.js +0 -145
  21. package/pdf/src/nav.js +0 -357
  22. package/pdf/src/paginate.js +0 -583
  23. package/pdf/src/tagged.js +0 -355
  24. package/pdf/src/text-layer.js +0 -1771
  25. package/pdf/src/writer/encrypt.js +0 -218
  26. package/pdf/src/writer/font.js +0 -507
  27. package/pdf/src/writer/index.js +0 -1135
  28. package/pdf/src/writer/subset.js +0 -387
  29. package/pdf.d.ts +0 -294
  30. package/pdf.js +0 -1
  31. package/stream/LICENSE +0 -21
  32. package/stream/README.md +0 -142
  33. package/stream/src/index.js +0 -41
  34. package/stream/src/overlays.js +0 -153
  35. package/stream/src/recorder.js +0 -41
  36. package/stream/src/stream.js +0 -686
  37. package/stream/src/webgl.js +0 -58
  38. package/stream.d.ts +0 -86
  39. package/stream.js +0 -1
  40. package/vector/CONTRACT.md +0 -903
  41. package/vector/LICENSE +0 -21
  42. package/vector/README.md +0 -35
  43. package/vector/src/adapters/snapdom.js +0 -795
  44. package/vector/src/collect/box.js +0 -1676
  45. package/vector/src/collect/font.js +0 -487
  46. package/vector/src/collect/image.js +0 -1458
  47. package/vector/src/collect/mathml.js +0 -272
  48. package/vector/src/collect/text.js +0 -3027
  49. package/vector/src/css/color.js +0 -823
  50. package/vector/src/css/gradient.js +0 -1126
  51. package/vector/src/css/matrix.js +0 -398
  52. package/vector/src/css/radius.js +0 -124
  53. package/vector/src/css/shadow.js +0 -201
  54. package/vector/src/emit/figma-json.js +0 -1995
  55. package/vector/src/emit/h2d-vector.js +0 -215
  56. package/vector/src/emit/h2d.js +0 -1147
  57. package/vector/src/emit/pdf.js +0 -2571
  58. package/vector/src/emit/svg-flat.js +0 -4842
  59. package/vector/src/exclusion.js +0 -13
  60. package/vector/src/index.js +0 -2910
  61. package/vector/src/paint.js +0 -2908
  62. package/vector/src/public.js +0 -57
  63. package/vector/src/writer/encrypt.js +0 -227
  64. package/vector/src/writer/font.js +0 -507
  65. package/vector/src/writer/index.js +0 -1148
  66. package/vector/src/writer/subset.js +0 -387
  67. package/vector/svd/index.js +0 -72
  68. package/vector/svd/schema.js +0 -985
  69. package/vector.d.ts +0 -28
  70. package/vector.js +0 -1
@@ -1,58 +0,0 @@
1
- /**
2
- * A WebGL texture fed by a stream: uploads only the rects a frame changed.
3
- *
4
- * WebGL2 reads a sub-rectangle of a canvas source through the unpack parameters, so a patch
5
- * frame costs its own pixels on the bus, not the texture's. demos/stream-webgl.html: 4% of
6
- * a 1000x1976 texture per frame against 100% re-uploading it. WebGL1 has no row length, so
7
- * there every frame uploads the whole canvas.
8
- * @module plugins/stream/webgl
9
- */
10
-
11
- /**
12
- * Create a texture and the `update(frame)` that keeps it in step with a stream.
13
- * @param {WebGLRenderingContext|WebGL2RenderingContext} gl
14
- * @param {{filter?: number}} [options] - TEXTURE_MIN/MAG_FILTER, default gl.LINEAR.
15
- * @returns {{texture: WebGLTexture, width: number, height: number, update: (frame: {full: boolean, rects: {x:number,y:number,width:number,height:number}[], canvas: HTMLCanvasElement}) => number}}
16
- * `update` returns the pixels it uploaded.
17
- */
18
- export function streamTexture(gl, options = {}) {
19
- const texture = gl.createTexture()
20
- const filter = options.filter ?? gl.LINEAR
21
- const webgl2 = typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext
22
- gl.bindTexture(gl.TEXTURE_2D, texture)
23
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filter)
24
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter)
25
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)
26
- gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)
27
- const state = { texture, width: 0, height: 0, update }
28
-
29
- function update(frame) {
30
- const c = frame.canvas
31
- gl.bindTexture(gl.TEXTURE_2D, texture)
32
- if (frame.full || !webgl2 || c.width !== state.width || c.height !== state.height) {
33
- state.width = c.width
34
- state.height = c.height
35
- if (webgl2) {
36
- gl.pixelStorei(gl.UNPACK_ROW_LENGTH, 0)
37
- gl.pixelStorei(gl.UNPACK_SKIP_PIXELS, 0)
38
- gl.pixelStorei(gl.UNPACK_SKIP_ROWS, 0)
39
- }
40
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, c)
41
- return c.width * c.height
42
- }
43
- gl.pixelStorei(gl.UNPACK_ROW_LENGTH, c.width)
44
- let uploaded = 0
45
- for (const r of frame.rects) {
46
- gl.pixelStorei(gl.UNPACK_SKIP_PIXELS, r.x)
47
- gl.pixelStorei(gl.UNPACK_SKIP_ROWS, r.y)
48
- gl.texSubImage2D(gl.TEXTURE_2D, 0, r.x, r.y, r.width, r.height, gl.RGBA, gl.UNSIGNED_BYTE, c)
49
- uploaded += r.width * r.height
50
- }
51
- gl.pixelStorei(gl.UNPACK_ROW_LENGTH, 0)
52
- gl.pixelStorei(gl.UNPACK_SKIP_PIXELS, 0)
53
- gl.pixelStorei(gl.UNPACK_SKIP_ROWS, 0)
54
- return uploaded
55
- }
56
-
57
- return state
58
- }
package/stream.d.ts DELETED
@@ -1,86 +0,0 @@
1
- import type { SnapdomOptions, SnapdomPlugin } from '@zumer/snapdom'
2
-
3
- /** One repaint of a stream: the rects of `canvas` that changed, in canvas pixels. */
4
- export interface StreamFrame {
5
- /** True when the whole canvas was repainted; `reason` says why. */
6
- full: boolean
7
- reason: string | null
8
- rects: { x: number; y: number; width: number; height: number }[]
9
- /** Wall time of the repaint. */
10
- ms: number
11
- /** The part of `ms` the stream's own work held the main thread: the turns between windows and the decodes are out, a full frame's capture counts whole. */
12
- busyMs: number
13
- canvas: HTMLCanvasElement
14
- }
15
-
16
- export interface StreamOptions extends SnapdomOptions {
17
- onFrame?: (frame: StreamFrame) => void
18
- /** Cap on frames per second; default every animation frame. */
19
- fps?: number
20
- /** false repaints full frames only. Default true. */
21
- patches?: boolean
22
- /** false stops following running animations and transitions: an animated box keeps its last drawn pixels until something else repaints it. Default true. */
23
- animations?: boolean
24
- }
25
-
26
- export interface Stream {
27
- canvas: HTMLCanvasElement
28
- ready: Promise<void>
29
- stats: { full: number; patch: number; skipped: number; lastMs: number }
30
- stop(): void
31
- }
32
-
33
- /**
34
- * Stream a live element into a canvas that repaints only the boxes that changed: the
35
- * first frame is a full capture, later frames capture and redraw just the changed
36
- * subtrees, and anything that cannot be patched exactly is a full frame.
37
- */
38
- export function stream(element: Element, options?: StreamOptions): Stream
39
-
40
- /** Plugin form: adds `result.toStream(options)` to a capture result. */
41
- export function streamExport(defaults?: StreamOptions): SnapdomPlugin
42
-
43
- declare module '@zumer/snapdom' {
44
- interface CaptureResult {
45
- toStream(options?: StreamOptions): Promise<Stream>
46
- }
47
- }
48
-
49
- /** A WebGL texture kept in step with a stream; `update` uploads only the changed rects on WebGL2. */
50
- export function streamTexture(
51
- gl: WebGLRenderingContext | WebGL2RenderingContext,
52
- options?: { filter?: number }
53
- ): { texture: WebGLTexture; width: number; height: number; update(frame: StreamFrame): number }
54
-
55
- /** Record a canvas with MediaRecorder; `duration` (ms) stops it by itself. */
56
- export function recordCanvas(
57
- canvas: HTMLCanvasElement,
58
- options?: { fps?: number; duration?: number; bitrate?: number }
59
- ): { done: Promise<Blob>; stop(): Promise<Blob>; type: string }
60
-
61
- /** The transparent stage every overlay template sits on; stream this element. */
62
- export function overlayStage(options?: { width?: number; height?: number; theme?: Record<string, string> }): HTMLDivElement
63
-
64
- export interface ScoreboardClock { start(): void; stop(): void; reset(seconds?: number): void; set(text: string): void }
65
-
66
- /** Two teams, their points and a running clock. */
67
- export function scoreboard(options?: { home?: string; away?: string; homeColor?: string; awayColor?: string }): {
68
- el: HTMLElement
69
- score(home: number, away: number): void
70
- add(side: 'home' | 'away', n?: number): void
71
- clock: ScoreboardClock
72
- }
73
-
74
- /** A name and a role that slide in and out. */
75
- export function lowerThird(options?: { name?: string; role?: string; visible?: boolean }): {
76
- el: HTMLElement
77
- set(fields: { name?: string; role?: string }): void
78
- show(): void
79
- hide(): void
80
- }
81
-
82
- /** A scrolling news line; speed is seconds per loop. */
83
- export function ticker(options?: { label?: string; items?: string[]; speed?: number }): { el: HTMLElement; set(items: string[]): void }
84
-
85
- /** A pulsing LIVE bug. */
86
- export function liveBadge(options?: { text?: string }): { el: HTMLElement; set(text: string): void }
package/stream.js DELETED
@@ -1 +0,0 @@
1
- export { stream, streamExport, streamTexture, recordCanvas, overlayStage, scoreboard, lowerThird, ticker, liveBadge } from './stream/src/index.js';