kiru 0.48.3 → 0.49.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 (236) hide show
  1. package/dist/action.d.ts +22 -0
  2. package/dist/action.d.ts.map +1 -0
  3. package/dist/action.js +20 -0
  4. package/dist/action.js.map +1 -0
  5. package/dist/components/index.d.ts +5 -0
  6. package/dist/components/index.d.ts.map +1 -0
  7. package/dist/components/index.js +5 -0
  8. package/dist/components/index.js.map +1 -0
  9. package/dist/components/lazy.d.ts.map +1 -0
  10. package/dist/{lazy.js → components/lazy.js} +11 -11
  11. package/dist/components/lazy.js.map +1 -0
  12. package/dist/{memo.d.ts → components/memo.d.ts} +1 -1
  13. package/dist/components/memo.d.ts.map +1 -0
  14. package/dist/{memo.js → components/memo.js} +2 -2
  15. package/dist/components/memo.js.map +1 -0
  16. package/dist/components/portal.d.ts.map +1 -0
  17. package/dist/{portal.js → components/portal.js} +6 -6
  18. package/dist/components/portal.js.map +1 -0
  19. package/dist/components/router/index.d.ts.map +1 -0
  20. package/dist/components/router/index.js.map +1 -0
  21. package/dist/components/router/route.d.ts.map +1 -0
  22. package/dist/{router → components/router}/route.js +1 -1
  23. package/dist/components/router/route.js.map +1 -0
  24. package/dist/{router → components/router}/router.d.ts +1 -1
  25. package/dist/components/router/router.d.ts.map +1 -0
  26. package/dist/{router → components/router}/router.js +8 -8
  27. package/dist/components/router/router.js.map +1 -0
  28. package/dist/components/router/routerUtils.d.ts.map +1 -0
  29. package/dist/components/router/routerUtils.js.map +1 -0
  30. package/dist/components/transition.d.ts.map +1 -0
  31. package/dist/{transition.js → components/transition.js} +5 -5
  32. package/dist/components/transition.js.map +1 -0
  33. package/dist/constants.d.ts +2 -1
  34. package/dist/constants.d.ts.map +1 -1
  35. package/dist/constants.js +79 -1
  36. package/dist/constants.js.map +1 -1
  37. package/dist/context.js +1 -1
  38. package/dist/context.js.map +1 -1
  39. package/dist/dom.d.ts.map +1 -1
  40. package/dist/dom.js +8 -9
  41. package/dist/dom.js.map +1 -1
  42. package/dist/element.js +2 -2
  43. package/dist/element.js.map +1 -1
  44. package/dist/error.js +1 -1
  45. package/dist/error.js.map +1 -1
  46. package/dist/form/index.d.ts.map +1 -1
  47. package/dist/form/index.js +1 -2
  48. package/dist/form/index.js.map +1 -1
  49. package/dist/hmr.js +1 -1
  50. package/dist/hmr.js.map +1 -1
  51. package/dist/hooks/useAsync.d.ts.map +1 -1
  52. package/dist/hooks/useAsync.js +2 -2
  53. package/dist/hooks/useAsync.js.map +1 -1
  54. package/dist/hooks/useCallback.d.ts.map +1 -1
  55. package/dist/hooks/useCallback.js +2 -1
  56. package/dist/hooks/useCallback.js.map +1 -1
  57. package/dist/hooks/useEffect.d.ts.map +1 -1
  58. package/dist/hooks/useEffect.js +2 -1
  59. package/dist/hooks/useEffect.js.map +1 -1
  60. package/dist/hooks/useEffectEvent.d.ts.map +1 -1
  61. package/dist/hooks/useEffectEvent.js +2 -1
  62. package/dist/hooks/useEffectEvent.js.map +1 -1
  63. package/dist/hooks/useLayoutEffect.d.ts.map +1 -1
  64. package/dist/hooks/useLayoutEffect.js +2 -1
  65. package/dist/hooks/useLayoutEffect.js.map +1 -1
  66. package/dist/hooks/useMemo.d.ts.map +1 -1
  67. package/dist/hooks/useMemo.js +2 -1
  68. package/dist/hooks/useMemo.js.map +1 -1
  69. package/dist/hooks/useReducer.js +2 -2
  70. package/dist/hooks/useReducer.js.map +1 -1
  71. package/dist/hooks/useRef.d.ts.map +1 -1
  72. package/dist/hooks/useRef.js +2 -1
  73. package/dist/hooks/useRef.js.map +1 -1
  74. package/dist/hooks/useState.js +2 -2
  75. package/dist/hooks/useState.js.map +1 -1
  76. package/dist/hooks/useSyncExternalStore.js +2 -2
  77. package/dist/hooks/useSyncExternalStore.js.map +1 -1
  78. package/dist/hooks/useViewTransition.d.ts.map +1 -1
  79. package/dist/hooks/useViewTransition.js +1 -2
  80. package/dist/hooks/useViewTransition.js.map +1 -1
  81. package/dist/hooks/utils.d.ts +0 -1
  82. package/dist/hooks/utils.d.ts.map +1 -1
  83. package/dist/hooks/utils.js +1 -2
  84. package/dist/hooks/utils.js.map +1 -1
  85. package/dist/index.d.ts +2 -5
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +2 -5
  88. package/dist/index.js.map +1 -1
  89. package/dist/reconciler.js +8 -7
  90. package/dist/reconciler.js.map +1 -1
  91. package/dist/renderToString.js +1 -2
  92. package/dist/renderToString.js.map +1 -1
  93. package/dist/scheduler.js +2 -2
  94. package/dist/scheduler.js.map +1 -1
  95. package/dist/signals/base.d.ts.map +1 -1
  96. package/dist/signals/base.js +1 -2
  97. package/dist/signals/base.js.map +1 -1
  98. package/dist/signals/computed.js +1 -1
  99. package/dist/signals/computed.js.map +1 -1
  100. package/dist/signals/effect.js +1 -1
  101. package/dist/signals/effect.js.map +1 -1
  102. package/dist/signals/watch.d.ts.map +1 -1
  103. package/dist/signals/watch.js +2 -3
  104. package/dist/signals/watch.js.map +1 -1
  105. package/dist/ssr/server.js +1 -2
  106. package/dist/ssr/server.js.map +1 -1
  107. package/dist/store.d.ts +1 -1
  108. package/dist/store.d.ts.map +1 -1
  109. package/dist/store.js +2 -2
  110. package/dist/store.js.map +1 -1
  111. package/dist/swr.js +1 -1
  112. package/dist/swr.js.map +1 -1
  113. package/dist/types.d.ts +4 -3
  114. package/dist/types.d.ts.map +1 -1
  115. package/dist/types.dom.d.ts +2 -2
  116. package/dist/types.dom.d.ts.map +1 -1
  117. package/dist/utils/compare.d.ts +3 -0
  118. package/dist/utils/compare.d.ts.map +1 -0
  119. package/dist/utils/compare.js +123 -0
  120. package/dist/utils/compare.js.map +1 -0
  121. package/dist/utils/format.d.ts +20 -0
  122. package/dist/utils/format.d.ts.map +1 -0
  123. package/dist/utils/format.js +129 -0
  124. package/dist/utils/format.js.map +1 -0
  125. package/dist/utils/generateId.d.ts.map +1 -0
  126. package/dist/utils/generateId.js.map +1 -0
  127. package/dist/utils/index.d.ts +7 -0
  128. package/dist/utils/index.d.ts.map +1 -0
  129. package/dist/utils/index.js +7 -0
  130. package/dist/utils/index.js.map +1 -0
  131. package/dist/utils/runtime.d.ts +11 -0
  132. package/dist/utils/runtime.d.ts.map +1 -0
  133. package/dist/utils/runtime.js +23 -0
  134. package/dist/utils/runtime.js.map +1 -0
  135. package/dist/utils/vdom.d.ts +25 -0
  136. package/dist/utils/vdom.d.ts.map +1 -0
  137. package/dist/utils/vdom.js +124 -0
  138. package/dist/utils/vdom.js.map +1 -0
  139. package/package.json +6 -6
  140. package/src/action.ts +42 -0
  141. package/src/components/index.ts +4 -0
  142. package/src/{lazy.ts → components/lazy.ts} +12 -12
  143. package/src/{memo.ts → components/memo.ts} +3 -3
  144. package/src/{portal.ts → components/portal.ts} +6 -6
  145. package/src/{router → components/router}/route.ts +1 -1
  146. package/src/{router → components/router}/router.ts +9 -9
  147. package/src/{transition.ts → components/transition.ts} +5 -5
  148. package/src/constants.ts +80 -1
  149. package/src/context.ts +1 -1
  150. package/src/customEvents.ts +22 -22
  151. package/src/dom.ts +7 -8
  152. package/src/element.ts +2 -2
  153. package/src/error.ts +1 -1
  154. package/src/form/index.ts +5 -2
  155. package/src/hmr.ts +1 -1
  156. package/src/hooks/useAsync.ts +5 -3
  157. package/src/hooks/useCallback.ts +2 -1
  158. package/src/hooks/useEffect.ts +2 -6
  159. package/src/hooks/useEffectEvent.ts +2 -1
  160. package/src/hooks/useLayoutEffect.ts +2 -6
  161. package/src/hooks/useMemo.ts +2 -1
  162. package/src/hooks/useReducer.ts +2 -2
  163. package/src/hooks/useRef.ts +2 -1
  164. package/src/hooks/useState.ts +2 -2
  165. package/src/hooks/useSyncExternalStore.ts +2 -2
  166. package/src/hooks/useViewTransition.ts +1 -2
  167. package/src/hooks/utils.ts +1 -2
  168. package/src/index.ts +2 -5
  169. package/src/reconciler.ts +13 -11
  170. package/src/renderToString.ts +2 -2
  171. package/src/scheduler.ts +2 -2
  172. package/src/signals/base.ts +6 -2
  173. package/src/signals/computed.ts +1 -1
  174. package/src/signals/effect.ts +1 -1
  175. package/src/signals/watch.ts +2 -3
  176. package/src/ssr/server.ts +2 -2
  177. package/src/store.ts +6 -2
  178. package/src/swr.ts +3 -3
  179. package/src/types.dom.ts +2 -1
  180. package/src/types.ts +9 -2
  181. package/src/utils/compare.ts +125 -0
  182. package/src/utils/format.ts +158 -0
  183. package/src/utils/index.ts +7 -0
  184. package/src/utils/runtime.ts +25 -0
  185. package/src/utils/vdom.ts +184 -0
  186. package/dist/cloneVNode.d.ts +0 -2
  187. package/dist/cloneVNode.d.ts.map +0 -1
  188. package/dist/cloneVNode.js +0 -14
  189. package/dist/cloneVNode.js.map +0 -1
  190. package/dist/generateId.d.ts.map +0 -1
  191. package/dist/generateId.js.map +0 -1
  192. package/dist/lazy.d.ts.map +0 -1
  193. package/dist/lazy.js.map +0 -1
  194. package/dist/memo.d.ts.map +0 -1
  195. package/dist/memo.js.map +0 -1
  196. package/dist/portal.d.ts.map +0 -1
  197. package/dist/portal.js.map +0 -1
  198. package/dist/props.d.ts +0 -4
  199. package/dist/props.d.ts.map +0 -1
  200. package/dist/props.js +0 -27
  201. package/dist/props.js.map +0 -1
  202. package/dist/router/index.d.ts.map +0 -1
  203. package/dist/router/index.js.map +0 -1
  204. package/dist/router/route.d.ts.map +0 -1
  205. package/dist/router/route.js.map +0 -1
  206. package/dist/router/router.d.ts.map +0 -1
  207. package/dist/router/router.js.map +0 -1
  208. package/dist/router/routerUtils.d.ts.map +0 -1
  209. package/dist/router/routerUtils.js.map +0 -1
  210. package/dist/transition.d.ts.map +0 -1
  211. package/dist/transition.js.map +0 -1
  212. package/dist/utils.d.ts +0 -52
  213. package/dist/utils.d.ts.map +0 -1
  214. package/dist/utils.js +0 -433
  215. package/dist/utils.js.map +0 -1
  216. package/dist/warning.d.ts +0 -2
  217. package/dist/warning.d.ts.map +0 -1
  218. package/dist/warning.js +0 -4
  219. package/dist/warning.js.map +0 -1
  220. package/src/cloneVNode.ts +0 -14
  221. package/src/props.ts +0 -34
  222. package/src/utils.ts +0 -518
  223. package/src/warning.ts +0 -9
  224. /package/dist/{lazy.d.ts → components/lazy.d.ts} +0 -0
  225. /package/dist/{portal.d.ts → components/portal.d.ts} +0 -0
  226. /package/dist/{router → components/router}/index.d.ts +0 -0
  227. /package/dist/{router → components/router}/index.js +0 -0
  228. /package/dist/{router → components/router}/route.d.ts +0 -0
  229. /package/dist/{router → components/router}/routerUtils.d.ts +0 -0
  230. /package/dist/{router → components/router}/routerUtils.js +0 -0
  231. /package/dist/{transition.d.ts → components/transition.d.ts} +0 -0
  232. /package/dist/{generateId.d.ts → utils/generateId.d.ts} +0 -0
  233. /package/dist/{generateId.js → utils/generateId.js} +0 -0
  234. /package/src/{router → components/router}/index.ts +0 -0
  235. /package/src/{router → components/router}/routerUtils.ts +0 -0
  236. /package/src/{generateId.ts → utils/generateId.ts} +0 -0
