ranuts 0.2.0-alpha.1 → 0.3.0-alpha.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.
Files changed (112) hide show
  1. package/CLAUDE.md +107 -16
  2. package/README.md +7 -5
  3. package/README.zh-CN.md +7 -5
  4. package/dist/chain-CTywmh_H.js +1 -0
  5. package/dist/{color-CRdlaDqQ.js → color-Dohr9BXX.js} +1 -1
  6. package/dist/enums-BAgbyGdH.js +1 -0
  7. package/dist/i18n-Cf5TtRb4.js +1 -0
  8. package/dist/index.d.ts +1 -5
  9. package/dist/index.js +1 -1
  10. package/dist/src/node/appendFile.d.ts +3 -3
  11. package/dist/src/node/fileInfo.d.ts +2 -2
  12. package/dist/src/node/index.js +1 -1
  13. package/dist/src/node/paresUrl.d.ts +1 -1
  14. package/dist/src/node/readFile.d.ts +3 -3
  15. package/dist/src/node/traverse.d.ts +2 -2
  16. package/dist/src/node/watchFile.d.ts +3 -3
  17. package/dist/src/node/writeFile.d.ts +3 -3
  18. package/dist/src/utils/async.d.ts +81 -0
  19. package/dist/src/utils/audioRecorder.d.ts +1 -1
  20. package/dist/src/utils/behavior.d.ts +12 -3
  21. package/dist/src/utils/bom.d.ts +68 -178
  22. package/dist/src/utils/bridge.d.ts +153 -0
  23. package/dist/src/utils/canvas.d.ts +54 -0
  24. package/dist/src/utils/chain.d.ts +80 -0
  25. package/dist/src/utils/color.d.ts +76 -4
  26. package/dist/src/utils/compose.d.ts +1 -1
  27. package/dist/src/utils/console.d.ts +19 -1
  28. package/dist/src/utils/debounce.d.ts +27 -5
  29. package/dist/src/utils/device.d.ts +31 -3
  30. package/dist/src/utils/dom.d.ts +5 -84
  31. package/dist/src/utils/error.d.ts +18 -1
  32. package/dist/src/utils/event.d.ts +61 -0
  33. package/dist/src/utils/file.d.ts +30 -0
  34. package/dist/src/utils/i18n/index.js +1 -0
  35. package/dist/src/utils/i18n.d.ts +69 -0
  36. package/dist/src/utils/idb.d.ts +178 -0
  37. package/dist/src/utils/img.d.ts +60 -4
  38. package/dist/src/utils/index.d.ts +48 -16
  39. package/dist/src/utils/index.js +1 -1
  40. package/dist/src/utils/lang.d.ts +69 -0
  41. package/dist/src/utils/localePath.d.ts +62 -0
  42. package/dist/src/utils/memoize.d.ts +53 -5
  43. package/dist/src/utils/monitor.d.ts +55 -26
  44. package/dist/src/utils/number.d.ts +46 -9
  45. package/dist/src/utils/obj.d.ts +56 -31
  46. package/dist/src/utils/prefetch.d.ts +81 -0
  47. package/dist/src/utils/queue.d.ts +53 -23
  48. package/dist/src/utils/report.d.ts +51 -3
  49. package/dist/src/utils/request.d.ts +26 -7
  50. package/dist/src/utils/script.d.ts +26 -4
  51. package/dist/src/utils/segment.d.ts +62 -0
  52. package/dist/src/utils/signal.d.ts +35 -3
  53. package/dist/src/utils/storage.d.ts +57 -0
  54. package/dist/src/utils/str.d.ts +112 -88
  55. package/dist/src/utils/style.d.ts +31 -0
  56. package/dist/src/utils/subscribe.d.ts +5 -5
  57. package/dist/src/utils/throttle.d.ts +26 -13
  58. package/dist/src/utils/time.d.ts +38 -6
  59. package/dist/src/utils/tween.d.ts +40 -0
  60. package/dist/src/utils/visual/application.d.ts +4 -4
  61. package/dist/src/utils/visual/enums.d.ts +4 -4
  62. package/dist/src/utils/visual/graphics/graphics.d.ts +25 -25
  63. package/dist/src/utils/visual/graphics/graphicsData.d.ts +1 -1
  64. package/dist/src/utils/visual/graphics/graphicsGeometry.d.ts +6 -6
  65. package/dist/src/utils/visual/index.js +1 -1
  66. package/dist/src/utils/visual/math/matrix.d.ts +8 -8
  67. package/dist/src/utils/visual/math/transform.d.ts +1 -1
  68. package/dist/src/utils/visual/render/batchRenderer.d.ts +20 -18
  69. package/dist/src/utils/visual/render/utils/batch/index.d.ts +13 -13
  70. package/dist/src/utils/visual/render/utils/float.d.ts +13 -13
  71. package/dist/src/utils/visual/render/utils/verticy.d.ts +3 -3
  72. package/dist/src/utils/visual/render/utils/webgl/initShader.d.ts +3 -2
  73. package/dist/src/utils/visual/render/utils/webgpu/shaders.d.ts +2 -2
  74. package/dist/src/utils/visual/render/webGPURenderer.d.ts +8 -8
  75. package/dist/src/utils/visual/vertex/container.d.ts +17 -16
  76. package/dist/src/utils/worker.d.ts +76 -0
  77. package/dist/src/utils/zip.d.ts +162 -0
  78. package/dist/src/vnode/index.d.ts +1 -1
  79. package/dist/src/vnode/index.js +1 -1
  80. package/dist/src/vnode/is.d.ts +4 -0
  81. package/dist/test/canvas.test.d.ts +1 -0
  82. package/dist/test/color.test.d.ts +1 -0
  83. package/dist/test/tween.test.d.ts +1 -0
  84. package/dist/test/utils/async.test.d.ts +1 -0
  85. package/dist/test/utils/file-read.test.d.ts +1 -0
  86. package/dist/test/utils/format.test.d.ts +1 -0
  87. package/dist/test/utils/idb.test.d.ts +1 -0
  88. package/dist/test/utils/instrumentation.test.d.ts +1 -0
  89. package/dist/test/utils/lang.test.d.ts +1 -0
  90. package/dist/test/utils/locale-path.test.d.ts +1 -0
  91. package/dist/test/utils/media-query.test.d.ts +1 -0
  92. package/dist/test/utils/number-parse.test.d.ts +1 -0
  93. package/dist/test/utils/prefetch.test.d.ts +1 -0
  94. package/dist/test/utils/query-storage.test.d.ts +1 -0
  95. package/dist/test/utils/queue.test.d.ts +1 -0
  96. package/dist/test/utils/report-config.test.d.ts +1 -0
  97. package/dist/test/utils/report-image.test.d.ts +1 -0
  98. package/dist/test/utils/segment.test.d.ts +1 -0
  99. package/dist/test/utils/signal-once.test.d.ts +1 -0
  100. package/dist/test/utils/single-flight.test.d.ts +1 -0
  101. package/dist/test/utils/timing.test.d.ts +1 -0
  102. package/dist/test/utils/worker-client.test.d.ts +1 -0
  103. package/dist/test/utils/zip.test.d.ts +1 -0
  104. package/dist/umd/index.umd.cjs +1 -1
  105. package/dist/umd/node/node.umd.cjs +1 -1
  106. package/dist/umd/utils/utils.umd.cjs +1 -1
  107. package/dist/utils-BDtXHcK8.js +1 -0
  108. package/docs/API.md +306 -147
  109. package/package.json +9 -6
  110. package/dist/src/vnode/chainDom.d.ts +0 -47
  111. package/dist/subscribe-CINWsor3.js +0 -1
  112. package/dist/utils-_OxsVZmz.js +0 -1
@@ -3,44 +3,44 @@ import type { Container } from '@/utils/visual/vertex/container';
3
3
  import type { Fill } from '@/utils/visual/style';
4
4
  import type { Graphics } from '@/utils/visual/graphics';
5
5
  /**
6
- * 构建大数组
6
+ * Build the big array
7
7
  */
8
8
  export declare const buildArray: (batchRenderer: BatchRenderer, container: Container) => void;
9
9
  /**
10
- * 更新大数组
10
+ * Update the big array
11
11
  */
12
12
  export declare const updateArray: (floatView: Float32Array, container: Container) => void;
13
13
  export declare abstract class Batch {
14
14
  /**
15
- * 顶点个数
15
+ * Vertex count
16
16
  */
17
17
  vertexCount: number;
18
18
  /**
19
- * 顶点下标个数
19
+ * Index count
20
20
  */
21
21
  indexCount: number;
22
22
  /**
23
- * rgba 的小端序形式
23
+ * rgba packed little-endian
24
24
  */
25
25
  rgba: number;
26
26
  /**
27
- * 顶点数据在大数组中的起点
27
+ * Where this batch's vertices start in the big array
28
28
  */
29
29
  vertexStart: number;
30
30
  /**
31
- * 顶点下标数据在大数组中的起点
31
+ * Where this batch's indices start in the big array
32
32
  */
33
33
  indexStart: number;
34
34
  /**
35
- * 将顶点数据写入大数组中
35
+ * Write the vertex data into the big array
36
36
  */
37
37
  abstract packVertices(floatView: Float32Array, intView: Uint32Array): void;
38
38
  /**
39
- * 将顶点下标数据写入大数组中
39
+ * Write the index data into the big array
40
40
  */
41
41
  abstract packIndices(int32: Uint32Array): void;
42
42
  /**
43
- * 在大数组中更新顶点位置数据
43
+ * Update the vertex positions inside the big array
44
44
  */
45
45
  abstract updateVertices(floatView: Float32Array): void;
46
46
  }
@@ -66,15 +66,15 @@ export declare class GraphicsBatchPool extends BatchPool {
66
66
  }
67
67
  export declare class GraphicsBatch extends Batch {
68
68
  /**
69
- * 顶点部分在 geometry.vertices 中的起始下标
69
+ * Where this part's vertices start in geometry.vertices
70
70
  */
71
71
  vertexOffset: number;
72
72
  /**
73
- * 顶点下标部分在 geometry.indices 中的起始下标
73
+ * Where this part's indices start in geometry.indices
74
74
  */
75
75
  indexOffset: number;
76
76
  /**
77
- * 对应的 Graphics 实例
77
+ * The Graphics instance this belongs to
78
78
  */
79
79
  graphics: Graphics;
80
80
  packVertices(floatView: Float32Array, intView: Uint32Array): void;
@@ -5,28 +5,28 @@ export declare class CustomFloatArray {
5
5
  private float32;
6
6
  private _data;
7
7
  /**
8
- * 获取长度
8
+ * Current length
9
9
  */
10
10
  get length(): number;
11
11
  /**
12
- * 拼接一个 number 数组
12
+ * Append an array of numbers
13
13
  */
14
14
  concat(arr: number[]): void;
15
15
  /**
16
- * 插入数据
17
- * @param num 要插入的数
16
+ * Push one value
17
+ * @param num the value to push
18
18
  */
19
19
  push(num: number): void;
20
20
  /**
21
- * 扩容
21
+ * Grow the backing buffer
22
22
  */
23
23
  expandCapacity(): void;
24
24
  /**
25
- * 以从 0 this.length 的这段 buffer 为底层,建立 Float32Array 视图并返回
25
+ * A Float32Array view over the buffer from 0 to this.length
26
26
  */
27
27
  get data(): Float32Array;
28
28
  /**
29
- * 清空
29
+ * Clear
30
30
  */
31
31
  clear(): void;
32
32
  }
@@ -37,27 +37,27 @@ export declare class CustomIntArray {
37
37
  private int32;
38
38
  private _data;
39
39
  /**
40
- * 获取长度
40
+ * Current length
41
41
  */
42
42
  get length(): number;
43
43
  /**
44
- * 拼接一个 number 数组
44
+ * Append an array of numbers
45
45
  */
46
46
  concat(arr: number[]): void;
47
47
  /**
48
- * 拼接一个UInt16数组
48
+ * Append a UInt16 array
49
49
  */
50
50
  concatUInt16(uint16: Uint32Array): void;
51
51
  /**
52
- * 扩容
52
+ * Grow the backing buffer
53
53
  */
54
54
  expandCapacity(): void;
55
55
  /**
56
- * 以从 0 this.length 的这段 buffer 为底层,建立 Uint32Array 视图并返回
56
+ * A Uint32Array view over the buffer from 0 to this.length
57
57
  */
58
58
  get data(): Uint32Array;
59
59
  /**
60
- * 清空
60
+ * Clear
61
61
  */
62
62
  clear(): void;
63
63
  }
@@ -1,13 +1,13 @@
1
1
  import type { GraphicsData } from '@/utils/visual/graphics/graphicsData';
2
2
  import type { GraphicsGeometry } from '@/utils/visual/graphics/graphicsGeometry';
3
3
  /**
4
- * 将一个图形顶点化
5
- * @param data 子图形data
4
+ * Turn a shape into vertices
5
+ * @param data the sub-shape's data
6
6
  */
7
7
  export declare const buildVertices: (data: GraphicsData) => void;
8
8
  export declare const triangulateFill: (data: GraphicsData, geometry: GraphicsGeometry) => void;
9
9
  export declare const getNormalVector: (x: number, y: number, lineWidth: number) => [number, number];
10
10
  /**
11
- * 构建描边的顶点 & 对其进行三角剖分
11
+ * Build the stroke's vertices and triangulate them
12
12
  */
13
13
  export declare const triangulateStroke: (data: GraphicsData, geometry: GraphicsGeometry) => void;
@@ -1,7 +1,8 @@
1
1
  import type { WebGLRenderer } from '@/utils/visual/render/webGlRenderer';
2
2
  /**
3
- * 设置顶点属性布局。调用前需保证目标 ARRAY_BUFFER 已经绑定。
4
- * 顶点格式与共享批处理管线(BatchRenderer)一致:position(2×Float32) + color(4×Uint8, 归一化),stride = BYTES_PER_VERTEX。
3
+ * Set the vertex attribute layout. The target ARRAY_BUFFER must already be bound.
4
+ * The vertex format matches the shared batching pipeline (BatchRenderer):
5
+ * position (2×Float32) + colour (4×Uint8, normalised), stride = BYTES_PER_VERTEX.
5
6
  */
6
7
  export declare const setupVertexLayout: (gl: WebGLRenderingContext, program: WebGLProgram) => void;
7
8
  export declare const initShader: (renderer: WebGLRenderer) => WebGLProgram;
@@ -1,8 +1,8 @@
1
1
  /**
2
- * 顶点着色器
2
+ * Vertex shader
3
3
  */
4
4
  export declare const vertexShaderSource = "\n@group(0) @binding(0) var<uniform> u_root_transform: mat3x3<f32>;\n@group(0) @binding(1) var<uniform> u_projection_matrix: mat3x3<f32>;\n\nstruct VertOutput {\n @builtin(position) v_position: vec4<f32>,\n @location(0) v_color : vec4<f32>,\n};\n\n@vertex\nfn main(\n @location(0) a_position: vec2<f32>,\n @location(1) a_color: vec4<f32>,\n) -> VertOutput {\n let v_position = vec4<f32>((u_projection_matrix * u_root_transform * vec3<f32>(a_position, 1.0)).xy, 0.0, 1.0);\n\n let v_color = a_color;\n\n return VertOutput(v_position, v_color);\n}\n";
5
5
  /**
6
- * 片元着色器
6
+ * Fragment shader
7
7
  */
8
8
  export declare const fragmentShaderSource = "\n@fragment\nfn main(\n @location(0) v_color : vec4<f32>,\n) -> @location(0) vec4<f32> {\n return v_color;\n}\n";
@@ -7,23 +7,23 @@ export declare class WebGPURenderer extends BatchRenderer {
7
7
  private renderPassDescriptor;
8
8
  private options;
9
9
  /**
10
- * 顶点的 webGPU buffer
10
+ * WebGPU buffer holding the vertices
11
11
  */
12
12
  private gpuVertexBuffer;
13
13
  /**
14
- * 顶点下标的 webGPU buffer
14
+ * WebGPU buffer holding the vertex indices
15
15
  */
16
16
  private gpuIndexBuffer;
17
17
  /**
18
- * 投影矩阵的 webGPU buffer
18
+ * WebGPU buffer holding the projection matrix
19
19
  */
20
20
  private projectionMatBuffer;
21
21
  /**
22
- * stage 的变换矩阵的 webGPU buffer
22
+ * WebGPU buffer holding the stage's transform matrix
23
23
  */
24
24
  private stageMatBuffer;
25
25
  /**
26
- * uniform 变量的 bind group
26
+ * Bind group for the uniforms
27
27
  */
28
28
  private uniformBindGroup;
29
29
  constructor(options: IApplicationOptions);
@@ -35,15 +35,15 @@ export declare class WebGPURenderer extends BatchRenderer {
35
35
  protected setRootTransform(a: number, b: number, c: number, d: number, tx: number, ty: number): void;
36
36
  protected setProjectionMatrix(): void;
37
37
  /**
38
- * 初始化 pipeline
38
+ * Initialise the pipeline
39
39
  */
40
40
  private createPipeline;
41
41
  /**
42
- * 初始化 device
42
+ * Initialise the device
43
43
  */
44
44
  private initDevice;
45
45
  /**
46
- * 初始化 renderPassDescriptor
46
+ * Initialise the renderPassDescriptor
47
47
  */
48
48
  private initRenderPassDescriptor;
49
49
  }
@@ -7,68 +7,69 @@ export declare class Container extends Vertex {
7
7
  isSort: boolean;
8
8
  type: string;
9
9
  /**
10
- * 所有子元素
10
+ * Every child
11
11
  */
12
12
  readonly children: Container[];
13
13
  /**
14
- * 用来标记 worldTransform 是否发生了改变
14
+ * Marks whether worldTransform changed
15
15
  */
16
16
  protected worldId: number;
17
17
  /**
18
- * 所有 batch
18
+ * Every batch
19
19
  */
20
20
  protected batches: Batch[];
21
21
  /**
22
- * batch 总数
22
+ * Number of batches
23
23
  */
24
24
  protected batchCount: number;
25
25
  /**
26
- * 场景结构版本号(仅根节点上的值有意义)。任何会改变“大数组该长什么样”的操作
27
- * (增删子节点、Graphics 重绘)都会冒泡到根节点并使其 +1,渲染器据此决定是否重建大数组。
26
+ * Scene structure version (only meaningful on the root). Anything that changes what the
27
+ * big array should look like — adding or removing a child, a Graphics redraw — bubbles to
28
+ * the root and increments it, and the renderer uses that to decide whether to rebuild.
28
29
  */
29
30
  structureVersion: number;
30
31
  constructor();
31
32
  /**
32
- * 标记场景结构已变化:冒泡到根节点并递增其版本号,触发下一帧的大数组重建。
33
+ * Mark the scene structure as changed: bubble to the root and bump its version, so the next frame rebuilds the big array.
33
34
  */
34
35
  protected markStructureDirty: () => void;
35
36
  /**
36
- * @description: 添加子元素
37
+ * @description: Add a child
37
38
  * @param {Container} child
38
39
  * @return {*}
39
40
  */
40
41
  addChild: (child: Container) => void;
41
42
  /**
42
- * @description:删除子元素
43
+ * @description: Remove a child
43
44
  * @param {Container} child
44
45
  * @return {void}
45
46
  */
46
47
  removeChild: (child: Container) => void;
47
48
  /**
48
- * @description: 根据 z-index 排序子元素
49
+ * @description: Sort children by z-index
49
50
  * @return {*}
50
51
  */
51
52
  sortChildren: () => void;
52
53
  /**
53
- * 渲染自身,在 container 上面没有东西要渲染,所以这个函数的内容为空
54
+ * Render itself — a container has nothing to render, so this is empty
54
55
  */
55
56
  protected renderCanvas(_render: CanvasRenderer): void;
56
57
  /**
57
- * 递归渲染以自身为根的整棵节点树
58
+ * Recursively render the whole tree rooted here
58
59
  */
59
60
  renderCanvasRecursive: (render: CanvasRenderer) => void;
60
61
  /**
61
- * 递归更新当前元素以及所有子元素的 transform
62
+ * Recursively update this element's transform and every child's
62
63
  */
63
64
  updateTransform: () => void;
64
65
  containsPoint: (p: Point) => boolean;
65
66
  /**
66
- * 构建自身的 batch。组容器自身没有可渲染内容,子类(如 Graphics)会重写此方法。
67
- * WebGL / WebGPU 后端统一通过 BatchRenderer buildArray 递归调用本方法。
67
+ * Build its own batches. A group has no content of its own, so subclasses such as
68
+ * Graphics override this. Both GPU backends reach it through BatchRenderer's buildArray.
68
69
  */
69
70
  buildBatches(_batchRenderer: BatchRenderer): void;
70
71
  /**
71
- * 更新自身的所有 batch 对应的大数组中的顶点
72
+ * Update this node's batched vertices inside the big array
72
73
  */
73
74
  updateBatches(_floatView: Float32Array): void;
74
75
  }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * A request/response wrapper over a Web Worker.
3
+ *
4
+ * A native worker only knows "post a message" and "receive a message" — there is no notion
5
+ * of a request and its response: send two tasks concurrently, get two messages back, and
6
+ * there is no way to tell which is which. The standard fix is to number each request and
7
+ * echo that number in the response; this class packages that correlation logic (ids, a
8
+ * pending table, progress events, rejecting every in-flight request when the worker
9
+ * crashes) into something reusable.
10
+ *
11
+ * It also owns the worker's lifecycle: **the worker is created on the first `send`** (heavy
12
+ * work should not start at page load), and `dispose()` terminates it and rejects in-flight
13
+ * requests; a later `send` rebuilds it.
14
+ */
15
+ /** A response must at least echo the request id so the two can be paired */
16
+ export interface WorkerResponseBase {
17
+ operationId: number;
18
+ type?: string;
19
+ }
20
+ export interface WorkerClientOptions<Res extends WorkerResponseBase, Progress> {
21
+ /** How to create the worker, e.g. `() => new Worker(new URL('./my.worker.ts', import.meta.url), { type: 'module' })` */
22
+ create: () => Worker;
23
+ /** Whether this is a progress message — it does not settle the request, it only calls onProgress. Defaults to `type === 'progress'` */
24
+ isProgress?: (response: Res) => boolean;
25
+ /** Extract the progress payload from a progress message. Defaults to `response.progress` */
26
+ getProgress?: (response: Res) => Progress;
27
+ /** Whether this is an error message. Defaults to `type === 'error'` */
28
+ isError?: (response: Res) => boolean;
29
+ /** Error message text. Defaults to `response.message` */
30
+ getErrorMessage?: (response: Res) => string;
31
+ /** Per-request timeout in milliseconds; omit for none. A timeout only rejects that request, it does not terminate the worker */
32
+ timeout?: number;
33
+ }
34
+ /**
35
+ * @description: A worker client with request ids. The request type `Req` is defined by the
36
+ * caller; the client only fills in `operationId` and routes each response back to the right
37
+ * promise.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const client = new WorkerClient<MyRequest, MyResponse, { progress: number }>({
42
+ * create: () => new Worker(new URL('./nlp.worker.ts', import.meta.url), { type: 'module' }),
43
+ * });
44
+ * const loaded = await client.send({ type: 'load', modelId }, (p) => render(p.progress));
45
+ * client.dispose();
46
+ * ```
47
+ * The worker side only has to echo the `operationId` it received:
48
+ * ```ts
49
+ * self.onmessage = ({ data }) => self.postMessage({ operationId: data.operationId, type: 'result', ... });
50
+ * ```
51
+ */
52
+ export declare class WorkerClient<Req extends object, Res extends WorkerResponseBase, Progress = unknown> {
53
+ private worker;
54
+ private nextOperationId;
55
+ private pending;
56
+ private options;
57
+ constructor(options: WorkerClientOptions<Res, Progress>);
58
+ /** Whether the worker has been created (it is created on the first `send`) */
59
+ get active(): boolean;
60
+ /** Number of in-flight requests */
61
+ get pendingCount(): number;
62
+ /**
63
+ * @description: Send one request and await its matching response
64
+ * @param {Req} request request body (`operationId` is filled in by the client — do not pass it)
65
+ * @param {Function} onProgress progress callback, fired on progress messages without settling the request
66
+ * @param {Transferable[]} transfer objects whose ownership is transferred (ArrayBuffer and friends, avoiding the structured-clone copy)
67
+ * @return {Promise<Res>}
68
+ */
69
+ send: (request: Req, onProgress?: (progress: Progress) => void, transfer?: Transferable[]) => Promise<Res>;
70
+ /** @description: Terminate the worker and reject every in-flight request; the next `send` rebuilds it */
71
+ dispose: () => void;
72
+ private getWorker;
73
+ private settle;
74
+ private handleMessage;
75
+ private rejectAll;
76
+ }
@@ -0,0 +1,162 @@
1
+ /**
2
+ * A minimal ZIP reader and rewriter with no dependencies.
3
+ *
4
+ * ZIP is the container behind OOXML (docx/xlsx/pptx), EPUB, ODF and browser extensions, so
5
+ * "read one file out of this archive" and "patch one file inside this archive" come up
6
+ * constantly. A full ZIP library is a large dependency for that; the whole of the format
7
+ * these tasks need is the central directory plus DEFLATE, and DEFLATE now ships in the
8
+ * platform as `DecompressionStream`.
9
+ *
10
+ * Scope, stated plainly:
11
+ * - **Reads** STORED (method 0) and DEFLATE (method 8) entries. Other methods are reported
12
+ * but their data cannot be extracted.
13
+ * - **Writes** rewritten and injected entries as STORED — no recompression. The output is
14
+ * larger than the input, which is the right trade for a patch-and-hand-off pipeline and
15
+ * the wrong one for archiving.
16
+ * - **No ZIP64.** Archives over 4 GiB, or with more than 65535 entries, are out of scope.
17
+ * - **No encryption**, no multi-disk archives.
18
+ *
19
+ * Everything is `Uint8Array` in, `Uint8Array` out; nothing here touches the DOM.
20
+ */
21
+ /** Compression methods this module understands. */
22
+ export declare const ZIP_STORED = 0;
23
+ export declare const ZIP_DEFLATE = 8;
24
+ /**
25
+ * @description: CRC32 checksum (IEEE 802.3 polynomial), the one ZIP stores per entry.
26
+ * Returned as an unsigned 32-bit number.
27
+ * @param {Uint8Array} data
28
+ * @return {number}
29
+ */
30
+ export declare const crc32: (data: Uint8Array) => number;
31
+ /**
32
+ * @description: Decompress raw DEFLATE bytes (no zlib or gzip wrapper) — the form ZIP
33
+ * stores entries in — using the platform's `DecompressionStream`.
34
+ *
35
+ * Note the format: `'deflate-raw'`, not `'deflate'`. The latter expects a zlib header that
36
+ * ZIP entries do not carry, and feeding it entry bytes fails with an opaque
37
+ * `TypeError`.
38
+ *
39
+ * @param {Uint8Array} data raw DEFLATE bytes
40
+ * @return {Promise<Uint8Array>} the decompressed bytes
41
+ * @throws when `DecompressionStream` is unavailable or the data is corrupt
42
+ */
43
+ export declare const inflateRaw: (data: Uint8Array) => Promise<Uint8Array>;
44
+ /** One entry as described by the archive's central directory. */
45
+ export interface ZipEntry {
46
+ /** Path inside the archive, e.g. `word/document.xml`. Always `/`-separated. */
47
+ name: string;
48
+ /** `ZIP_STORED` (0) or `ZIP_DEFLATE` (8); other values are readable metadata only. */
49
+ compression: number;
50
+ crc: number;
51
+ compressedSize: number;
52
+ uncompressedSize: number;
53
+ /** MS-DOS packed time / date, carried through a rewrite unchanged. */
54
+ modTime: number;
55
+ modDate: number;
56
+ /** Whether the name ends in `/` — a directory marker with no content. */
57
+ directory: boolean;
58
+ /** Offset of the entry's compressed bytes in the source array. */
59
+ dataStart: number;
60
+ /** Name as stored, kept verbatim so a rewrite reproduces non-UTF-8 names byte for byte. */
61
+ nameBytes: Uint8Array;
62
+ localOffset: number;
63
+ centralStart: number;
64
+ centralEnd: number;
65
+ }
66
+ /**
67
+ * @description: Read an archive's central directory. Returns `[]` for anything that is not
68
+ * a ZIP, rather than throwing — the common caller is inspecting a file the user supplied.
69
+ *
70
+ * The central directory is the authority on an entry's sizes and CRC. The local header at
71
+ * the front of each entry may hold zeros instead: archives written by a streaming writer
72
+ * set general-purpose bit 3 and append the real values in a data descriptor *after* the
73
+ * compressed bytes. Reading sizes from local headers is the single most common way a
74
+ * hand-rolled ZIP reader breaks on real files.
75
+ *
76
+ * @param {Uint8Array} bytes the whole archive
77
+ * @return {ZipEntry[]} entries in central-directory order
78
+ */
79
+ export declare const readZipEntries: (bytes: Uint8Array) => ZipEntry[];
80
+ /**
81
+ * @description: Whether the archive contains an entry with exactly this name. Cheaper than
82
+ * `readZipEntries(bytes).some(...)` only in intent — use it to make the check read clearly.
83
+ * @param {Uint8Array} bytes
84
+ * @param {string} name exact path, e.g. `[Content_Types].xml`
85
+ * @return {boolean}
86
+ */
87
+ export declare const zipHasEntry: (bytes: Uint8Array, name: string) => boolean;
88
+ /**
89
+ * @description: Extract one entry's decompressed bytes. Resolves `null` when the entry is
90
+ * missing, is a directory, is truncated, or uses a compression method other than STORED
91
+ * and DEFLATE.
92
+ *
93
+ * @param {Uint8Array} bytes the whole archive
94
+ * @param {string | ZipEntry} entry entry name, or an entry from `readZipEntries`
95
+ * @return {Promise<Uint8Array | null>}
96
+ * @example
97
+ * ```ts
98
+ * const xml = await readZipEntry(docx, 'word/document.xml');
99
+ * if (xml) parse(new TextDecoder().decode(xml));
100
+ * ```
101
+ */
102
+ export declare const readZipEntry: (bytes: Uint8Array, entry: string | ZipEntry) => Promise<Uint8Array | null>;
103
+ export interface RewriteZipOptions {
104
+ /**
105
+ * Which entries to decompress and hand to `transform`. Omit to consider every file entry
106
+ * — costly on a large archive, since each candidate is decompressed.
107
+ */
108
+ filter?: (entry: ZipEntry) => boolean;
109
+ /**
110
+ * Produce replacement content for an entry. Return `null` (or the bytes unchanged) to
111
+ * leave it alone. A returned string is encoded as UTF-8, which is what XML entries want.
112
+ */
113
+ transform?: (data: Uint8Array, entry: ZipEntry) => Uint8Array | string | null | Promise<Uint8Array | string | null>;
114
+ /** Brand-new entries to append. An existing entry with the same name is not replaced. */
115
+ inject?: ReadonlyArray<{
116
+ name: string;
117
+ data: Uint8Array | string;
118
+ }>;
119
+ }
120
+ /**
121
+ * @description: Rebuild an archive with some entries replaced and/or new entries appended.
122
+ * Returns the **original array unchanged** when nothing matched, so the no-op path costs
123
+ * nothing and the result can be compared by identity.
124
+ *
125
+ * Rewritten and injected entries are written STORED (uncompressed); untouched entries keep
126
+ * their original compressed bytes, copied verbatim. The output is therefore bigger than the
127
+ * input but is produced without a compressor.
128
+ *
129
+ * Every local header is written fresh from the central directory's sizes and CRC, and
130
+ * general-purpose bit 3 is cleared throughout. That is what makes the result readable by
131
+ * strict parsers even when the input came from a streaming writer whose local headers hold
132
+ * zero placeholders backed by trailing data descriptors — copying those headers through is
133
+ * the standard way a rewritten ZIP ends up subtly corrupt.
134
+ *
135
+ * An entry whose transform throws, or whose compression method is unsupported, is left
136
+ * untouched rather than dropped: a rewrite must never lose data it failed to understand.
137
+ *
138
+ * @param {Uint8Array} bytes the whole archive
139
+ * @param {RewriteZipOptions} options
140
+ * @return {Promise<Uint8Array>}
141
+ * @example
142
+ * ```ts
143
+ * // Rewrite every XML part, and add one new file.
144
+ * const patched = await rewriteZip(docx, {
145
+ * filter: (e) => e.name.endsWith('.xml'),
146
+ * transform: (data) => new TextDecoder().decode(data).replace(/&amp;#10;/g, '&#10;'),
147
+ * inject: [{ name: 'meta.json', data: JSON.stringify({ patched: true }) }],
148
+ * });
149
+ * ```
150
+ */
151
+ export declare const rewriteZip: (bytes: Uint8Array, options?: RewriteZipOptions) => Promise<Uint8Array>;
152
+ /**
153
+ * @description: Build a ZIP from scratch, every entry STORED. No compression, so this is
154
+ * for containers whose payload is already compressed (media, an OOXML bundle being
155
+ * assembled) rather than for shrinking anything.
156
+ * @param {ReadonlyArray<{ name: string; data: Uint8Array | string }>} files
157
+ * @return {Uint8Array}
158
+ */
159
+ export declare const createZip: (files: ReadonlyArray<{
160
+ name: string;
161
+ data: Uint8Array | string;
162
+ }>) => Uint8Array;
@@ -1,7 +1,7 @@
1
1
  import { init } from './init';
2
2
  import { addNS, h } from './h';
3
3
  import { vnode } from './vnode';
4
- import { Chain, create } from './chainDom';
4
+ import { Chain, create } from '@/utils/chain';
5
5
  import { htmlDomApi } from './htmlDomApi';
6
6
  import { modules } from './modules';
7
7
  import { attributesModule } from './modules/attributes';
@@ -1 +1 @@
1
- import{n as e}from"../../rolldown-runtime-I3TIJKkN.js";function t(e,t,n,o,r){return{sel:e,data:t,children:n,text:o,elm:r,key:void 0===t?void 0:t.key}}function n(e){if(o(e)){for(;e&&o(e);)e=r(e).parent;return e??null}return e.parentNode}function o(e){return 11===e.nodeType}function r(e,t){const n=e;return n.parent??=t??null,n.firstChildNode??=e.firstChild,n.lastChildNode??=e.lastChild,n}var i={createElement:function(e,t){return document.createElement(e,t)},createElementNS:function(e,t,n){return document.createElementNS(e,t,n)},createTextNode:function(e){return document.createTextNode(e)},createDocumentFragment:function(){return r(document.createDocumentFragment())},createComment:function(e){return document.createComment(e)},insertBefore:function(e,t,n){if(o(e)){let t=e;for(;t&&o(t);)t=r(t).parent;e=t??e}o(t)&&(t=r(t,e)),n&&o(n)&&(n=r(n).firstChildNode),e.insertBefore(t,n)},removeChild:function(e,t){e.removeChild(t)},appendChild:function(e,t){o(t)&&(t=r(t,e)),e.appendChild(t)},parentNode:n,nextSibling:function(e){if(o(e)){const t=r(e),o=n(t);if(o&&t.lastChildNode){const e=Array.from(o.childNodes);return e[e.indexOf(t.lastChildNode)+1]??null}return null}return e.nextSibling},tagName:function(e){return e.tagName},setTextContent:function(e,t){e.textContent=t},getTextContent:function(e){return e.textContent},isElement:function(e){return 1===e.nodeType},isText:function(e){return 3===e.nodeType},isComment:function(e){return 8===e.nodeType},isDocumentFragment:o},l=/* @__PURE__ */e({array:()=>s,isStr:()=>c,isVnode:()=>d,primitive:()=>a}),s=Array.isArray,c=e=>"string"==typeof e;function a(e){return"string"==typeof e||"number"==typeof e}function d(e){return!!e?.sel}function u(e,t){let n;const o=t.elm;let r=e.data&&e.data.attrs,i=t.data&&t.data.attrs;if((r||i)&&r!==i){for(n in r=r||{},i=i||{},i){const e=i[n];r[n]!==e&&(!0===e?o.setAttribute(n,""):!1===e?o.removeAttribute(n):120!==n.charCodeAt(0)?o.setAttribute(n,e):58===n.charCodeAt(3)?o.setAttributeNS("http://www.w3.org/XML/1998/namespace",n,e):58===n.charCodeAt(5)?o.setAttributeNS("http://www.w3.org/1999/xlink",n,e):o.setAttribute(n,`${e}`))}for(n in r)n in i||o.removeAttribute(n)}}var f={create:u,update:u};function m(e,t){let n,o;const r=t.elm;let i=e.data&&e.data.class,l=t.data&&t.data.class;if((i||l)&&i!==l){for(o in i=i||{},l=l||{},i)i[o]&&!Object.prototype.hasOwnProperty.call(l,o)&&r.classList.remove(o);for(o in l)n=l[o],n!==i[o]&&r.classList[n?"add":"remove"](o)}}var p={create:m,update:m};function v(e,t,n){if((e=>"function"==typeof e)(e))e.call(t,n,t);else if("object"==typeof e)for(let o=0;o<e.length;o++)v(e[o],t,n)}function h(e,t){const n=e.type,o=t.data&&t.data.on;o&&o[n]&&v(o[n],t,e)}function y(e,t){const n=e?.data?.on,o=e?.listener,r=e.elm,i=t?.data?.on,l=t&&t.elm;let s;if(n!==i){if(n&&o)if(i)for(s in n)i[s]||r.removeEventListener(s,o,!1);else for(s in n)r.removeEventListener(s,o,!1);if(i){const o=t.listener=e.listener||function e(t){h(t,e.vnode)};if(n)for(s in i)n[s]||l.addEventListener(s,o,!1);else for(s in i)l.addEventListener(s,o,!1)}}}var g={create:y,update:y,destroy:y};function C(e,t){let n,o,r;const i=t.elm;let l=e.data?e.data.props:void 0,s=t.data?t.data.props:void 0;if((l||s)&&l!==s)for(n in l=l||{},s=s||{},s)o=s[n],r=l[n],r===o||"value"===n&&i[n]===o||(i[n]=o)}var x={create:C,update:C},b=!1;function N(e,t){let n,o;const r=t.elm;let i=e.data.style,l=t.data.style;if((i||l)&&i!==l){for(o in i=i||{},l=l||{},i)l[o]||("-"===o[0]&&"-"===o[1]?r.style.removeProperty(o):r.style[o]="");for(o in l)n=l[o],n!==i[o]&&("-"===o[0]&&"-"===o[1]?r.style.setProperty(o,n):r.style[o]=n)}}var A={pre:function(){b=!1},create:N,update:N,destroy:function(e){let t,n;const o=e.elm,r=e.data.style;if(r&&(t=r.destroy))for(n in t)o.style[n]=t[n]},remove:function(e,t){const n=e.data.style;if(!n||!n.remove)return void t();let o;b||(b=!0);const r=e.elm;let i=0;const l=n.remove;let s=0;const c=[];for(o in l)c.push(o),r.style[o]=l[o];const a=getComputedStyle(r)["transition-property"].split(", ");for(;i<a.length;++i)-1!==c.indexOf(a[i])&&s++;r.addEventListener("transitionend",function(e){e.target===r&&--s,0===s&&t()})}},w={attributesModule:f,classModule:p,eventListenersModule:g,propsModule:x,styleModule:A};function E(e,t){return e.key===t.key&&e.sel===t.sel}function T(e,t,n){const o={};for(let r=t;r<=n;++r){const t=e[r]?.key;void 0!==t&&(o[t]=r)}return o}var L=t("",{},[],void 0,void 0);function S(){const e=i,n={create:[],update:[],destroy:[]};for(const t of Object.keys(n)){n[t]=[];for(const e of Object.keys(w)){const o=w[e][t];void 0!==o&&n[t].push(o)}}function o(n){const o=n.id?"#"+n.id:"",r=n.className?"."+n.className.split(" ").join("."):"";return t(e.tagName(n).toLowerCase()+o+r,{},[],void 0,n)}function r(e){return void 0===e}function l(e){return void 0!==e}function c(t){let o;const i=t.children,l=t.sel;if("!"===l)r(t.text)&&(t.text=""),t.elm=e.createComment(`${t.text}`);else if(void 0!==l){const r=l.indexOf("#"),d=l.indexOf(".",r),u=r>0?r:l.length,f=d>0?d:l.length,m=-1!==r||-1!==d?l.slice(0,Math.min(u,f)):l,p=t.elm=e.createElement(m);for(u<f&&p.setAttribute("id",l.slice(u+1,f)),d>0&&p.setAttribute("class",l.slice(f+1).replace(/\./g," ")),o=0;o<n.create.length;++o)n.create[o](L,t);if(s(i))for(o=0;o<i.length;++o){const t=i[o];null!=t&&e.appendChild(p,c(t))}else a(t.text)&&e.appendChild(p,e.createTextNode(`${t.text}`))}else t.elm=e.createTextNode(`${t.text}`);return t.elm}function d(e){if(void 0!==e.data){for(let t=0;t<n.destroy.length;++t)n.destroy[t](e);if(void 0!==e.children)for(let t=0;t<e.children.length;++t){const n=e.children[t];null!=n&&"string"!=typeof n&&"number"!=typeof n&&d(n)}}}function u(t){return function(){const n=e.parentNode(t);e.removeChild(n,t)}}function f(t,n,o,r){for(;o<=r;++o){let r;const i=n[o];null!=i&&(l(i.sel)?(d(i),r=u(i.elm),r()):e.removeChild(t,i.elm))}}function m(t,n,o){let i,l,s,a,d=0,u=0,m=n.length-1,v=o.length-1,h=n[0],y=n[m],g=o[0],C=o[v];for(;d<=m&&u<=v;)null==h?h=n[++d]:null==y?y=n[--m]:null==g?g=o[++u]:null==C?C=o[--v]:E(h,g)?(p(h,g),h=n[++d],g=o[++u]):E(y,C)?(p(y,C),y=n[--m],C=o[--v]):E(h,C)?(p(h,C),e.insertBefore(t,h.elm,e.nextSibling(y.elm)),h=n[++d],C=o[--v]):E(y,g)?(p(y,g),e.insertBefore(t,y.elm,h.elm),y=n[--m],g=o[++u]):(void 0===i&&(i=T(n,d,m)),l=i[g.key],r(l)?e.insertBefore(t,c(g),h.elm):(s=n[l],s.sel!==g.sel?e.insertBefore(t,c(g),h.elm):(p(s,g),n[l]=void 0,e.insertBefore(t,s.elm,h.elm))),g=o[++u]);(d<=m||u<=v)&&(d>m?(a=null==o[v+1]?null:o[v+1].elm,function(t,n,o,r,i){for(;r<=i;++r){const i=o[r];null!=i&&e.insertBefore(t,c(i),n)}}(t,a,o,u,v)):f(t,n,d,m))}function p(e,t){if(void 0!==t.data)for(let r=0;r<n.update.length;++r)n.update[r](e,t);const o=t.elm=e.elm,i=e.children,s=t.children;e!==t&&r(t.text)&&l(i)&&l(s)&&i!==s&&m(o,i,s)}return function(t,n){let r,i;return function(e){return void 0!==e.sel}(t)||(t=o(t)),E(t,n)?p(t,n):(r=t.elm,i=e.parentNode(r),c(n),null!=i&&(e.insertBefore(i,n.elm,e.nextSibling(r)),f(i,[t],0,0))),n}}function k(e,t,n){if(e.ns="http://www.w3.org/2000/svg","foreignObject"!==n&&void 0!==t)for(let o=0;o<t.length;++o){const e=t[o];if("string"==typeof e||"number"==typeof e)continue;const n=e.data;void 0!==n&&k(n,e.children,e.sel)}}function B(e,n,o){let r,i,l,c={};if(void 0!==o?(null!=n&&(c=n),s(o)?r=o:a(o)?i=o:o&&o.sel&&(r=[o])):void 0!==n&&null!=n&&(s(n)?r=n:a(n)?i=n:d(n)?r=[n]:c=n),void 0!==r)for(l=0;l<r.length;++l){const e=r[l];a(e)&&(r[l]=t(void 0,void 0,void 0,e,void 0))}return"s"!==e[0]||"v"!==e[1]||"g"!==e[2]||3!==e.length&&"."!==e[3]&&"#"!==e[3]||k(c,r,e),t(e,c,r,i,void 0)}var O=class{element;constructor(e,t){this.element=this.create(e,t)}create=(e,t)=>document.createElement(e,t);setAttribute=(e,t)=>(this.element.setAttribute(e,t),this);removeAttribute=e=>(this.element.removeAttribute(e),this);append=e=>(this.element.appendChild(e),this);remove=e=>(this.element.removeChild(e),this);setTextContent=e=>(this.element.textContent=e,this)},j=(e,t)=>new O(e,t);export{O as Chain,k as addNS,f as attributesModule,p as classModule,j as create,g as eventListenersModule,B as h,i as htmlDomApi,S as init,l as is,w as modules,x as propsModule,A as styleModule,t as vnode};
1
+ import{n as e}from"../../rolldown-runtime-I3TIJKkN.js";import{n as t,t as n}from"../../chain-CTywmh_H.js";function o(e,t,n,o,r){return{sel:e,data:t,children:n,text:o,elm:r,key:void 0===t?void 0:t.key}}function r(e){if(i(e)){for(;e&&i(e);)e=l(e).parent;return e??null}return e.parentNode}function i(e){return 11===e.nodeType}function l(e,t){const n=e;return n.parent??=t??null,n.firstChildNode??=e.firstChild,n.lastChildNode??=e.lastChild,n}var s={createElement:function(e,t){return document.createElement(e,t)},createElementNS:function(e,t,n){return document.createElementNS(e,t,n)},createTextNode:function(e){return document.createTextNode(e)},createDocumentFragment:function(){return l(document.createDocumentFragment())},createComment:function(e){return document.createComment(e)},insertBefore:function(e,t,n){if(i(e)){let t=e;for(;t&&i(t);)t=l(t).parent;e=t??e}i(t)&&(t=l(t,e)),n&&i(n)&&(n=l(n).firstChildNode),e.insertBefore(t,n)},removeChild:function(e,t){e.removeChild(t)},appendChild:function(e,t){i(t)&&(t=l(t,e)),e.appendChild(t)},parentNode:r,nextSibling:function(e){if(i(e)){const t=l(e),n=r(t);if(n&&t.lastChildNode){const e=Array.from(n.childNodes);return e[e.indexOf(t.lastChildNode)+1]??null}return null}return e.nextSibling},tagName:function(e){return e.tagName},setTextContent:function(e,t){e.textContent=t},getTextContent:function(e){return e.textContent},isElement:function(e){return 1===e.nodeType},isText:function(e){return 3===e.nodeType},isComment:function(e){return 8===e.nodeType},isDocumentFragment:i},a=/* @__PURE__ */e({array:()=>c,isStr:()=>d,isVnode:()=>f,primitive:()=>u}),c=Array.isArray,d=e=>"string"==typeof e;function u(e){return"string"==typeof e||"number"==typeof e}function f(e){return!!e?.sel}function m(e,t){let n;const o=t.elm;let r=e.data&&e.data.attrs,i=t.data&&t.data.attrs;if((r||i)&&r!==i){for(n in r=r||{},i=i||{},i){const e=i[n];r[n]!==e&&(!0===e?o.setAttribute(n,""):!1===e?o.removeAttribute(n):120!==n.charCodeAt(0)?o.setAttribute(n,e):58===n.charCodeAt(3)?o.setAttributeNS("http://www.w3.org/XML/1998/namespace",n,e):58===n.charCodeAt(5)?o.setAttributeNS("http://www.w3.org/1999/xlink",n,e):o.setAttribute(n,`${e}`))}for(n in r)n in i||o.removeAttribute(n)}}var p={create:m,update:m};function v(e,t){let n,o;const r=t.elm;let i=e.data&&e.data.class,l=t.data&&t.data.class;if((i||l)&&i!==l){for(o in i=i||{},l=l||{},i)i[o]&&!Object.prototype.hasOwnProperty.call(l,o)&&r.classList.remove(o);for(o in l)n=l[o],n!==i[o]&&r.classList[n?"add":"remove"](o)}}var h={create:v,update:v};function y(e,t,n){if((e=>"function"==typeof e)(e))e.call(t,n,t);else if("object"==typeof e)for(let o=0;o<e.length;o++)y(e[o],t,n)}function g(e,t){const n=e.type,o=t.data&&t.data.on;o&&o[n]&&y(o[n],t,e)}function C(e,t){const n=e?.data?.on,o=e?.listener,r=e.elm,i=t?.data?.on,l=t&&t.elm;let s;if(n!==i){if(n&&o)if(i)for(s in n)i[s]||r.removeEventListener(s,o,!1);else for(s in n)r.removeEventListener(s,o,!1);if(i){const o=t.listener=e.listener||function e(t){g(t,e.vnode)};if(n)for(s in i)n[s]||l.addEventListener(s,o,!1);else for(s in i)l.addEventListener(s,o,!1)}}}var x={create:C,update:C,destroy:C};function N(e,t){let n,o,r;const i=t.elm;let l=e.data?e.data.props:void 0,s=t.data?t.data.props:void 0;if((l||s)&&l!==s)for(n in l=l||{},s=s||{},s)o=s[n],r=l[n],r===o||"value"===n&&i[n]===o||(i[n]=o)}var b={create:N,update:N},w=!1;function A(e,t){let n,o;const r=t.elm;let i=e.data.style,l=t.data.style;if((i||l)&&i!==l){for(o in i=i||{},l=l||{},i)l[o]||("-"===o[0]&&"-"===o[1]?r.style.removeProperty(o):r.style[o]="");for(o in l)n=l[o],n!==i[o]&&("-"===o[0]&&"-"===o[1]?r.style.setProperty(o,n):r.style[o]=n)}}var E={pre:function(){w=!1},create:A,update:A,destroy:function(e){let t,n;const o=e.elm,r=e.data.style;if(r&&(t=r.destroy))for(n in t)o.style[n]=t[n]},remove:function(e,t){const n=e.data.style;if(!n||!n.remove)return void t();let o;w||(w=!0);const r=e.elm;let i=0;const l=n.remove;let s=0;const a=[];for(o in l)a.push(o),r.style[o]=l[o];const c=getComputedStyle(r)["transition-property"].split(", ");for(;i<c.length;++i)-1!==a.indexOf(c[i])&&s++;r.addEventListener("transitionend",function(e){e.target===r&&--s,0===s&&t()})}},T={attributesModule:p,classModule:h,eventListenersModule:x,propsModule:b,styleModule:E};function L(e,t){return e.key===t.key&&e.sel===t.sel}function S(e,t,n){const o={};for(let r=t;r<=n;++r){const t=e[r]?.key;void 0!==t&&(o[t]=r)}return o}var k=o("",{},[],void 0,void 0);function B(){const e=s,t={create:[],update:[],destroy:[]};for(const o of Object.keys(t)){t[o]=[];for(const e of Object.keys(T)){const n=T[e][o];void 0!==n&&t[o].push(n)}}function n(t){const n=t.id?"#"+t.id:"",r=t.className?"."+t.className.split(" ").join("."):"";return o(e.tagName(t).toLowerCase()+n+r,{},[],void 0,t)}function r(e){return void 0===e}function i(e){return void 0!==e}function l(n){let o;const i=n.children,s=n.sel;if("!"===s)r(n.text)&&(n.text=""),n.elm=e.createComment(`${n.text}`);else if(void 0!==s){const r=s.indexOf("#"),a=s.indexOf(".",r),d=r>0?r:s.length,f=a>0?a:s.length,m=-1!==r||-1!==a?s.slice(0,Math.min(d,f)):s,p=n.elm=e.createElement(m);for(d<f&&p.setAttribute("id",s.slice(d+1,f)),a>0&&p.setAttribute("class",s.slice(f+1).replace(/\./g," ")),o=0;o<t.create.length;++o)t.create[o](k,n);if(c(i))for(o=0;o<i.length;++o){const t=i[o];null!=t&&e.appendChild(p,l(t))}else u(n.text)&&e.appendChild(p,e.createTextNode(`${n.text}`))}else n.elm=e.createTextNode(`${n.text}`);return n.elm}function a(e){if(void 0!==e.data){for(let n=0;n<t.destroy.length;++n)t.destroy[n](e);if(void 0!==e.children)for(let t=0;t<e.children.length;++t){const n=e.children[t];null!=n&&"string"!=typeof n&&"number"!=typeof n&&a(n)}}}function d(t){return function(){const n=e.parentNode(t);e.removeChild(n,t)}}function f(t,n,o,r){for(;o<=r;++o){let r;const l=n[o];null!=l&&(i(l.sel)?(a(l),r=d(l.elm),r()):e.removeChild(t,l.elm))}}function m(t,n,o){let i,s,a,c,d=0,u=0,m=n.length-1,v=o.length-1,h=n[0],y=n[m],g=o[0],C=o[v];for(;d<=m&&u<=v;)null==h?h=n[++d]:null==y?y=n[--m]:null==g?g=o[++u]:null==C?C=o[--v]:L(h,g)?(p(h,g),h=n[++d],g=o[++u]):L(y,C)?(p(y,C),y=n[--m],C=o[--v]):L(h,C)?(p(h,C),e.insertBefore(t,h.elm,e.nextSibling(y.elm)),h=n[++d],C=o[--v]):L(y,g)?(p(y,g),e.insertBefore(t,y.elm,h.elm),y=n[--m],g=o[++u]):(void 0===i&&(i=S(n,d,m)),s=i[g.key],r(s)?e.insertBefore(t,l(g),h.elm):(a=n[s],a.sel!==g.sel?e.insertBefore(t,l(g),h.elm):(p(a,g),n[s]=void 0,e.insertBefore(t,a.elm,h.elm))),g=o[++u]);(d<=m||u<=v)&&(d>m?(c=null==o[v+1]?null:o[v+1].elm,function(t,n,o,r,i){for(;r<=i;++r){const i=o[r];null!=i&&e.insertBefore(t,l(i),n)}}(t,c,o,u,v)):f(t,n,d,m))}function p(e,n){if(void 0!==n.data)for(let r=0;r<t.update.length;++r)t.update[r](e,n);const o=n.elm=e.elm,l=e.children,s=n.children;e!==n&&r(n.text)&&i(l)&&i(s)&&l!==s&&m(o,l,s)}return function(t,o){let r,i;return function(e){return void 0!==e.sel}(t)||(t=n(t)),L(t,o)?p(t,o):(r=t.elm,i=e.parentNode(r),l(o),null!=i&&(e.insertBefore(i,o.elm,e.nextSibling(r)),f(i,[t],0,0))),o}}function O(e,t,n){if(e.ns="http://www.w3.org/2000/svg","foreignObject"!==n&&void 0!==t)for(let o=0;o<t.length;++o){const e=t[o];if("string"==typeof e||"number"==typeof e)continue;const n=e.data;void 0!==n&&O(n,e.children,e.sel)}}function j(e,t,n){let r,i,l,s={};if(void 0!==n?(null!=t&&(s=t),c(n)?r=n:u(n)?i=n:n&&n.sel&&(r=[n])):void 0!==t&&null!=t&&(c(t)?r=t:u(t)?i=t:f(t)?r=[t]:s=t),void 0!==r)for(l=0;l<r.length;++l){const e=r[l];u(e)&&(r[l]=o(void 0,void 0,void 0,e,void 0))}return"s"!==e[0]||"v"!==e[1]||"g"!==e[2]||3!==e.length&&"."!==e[3]&&"#"!==e[3]||O(s,r,e),o(e,s,r,i,void 0)}export{n as Chain,O as addNS,p as attributesModule,h as classModule,t as create,x as eventListenersModule,j as h,s as htmlDomApi,B as init,a as is,T as modules,b as propsModule,E as styleModule,o as vnode};
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @description: Type guards — array / string / primitive / VNode
3
+ * @module
4
+ */
1
5
  import type { VNode } from './vnode';
2
6
  export declare const array: (arg: any) => arg is any[];
3
7
  export declare const isStr: (str: unknown) => str is string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};