package/src/utils.ts DELETED
@@ -1,518 +0,0 @@
1
- import { node, renderMode } from "./globals.js"
2
- import {
3
- $CONTEXT_PROVIDER,
4
- $FRAGMENT,
5
- $HYDRATION_BOUNDARY,
6
- booleanAttributes,
7
- FLAG_DELETION,
8
- FLAG_PLACEMENT,
9
- FLAG_UPDATE,
10
- REGEX_UNIT,
11
- } from "./constants.js"
12
- import { unwrap } from "./signals/utils.js"
13
- import { __DEV__ } from "./env.js"
14
- import type { AppContext } from "./appContext"
15
-
16
- export {
17
- isVNode,
18
- isFragment,
19
- isLazy,
20
- isMemo,
21
- className,
22
- isContextProvider,
23
- isExoticType,
24
- isVNodeDeleted,
25
- vNodeContains,
26
- getCurrentVNode,
27
- getVNodeAppContext,
28
- commitSnapshot,
29
- traverseApply,
30
- findParent,
31
- propToHtmlAttr,
32
- propValueToHtmlAttrValue,
33
- propsToElementAttributes,
34
- styleObjectToString,
35
- shallowCompare,
36
- deepCompare,
37
- sideEffectsEnabled,
38
- encodeHtmlEntities,
39
- noop,
40
- latest,
41
- propFilters,
42
- safeStringify,
43
- }
44
-
45
- type VNode = Kiru.VNode
46
-
47
- const noop: () => void = Object.freeze(() => {})
48
-
49
- function className(...classes: (string | false | undefined)[]): string {
50
- return classes.filter(Boolean).join(" ")
51
- }
52
-
53
- /**
54
- * This is a no-op in production. It is used to get the latest
55
- * iteration of a component or signal after HMR has happened.
56
- */
57
- function latest<T>(thing: T): T {
58
- let tgt: any = thing
59
- if (__DEV__) {
60
- while ("__next" in tgt) {
61
- tgt = tgt.__next as typeof tgt
62
- }
63
- }
64
- return tgt
65
- }
66
-
67
- /**
68
- * Returns false if called during "stream" or "string" render modes.
69
- */
70
- function sideEffectsEnabled(): boolean {
71
- return renderMode.current === "dom" || renderMode.current === "hydrate"
72
- }
73
-
74
- function isVNodeDeleted(vNode: VNode): boolean {
75
- return (vNode.flags & FLAG_DELETION) !== 0
76
- }
77
-
78
- function isVNode(thing: unknown): thing is VNode {
79
- return typeof thing === "object" && thing !== null && "type" in thing
80
- }
81
-
82
- function isExoticType(type: VNode["type"]): type is Kiru.ExoticSymbol {
83
- return (
84
- type === $FRAGMENT ||
85
- type === $CONTEXT_PROVIDER ||
86
- type === $HYDRATION_BOUNDARY
87
- )
88
- }
89
-
90
- function isFragment(vNode: VNode): vNode is VNode & { type: typeof $FRAGMENT } {
91
- return vNode.type === $FRAGMENT
92
- }
93
-
94
- function isLazy(vNode: VNode): boolean {
95
- return (
96
- typeof vNode.type === "function" &&
97
- "displayName" in vNode.type &&
98
- vNode.type.displayName === "Kiru.lazy"
99
- )
100
- }
101
-
102
- function isMemo(vNode: Kiru.VNode): boolean {
103
- return (
104
- typeof vNode.type === "function" &&
105
- "displayName" in vNode.type &&
106
- vNode.type.displayName === "Kiru.memo"
107
- )
108
- }
109
-
110
- function isContextProvider(
111
- thing: unknown
112
- ): thing is VNode & { type: typeof $CONTEXT_PROVIDER } {
113
- return isVNode(thing) && thing.type === $CONTEXT_PROVIDER
114
- }
115
-
116
- function getCurrentVNode(): VNode | null {
117
- return node.current
118
- }
119
-
120
- function getVNodeAppContext(vNode: VNode): AppContext | null {
121
- let n: VNode | null = vNode
122
- while (n) {
123
- if (n.app) {
124
- return (vNode.app = n.app)
125
- }
126
- n = n.parent
127
- }
128
-
129
- return null
130
- }
131
-
132
- function commitSnapshot(vNode: VNode): void {
133
- const {
134
- props: { children, ...props },
135
- memoizedProps,
136
- index,
137
- } = vNode
138
- vNode.prev = { props, memoizedProps, index }
139
- vNode.flags &= ~(FLAG_UPDATE | FLAG_PLACEMENT | FLAG_DELETION)
140
- }
141
-
142
- function vNodeContains(haystack: VNode, needle: VNode): boolean {
143
- if (needle.depth < haystack.depth) return false
144
- if (haystack === needle) return true
145
- let checkSiblings = false
146
- const stack: VNode[] = [haystack]
147
- while (stack.length) {
148
- const n = stack.pop()!
149
- if (n === needle) return true
150
- n.child && stack.push(n.child)
151
- checkSiblings && n.sibling && stack.push(n.sibling)
152
- checkSiblings = true
153
- }
154
- return false
155
- }
156
-
157
- function traverseApply(vNode: VNode, func: (node: VNode) => void): void {
158
- func(vNode)
159
- let child = vNode.child
160
- while (child) {
161
- func(child)
162
- if (child.child) {
163
- traverseApply(child, func)
164
- }
165
- child = child.sibling
166
- }
167
- }
168
-
169
- function findParent(vNode: Kiru.VNode, predicate: (n: Kiru.VNode) => boolean) {
170
- let n: Kiru.VNode | null = vNode.parent
171
- while (n) {
172
- if (predicate(n)) return n
173
- n = n.parent
174
- }
175
- return null
176
- }
177
-
178
- function compare<T>(a: T, b: T, deep = false): boolean {
179
- // Fast path: identity comparison
180
- if (a === b) return true
181
-
182
- // Handle primitive types and null/undefined
183
- if (
184
- a == null ||
185
- b == null ||
186
- typeof a !== "object" ||
187
- typeof b !== "object"
188
- ) {
189
- return false
190
- }
191
-
192
- // Handle arrays efficiently
193
- if (Array.isArray(a) && Array.isArray(b)) {
194
- if (a.length !== b.length) return false
195
-
196
- if (deep) {
197
- for (let i = 0; i < a.length; i++) {
198
- if (!compare(a[i], b[i], true)) return false
199
- }
200
- } else {
201
- for (let i = 0; i < a.length; i++) {
202
- if (!Object.is(a[i], b[i])) return false
203
- }
204
- }
205
- return true
206
- }
207
-
208
- // Handle Maps
209
- if (a instanceof Map && b instanceof Map) {
210
- if (a.size !== b.size) return false
211
-
212
- for (const [key, valueA] of a) {
213
- if (!b.has(key)) return false
214
-
215
- const valueB = b.get(key)
216
- if (deep) {
217
- if (!compare(valueA, valueB, true)) return false
218
- } else {
219
- if (!Object.is(valueA, valueB)) return false
220
- }
221
- }
222
- return true
223
- }
224
-
225
- // Handle Sets more efficiently
226
- if (a instanceof Set && b instanceof Set) {
227
- if (a.size !== b.size) return false
228
-
229
- if (deep) {
230
- // For deep equality of Sets, we need to compare the values themselves
231
- // Convert to arrays and sort for comparison
232
- const aValues = Array.from(a)
233
- const bValues = Array.from(b)
234
-
235
- if (aValues.length !== bValues.length) return false
236
-
237
- // Simple compare doesn't work for objects in Sets with deep comparison
238
- // Using a matching algorithm instead
239
- for (const valueA of aValues) {
240
- // Find matching element in bValues
241
- let found = false
242
- for (let i = 0; i < bValues.length; i++) {
243
- if (compare(valueA, bValues[i], true)) {
244
- bValues.splice(i, 1) // Remove the matched element
245
- found = true
246
- break
247
- }
248
- }
249
- if (!found) return false
250
- }
251
- return true
252
- } else {
253
- // Regular Set comparison
254
- for (const valueA of a) {
255
- if (!b.has(valueA)) return false
256
- }
257
- return true
258
- }
259
- }
260
-
261
- // Handle Date objects
262
- if (a instanceof Date && b instanceof Date) {
263
- return a.getTime() === b.getTime()
264
- }
265
-
266
- // Handle RegExp objects
267
- if (a instanceof RegExp && b instanceof RegExp) {
268
- return a.toString() === b.toString()
269
- }
270
-
271
- // Handle plain objects
272
- const keysA = Object.keys(a)
273
- const keysB = Object.keys(b)
274
-
275
- if (keysA.length !== keysB.length) return false
276
-
277
- // Use a Set for faster key lookup
278
- const keySet = new Set(keysB)
279
-
280
- for (const key of keysA) {
281
- if (!keySet.has(key)) return false
282
-
283
- const valueA = a[key as keyof T]
284
- const valueB = b[key as keyof T]
285
-
286
- if (deep) {
287
- if (!compare(valueA, valueB, true)) return false
288
- } else {
289
- if (!Object.is(valueA, valueB)) return false
290
- }
291
- }
292
-
293
- return true
294
- }
295
-
296
- function deepCompare<T>(a: T, b: T): boolean {
297
- return compare(a, b, true)
298
- }
299
-
300
- function shallowCompare<T>(a: T, b: T): boolean {
301
- return compare(a, b, false)
302
- }
303
-
304
- function encodeHtmlEntities(text: string): string {
305
- return text
306
- .replace(REGEX_UNIT.AMP_G, "&amp;")
307
- .replace(REGEX_UNIT.LT_G, "&lt;")
308
- .replace(REGEX_UNIT.GT_G, "&gt;")
309
- .replace(REGEX_UNIT.DBLQT_G, "&quot;")
310
- .replace(REGEX_UNIT.SQT_G, "&#039;")
311
- .replace(REGEX_UNIT.SLASH_G, "&#47;")
312
- }
313
-
314
- const propFilters = {
315
- internalProps: ["children", "ref", "key", "innerHTML"],
316
- isEvent: (key: string) => key.startsWith("on"),
317
- isProperty: (key: string) =>
318
- !propFilters.internalProps.includes(key) && !propFilters.isEvent(key),
319
- }
320
-
321
- function propToHtmlAttr(key: string): string {
322
- switch (key) {
323
- case "className":
324
- return "class"
325
- case "htmlFor":
326
- return "for"
327
- case "tabIndex":
328
- case "formAction":
329
- case "formMethod":
330
- case "formEncType":
331
- case "contentEditable":
332
- case "spellCheck":
333
- case "allowFullScreen":
334
- case "autoPlay":
335
- case "disablePictureInPicture":
336
- case "disableRemotePlayback":
337
- case "formNoValidate":
338
- case "noModule":
339
- case "noValidate":
340
- case "popoverTarget":
341
- case "popoverTargetAction":
342
- case "playsInline":
343
- case "readOnly":
344
- case "itemscope":
345
- case "rowSpan":
346
- case "crossOrigin":
347
- return key.toLowerCase()
348
-
349
- default:
350
- if (key.indexOf("-") > -1) return key
351
- if (key.startsWith("aria"))
352
- return "aria-" + key.substring(4).toLowerCase()
353
-
354
- return snakeCaseAttrs.get(key) || key
355
- }
356
- }
357
-
358
- const snakeCaseAttrs = new Map([
359
- ["acceptCharset", "accept-charset"],
360
- ["accentHeight", "accent-height"],
361
- ["alignmentBaseline", "alignment-baseline"],
362
- ["arabicForm", "arabic-form"],
363
- ["baselineShift", "baseline-shift"],
364
- ["capHeight", "cap-height"],
365
- ["clipPath", "clip-path"],
366
- ["clipRule", "clip-rule"],
367
- ["colorInterpolation", "color-interpolation"],
368
- ["colorInterpolationFilters", "color-interpolation-filters"],
369
- ["colorProfile", "color-profile"],
370
- ["colorRendering", "color-rendering"],
371
- ["dominantBaseline", "dominant-baseline"],
372
- ["enableBackground", "enable-background"],
373
- ["fillOpacity", "fill-opacity"],
374
- ["fillRule", "fill-rule"],
375
- ["floodColor", "flood-color"],
376
- ["floodOpacity", "flood-opacity"],
377
- ["fontFamily", "font-family"],
378
- ["fontSize", "font-size"],
379
- ["fontSizeAdjust", "font-size-adjust"],
380
- ["fontStretch", "font-stretch"],
381
- ["fontStyle", "font-style"],
382
- ["fontVariant", "font-variant"],
383
- ["fontWeight", "font-weight"],
384
- ["glyphName", "glyph-name"],
385
- ["glyphOrientationHorizontal", "glyph-orientation-horizontal"],
386
- ["glyphOrientationVertical", "glyph-orientation-vertical"],
387
- ["horizAdvX", "horiz-adv-x"],
388
- ["horizOriginX", "horiz-origin-x"],
389
- ["httpEquiv", "http-equiv"],
390
- ["imageRendering", "image-rendering"],
391
- ["letterSpacing", "letter-spacing"],
392
- ["lightingColor", "lighting-color"],
393
- ["markerEnd", "marker-end"],
394
- ["markerMid", "marker-mid"],
395
- ["markerStart", "marker-start"],
396
- ["overlinePosition", "overline-position"],
397
- ["overlineThickness", "overline-thickness"],
398
- ["paintOrder", "paint-order"],
399
- ["panose-1", "panose-1"],
400
- ["pointerEvents", "pointer-events"],
401
- ["renderingIntent", "rendering-intent"],
402
- ["shapeRendering", "shape-rendering"],
403
- ["stopColor", "stop-color"],
404
- ["stopOpacity", "stop-opacity"],
405
- ["strikethroughPosition", "strikethrough-position"],
406
- ["strikethroughThickness", "strikethrough-thickness"],
407
- ["strokeDasharray", "stroke-dasharray"],
408
- ["strokeDashoffset", "stroke-dashoffset"],
409
- ["strokeLinecap", "stroke-linecap"],
410
- ["strokeLinejoin", "stroke-linejoin"],
411
- ["strokeMiterlimit", "stroke-miterlimit"],
412
- ["strokeOpacity", "stroke-opacity"],
413
- ["strokeWidth", "stroke-width"],
414
- ["textAnchor", "text-anchor"],
415
- ["textDecoration", "text-decoration"],
416
- ["textRendering", "text-rendering"],
417
- ["transformOrigin", "transform-origin"],
418
- ["underlinePosition", "underline-position"],
419
- ["underlineThickness", "underline-thickness"],
420
- ["unicodeBidi", "unicode-bidi"],
421
- ["unicodeRange", "unicode-range"],
422
- ["unitsPerEm", "units-per-em"],
423
- ["vAlphabetic", "v-alphabetic"],
424
- ["vHanging", "v-hanging"],
425
- ["vIdeographic", "v-ideographic"],
426
- ["vMathematical", "v-mathematical"],
427
- ["vectorEffect", "vector-effect"],
428
- ["vertAdvY", "vert-adv-y"],
429
- ["vertOriginX", "vert-origin-x"],
430
- ["vertOriginY", "vert-origin-y"],
431
- ["wordSpacing", "word-spacing"],
432
- ["writingMode", "writing-mode"],
433
- ["xmlnsXlink", "xmlns:xlink"],
434
- ["xHeight", "x-height"],
435
- ])
436
-
437
- function styleObjectToString(obj: Partial<CSSStyleDeclaration>): string {
438
- let cssString = ""
439
- for (const key in obj) {
440
- const cssKey = key.replace(REGEX_UNIT.ALPHA_UPPER_G, "-$&").toLowerCase()
441
- cssString += `${cssKey}:${obj[key]};`
442
- }
443
- return cssString
444
- }
445
-
446
- function stylePropToString(style: unknown) {
447
- if (typeof style === "string") return style
448
- if (typeof style === "object" && !!style) return styleObjectToString(style)
449
- return ""
450
- }
451
-
452
- function propValueToHtmlAttrValue(key: string, value: unknown): string {
453
- return key === "style" && typeof value === "object" && !!value
454
- ? styleObjectToString(value)
455
- : String(value)
456
- }
457
- function propsToElementAttributes(props: Record<string, unknown>): string {
458
- const attrs: string[] = []
459
- const { className, style, ...rest } = props
460
- if (className) {
461
- const val = unwrap(className)
462
- if (!!val) attrs.push(`class="${val}"`)
463
- }
464
- if (style) {
465
- const val = unwrap(style)
466
- if (!!val) attrs.push(`style="${stylePropToString(val)}"`)
467
- }
468
-
469
- const keys = Object.keys(rest).filter(propFilters.isProperty)
470
- for (let i = 0; i < keys.length; i++) {
471
- let k = keys[i]
472
- let val = unwrap(props[k])
473
- if (val === null || val === undefined) continue
474
-
475
- k = k.split("bind:")[1] ?? k // normalize bind props
476
- const key = propToHtmlAttr(k)
477
-
478
- switch (typeof val) {
479
- case "function":
480
- case "symbol":
481
- continue
482
- case "boolean":
483
- if (booleanAttributes.has(key)) {
484
- if (val) attrs.push(key)
485
- continue
486
- }
487
- }
488
- attrs.push(`${key}="${val}"`)
489
- }
490
- return attrs.join(" ")
491
- }
492
-
493
- type SafeStringifyOptions = {
494
- /**
495
- * By default, functions are stringified. Specify `false` to instead produce `[FUNCTION (${fn.name})]`.
496
- */
497
- functions: boolean
498
- }
499
-
500
- function safeStringify(
501
- value: unknown,
502
- opts: SafeStringifyOptions = { functions: true }
503
- ): string {
504
- const seen = new WeakSet()
505
- return JSON.stringify(value, (_, value) => {
506
- if (typeof value === "object" && value !== null) {
507
- if (seen.has(value)) {
508
- return "[CIRCULAR]"
509
- }
510
- seen.add(value)
511
- }
512
- if (typeof value === "function") {
513
- if (!opts.functions) return `[FUNCTION (${value.name || "anonymous"})]`
514
- return value.toString()
515
- }
516
- return value
517
- })
518
- }
package/src/warning.ts DELETED
@@ -1,9 +0,0 @@
1
- export const warnDeprecated = (
2
- featName: string,
3
- reason: string,
4
- solution: string
5
- ) => {
6
- console.warn(
7
- `[kiru]: "${featName}" is deprecated ${reason} and will be removed in future versions. ${solution}.`
8
- )
9
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes