@takazudo/zfb 3.1.0 → 4.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.
- package/dist/config.d.ts +57 -3
- package/dist/config.js +23 -12
- package/dist/config.js.map +1 -1
- package/dist/content.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js.map +1 -1
- package/dist/island-boundary.d.ts +2 -2
- package/dist/island-boundary.js +4 -2
- package/dist/island-boundary.js.map +1 -1
- package/dist/island.d.ts +8 -4
- package/dist/island.js +1 -1
- package/dist/island.js.map +1 -1
- package/dist/jsx-types.d.ts +1 -1
- package/dist/jsx-types.js.map +1 -1
- package/dist/plugins.d.ts +18 -4
- package/dist/plugins.js.map +1 -1
- package/dist/runtime.js.map +1 -1
- package/dist/slugify.js.map +1 -1
- package/dist/zudo-react/description.d.ts +18 -0
- package/dist/zudo-react/description.js +41 -0
- package/dist/zudo-react/description.js.map +1 -1
- package/dist/zudo-react/dom-bindings.d.ts +2 -1
- package/dist/zudo-react/dom-bindings.js +16 -22
- package/dist/zudo-react/dom-bindings.js.map +1 -1
- package/dist/zudo-react/forms.js.map +1 -1
- package/dist/zudo-react/hydrate.js +52 -31
- package/dist/zudo-react/hydrate.js.map +1 -1
- package/dist/zudo-react/index.d.ts +2 -1
- package/dist/zudo-react/index.js.map +1 -1
- package/dist/zudo-react/jsx-dev-runtime.d.ts +2 -6
- package/dist/zudo-react/jsx-dev-runtime.js +3 -3
- package/dist/zudo-react/jsx-dev-runtime.js.map +1 -1
- package/dist/zudo-react/jsx-runtime.js +2 -2
- package/dist/zudo-react/jsx-runtime.js.map +1 -1
- package/dist/zudo-react/jsx-types.d.ts +73 -26
- package/dist/zudo-react/jsx-types.js.map +1 -1
- package/dist/zudo-react/props-transport.d.ts +2 -0
- package/dist/zudo-react/props-transport.js +42 -14
- package/dist/zudo-react/props-transport.js.map +1 -1
- package/dist/zudo-react/raw-html.d.ts +1 -0
- package/dist/zudo-react/raw-html.js +260 -0
- package/dist/zudo-react/raw-html.js.map +1 -0
- package/dist/zudo-react/reactive.js.map +1 -1
- package/dist/zudo-react/render-html.d.ts +11 -1
- package/dist/zudo-react/render-html.js +83 -56
- package/dist/zudo-react/render-html.js.map +1 -1
- package/dist/zudo-react/root.d.ts +9 -1
- package/dist/zudo-react/root.js +45 -3
- package/dist/zudo-react/root.js.map +1 -1
- package/dist/zudo-react/server.d.ts +2 -0
- package/dist/zudo-react/server.js.map +1 -1
- package/dist/zudo-react/style.d.ts +10 -0
- package/dist/zudo-react/style.js +525 -0
- package/dist/zudo-react/style.js.map +1 -0
- package/dist/zudo-react/testing.d.ts +27 -0
- package/dist/zudo-react/testing.js +117 -0
- package/dist/zudo-react/testing.js.map +1 -0
- package/dist/zudo-react/vocabulary.d.ts +7 -0
- package/dist/zudo-react/vocabulary.js +64 -5
- package/dist/zudo-react/vocabulary.js.map +1 -1
- package/package.json +16 -10
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CSSProperties } from "./style.js";
|
|
2
|
+
export type { CSSProperties, CssProperty } from "./style.js";
|
|
3
|
+
import type { Child, Component, Description, Key } from "./description.js";
|
|
2
4
|
import type { Listener, Ref } from "./index.js";
|
|
3
5
|
import type { ReadonlySignal, Signal } from "./reactive-types.js";
|
|
4
6
|
type Value<T> = T | ReadonlySignal<T> | undefined;
|
|
@@ -6,8 +8,6 @@ type ScalarAttribute = Value<string | number | boolean | null>;
|
|
|
6
8
|
type DimensionAttribute = Value<string | number | null>;
|
|
7
9
|
type StringAttribute = Value<string | null>;
|
|
8
10
|
type BooleanAttribute = Value<boolean | null>;
|
|
9
|
-
type CssProperty = `--${string}` | `${string}-${string}` | "color" | "display" | "opacity" | "width" | "height" | "margin" | "padding" | "border" | "background" | "position" | "top" | "right" | "bottom" | "left" | "overflow" | "transform" | "transition" | "animation" | "font" | "flex" | "grid" | "gap";
|
|
10
|
-
type CssStyle = Readonly<Partial<Record<CssProperty, string | number | null | undefined>>>;
|
|
11
11
|
type AnyListener = Listener<any>;
|
|
12
12
|
type EventProps<TEl extends Element, TMap extends Record<keyof TMap, Event>> = {
|
|
13
13
|
[K in keyof TMap & string as `on:${K}` | `on:${K}:capture`]?: Listener<TMap[K] & {
|
|
@@ -35,12 +35,12 @@ interface CommonAttributes<T extends Element = Element> extends ReservedProps<T>
|
|
|
35
35
|
dir?: StringAttribute;
|
|
36
36
|
slot?: StringAttribute;
|
|
37
37
|
role?: StringAttribute;
|
|
38
|
-
style?: Value<string |
|
|
38
|
+
style?: Value<string | CSSProperties | null>;
|
|
39
39
|
hidden?: BooleanAttribute;
|
|
40
40
|
inert?: BooleanAttribute;
|
|
41
|
-
contenteditable?:
|
|
42
|
-
draggable?:
|
|
43
|
-
spellcheck?:
|
|
41
|
+
contenteditable?: Value<string | boolean | null>;
|
|
42
|
+
draggable?: Value<string | boolean | null>;
|
|
43
|
+
spellcheck?: Value<string | boolean | null>;
|
|
44
44
|
tabindex?: Value<number | null>;
|
|
45
45
|
accesskey?: StringAttribute;
|
|
46
46
|
translate?: StringAttribute;
|
|
@@ -48,11 +48,32 @@ interface CommonAttributes<T extends Element = Element> extends ReservedProps<T>
|
|
|
48
48
|
onload?: string | undefined;
|
|
49
49
|
onerror?: string | undefined;
|
|
50
50
|
}
|
|
51
|
-
interface
|
|
51
|
+
interface HtmlBaseAttributes<T extends HTMLElement = HTMLElement> extends CommonAttributes<T> {
|
|
52
52
|
href?: StringAttribute;
|
|
53
53
|
target?: StringAttribute;
|
|
54
54
|
rel?: StringAttribute;
|
|
55
|
-
download?:
|
|
55
|
+
download?: Value<string | boolean | null>;
|
|
56
|
+
property?: StringAttribute;
|
|
57
|
+
itemprop?: StringAttribute;
|
|
58
|
+
hreflang?: StringAttribute;
|
|
59
|
+
as?: StringAttribute;
|
|
60
|
+
integrity?: StringAttribute;
|
|
61
|
+
async?: BooleanAttribute;
|
|
62
|
+
defer?: BooleanAttribute;
|
|
63
|
+
nonce?: StringAttribute;
|
|
64
|
+
popover?: StringAttribute;
|
|
65
|
+
popovertarget?: StringAttribute;
|
|
66
|
+
popovertargetaction?: StringAttribute;
|
|
67
|
+
srcdoc?: StringAttribute;
|
|
68
|
+
fetchpriority?: StringAttribute;
|
|
69
|
+
inputmode?: StringAttribute;
|
|
70
|
+
autocapitalize?: StringAttribute;
|
|
71
|
+
form?: StringAttribute;
|
|
72
|
+
label?: StringAttribute;
|
|
73
|
+
preload?: StringAttribute;
|
|
74
|
+
playsinline?: BooleanAttribute;
|
|
75
|
+
wrap?: StringAttribute;
|
|
76
|
+
closedby?: StringAttribute;
|
|
56
77
|
src?: StringAttribute;
|
|
57
78
|
alt?: StringAttribute;
|
|
58
79
|
width?: Value<string | number | null>;
|
|
@@ -112,43 +133,58 @@ interface HtmlAttributes<T extends Element = HTMLElement> extends CommonAttribut
|
|
|
112
133
|
allow?: StringAttribute;
|
|
113
134
|
allowfullscreen?: BooleanAttribute;
|
|
114
135
|
}
|
|
115
|
-
type
|
|
116
|
-
type RawTextProps<
|
|
136
|
+
export type HTMLAttributes<T extends HTMLElement = HTMLElement> = HtmlBaseAttributes<T> & DataAria & EventProps<T, HTMLElementEventMap>;
|
|
137
|
+
type RawTextProps<T extends HTMLElement = HTMLElement> = Omit<HtmlBaseAttributes<T>, "children" | "rawHtml"> & DataAria & EventProps<T, HTMLElementEventMap> & {
|
|
117
138
|
children?: never;
|
|
118
139
|
rawHtml?: string | undefined;
|
|
119
140
|
};
|
|
120
|
-
type
|
|
121
|
-
|
|
122
|
-
|
|
141
|
+
type IframeProps = Omit<HtmlBaseAttributes<HTMLIFrameElement>, "children" | "rawHtml"> & DataAria & EventProps<HTMLIFrameElement, HTMLElementEventMap> & {
|
|
142
|
+
children?: never;
|
|
143
|
+
rawHtml?: never;
|
|
123
144
|
};
|
|
124
|
-
type
|
|
145
|
+
type InputBase = Omit<HtmlBaseAttributes<HTMLInputElement>, "type"> & DataAria & EventProps<HTMLInputElement, HTMLElementEventMap>;
|
|
146
|
+
export type InputProps = InputBase & ({
|
|
125
147
|
type?: "text" | "search" | "email" | "url" | "tel" | "password" | undefined;
|
|
148
|
+
defaultValue?: string | undefined;
|
|
149
|
+
defaultChecked?: never;
|
|
126
150
|
modelValue?: Signal<string> | undefined;
|
|
127
151
|
modelChecked?: never;
|
|
128
152
|
} | {
|
|
129
153
|
type: "checkbox";
|
|
154
|
+
defaultValue?: never;
|
|
155
|
+
defaultChecked?: boolean | undefined;
|
|
130
156
|
modelChecked?: Signal<boolean> | undefined;
|
|
131
157
|
modelValue?: never;
|
|
132
158
|
} | {
|
|
133
159
|
type: "radio";
|
|
134
160
|
name: string;
|
|
135
161
|
value: string;
|
|
136
|
-
|
|
162
|
+
defaultValue?: never;
|
|
163
|
+
defaultChecked?: boolean | undefined;
|
|
164
|
+
modelValue: Signal<string | null>;
|
|
165
|
+
modelChecked?: never;
|
|
166
|
+
} | {
|
|
167
|
+
type: "radio";
|
|
168
|
+
defaultValue?: never;
|
|
169
|
+
defaultChecked?: boolean | undefined;
|
|
170
|
+
modelValue?: undefined;
|
|
137
171
|
modelChecked?: never;
|
|
138
172
|
} | {
|
|
139
173
|
type: string;
|
|
174
|
+
defaultValue?: never;
|
|
175
|
+
defaultChecked?: never;
|
|
140
176
|
modelValue?: never;
|
|
141
177
|
modelChecked?: never;
|
|
142
178
|
});
|
|
143
|
-
type TextareaProps =
|
|
179
|
+
export type TextareaProps = HTMLAttributes<HTMLTextAreaElement> & {
|
|
144
180
|
modelValue?: Signal<string> | undefined;
|
|
145
181
|
defaultValue?: string | undefined;
|
|
146
182
|
};
|
|
147
|
-
type SelectProps =
|
|
183
|
+
export type SelectProps = HTMLAttributes<HTMLSelectElement> & {
|
|
148
184
|
modelValue?: Signal<string> | undefined;
|
|
149
185
|
defaultValue?: string | undefined;
|
|
150
186
|
};
|
|
151
|
-
interface
|
|
187
|
+
interface SvgBaseAttributes<T extends SVGElement = SVGElement> extends CommonAttributes<T> {
|
|
152
188
|
width?: DimensionAttribute;
|
|
153
189
|
height?: DimensionAttribute;
|
|
154
190
|
viewBox?: StringAttribute;
|
|
@@ -161,6 +197,10 @@ interface SvgAttributes extends CommonAttributes<SVGElement> {
|
|
|
161
197
|
refY?: ScalarAttribute;
|
|
162
198
|
"xlink:href"?: StringAttribute;
|
|
163
199
|
"xml:lang"?: StringAttribute;
|
|
200
|
+
xmlns?: StringAttribute;
|
|
201
|
+
"xmlns:xlink"?: StringAttribute;
|
|
202
|
+
href?: StringAttribute;
|
|
203
|
+
focusable?: StringAttribute;
|
|
164
204
|
"stroke-width"?: ScalarAttribute;
|
|
165
205
|
"fill-rule"?: StringAttribute;
|
|
166
206
|
"clip-rule"?: StringAttribute;
|
|
@@ -168,6 +208,9 @@ interface SvgAttributes extends CommonAttributes<SVGElement> {
|
|
|
168
208
|
"stroke-linejoin"?: StringAttribute;
|
|
169
209
|
"stop-color"?: StringAttribute;
|
|
170
210
|
"stop-opacity"?: ScalarAttribute;
|
|
211
|
+
"fill-opacity"?: ScalarAttribute;
|
|
212
|
+
"stroke-dasharray"?: StringAttribute;
|
|
213
|
+
"text-anchor"?: StringAttribute;
|
|
171
214
|
fill?: StringAttribute;
|
|
172
215
|
stroke?: StringAttribute;
|
|
173
216
|
d?: StringAttribute;
|
|
@@ -188,21 +231,26 @@ interface SvgAttributes extends CommonAttributes<SVGElement> {
|
|
|
188
231
|
offset?: ScalarAttribute;
|
|
189
232
|
id?: StringAttribute;
|
|
190
233
|
}
|
|
191
|
-
type
|
|
234
|
+
export type SVGAttributes<T extends SVGElement = SVGElement> = SvgBaseAttributes<T> & DataAria & EventProps<T, SVGElementEventMap>;
|
|
192
235
|
type CustomProps = ReservedProps & EventProps<HTMLElement, GlobalEventHandlersEventMap> & {
|
|
193
236
|
value?: string | null | undefined;
|
|
194
237
|
checked?: null | undefined;
|
|
195
238
|
[attribute: string]: StringAttribute | Child | Ref<Element> | AnyListener | undefined;
|
|
196
239
|
};
|
|
197
|
-
type HtmlTag = "html" | "head" | "body" | "title" | "base" | "link" | "meta" | "style" | "script" | "div" | "span" | "p" | "a" | "br" | "hr" | "main" | "header" | "footer" | "nav" | "section" | "article" | "aside" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "ul" | "ol" | "li" | "dl" | "dt" | "dd" | "blockquote" | "pre" | "code" | "strong" | "em" | "b" | "i" | "small" | "mark" | "time" | "figure" | "figcaption" | "img" | "picture" | "source" | "video" | "audio" | "track" | "canvas" | "form" | "label" | "input" | "button" | "textarea" | "select" | "option" | "optgroup" | "fieldset" | "legend" | "output" | "progress" | "meter" | "datalist" | "table" | "caption" | "thead" | "tbody" | "tfoot" | "tr" | "th" | "td" | "col" | "colgroup" | "details" | "summary" | "dialog" | "template" | "slot" | "iframe" | "noscript" | "address" | "abbr" | "bdi" | "bdo" | "cite" | "data" | "del" | "dfn" | "ins" | "kbd" | "map" | "area" | "object" | "param" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "sub" | "sup" | "u" | "var" | "wbr" | "embed";
|
|
198
|
-
type SvgTag = "svg" | "g" | "path" | "circle" | "ellipse" | "rect" | "line" | "polyline" | "polygon" | "text" | "tspan" | "defs" | "symbol" | "use" | "clipPath" | "mask" | "linearGradient" | "radialGradient" | "stop" | "desc" | "foreignObject";
|
|
240
|
+
type HtmlTag = "html" | "head" | "body" | "title" | "base" | "link" | "meta" | "style" | "script" | "div" | "span" | "p" | "a" | "br" | "hr" | "main" | "header" | "footer" | "nav" | "section" | "article" | "aside" | "search" | "hgroup" | "menu" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "ul" | "ol" | "li" | "dl" | "dt" | "dd" | "blockquote" | "pre" | "code" | "strong" | "em" | "b" | "i" | "small" | "mark" | "time" | "figure" | "figcaption" | "img" | "picture" | "source" | "video" | "audio" | "track" | "canvas" | "form" | "label" | "input" | "button" | "textarea" | "select" | "option" | "optgroup" | "fieldset" | "legend" | "output" | "progress" | "meter" | "datalist" | "table" | "caption" | "thead" | "tbody" | "tfoot" | "tr" | "th" | "td" | "col" | "colgroup" | "details" | "summary" | "dialog" | "template" | "slot" | "iframe" | "noscript" | "address" | "abbr" | "bdi" | "bdo" | "cite" | "data" | "del" | "dfn" | "ins" | "kbd" | "map" | "area" | "object" | "param" | "q" | "rp" | "rb" | "rt" | "ruby" | "s" | "samp" | "sub" | "sup" | "u" | "var" | "wbr" | "embed";
|
|
241
|
+
type SvgTag = "svg" | "g" | "path" | "circle" | "ellipse" | "rect" | "line" | "polyline" | "polygon" | "text" | "tspan" | "defs" | "symbol" | "use" | "clipPath" | "mask" | "linearGradient" | "radialGradient" | "stop" | "desc" | "foreignObject" | "pattern" | "filter" | "marker" | "image";
|
|
242
|
+
/** DOM element corresponding to an owned intrinsic tag. */
|
|
243
|
+
export type ElementForTag<Tag extends HtmlTag | SvgTag> = Tag extends HtmlTag ? Tag extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[Tag] : HTMLElement : Tag extends keyof SVGElementTagNameMap ? SVGElementTagNameMap[Tag] : SVGElement;
|
|
199
244
|
export declare namespace JSX {
|
|
200
|
-
type Element =
|
|
245
|
+
type Element = Description;
|
|
246
|
+
type HTMLAttributes<T extends HTMLElement = HTMLElement> = import("./jsx-types.js").HTMLAttributes<T>;
|
|
247
|
+
type SVGAttributes<T extends SVGElement = SVGElement> = import("./jsx-types.js").SVGAttributes<T>;
|
|
248
|
+
type CSSProperties = import("./jsx-types.js").CSSProperties;
|
|
201
249
|
type ElementType = string | Component<any> | typeof import("../island.js").Island | typeof import("./description.js").Fragment;
|
|
202
250
|
type IntrinsicElements = {
|
|
203
|
-
[K in HtmlTag]: K extends "input" ? InputProps : K extends "textarea" ? TextareaProps : K extends "select" ? SelectProps : K extends "script" | "style" ? RawTextProps<K
|
|
251
|
+
[K in HtmlTag]: K extends "input" ? InputProps : K extends "textarea" ? TextareaProps : K extends "select" ? SelectProps : K extends "iframe" ? IframeProps : K extends "script" | "style" ? RawTextProps<ElementForTag<K>> : HTMLAttributes<ElementForTag<K>>;
|
|
204
252
|
} & {
|
|
205
|
-
[K in SvgTag]:
|
|
253
|
+
[K in SvgTag]: SVGAttributes<ElementForTag<K>>;
|
|
206
254
|
} & {
|
|
207
255
|
[K in `${string}-${string}`]: CustomProps;
|
|
208
256
|
};
|
|
@@ -213,4 +261,3 @@ export declare namespace JSX {
|
|
|
213
261
|
children: unknown;
|
|
214
262
|
}
|
|
215
263
|
}
|
|
216
|
-
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-types.js","sourceRoot":"","sources":["../../src/zudo-react/jsx-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Child, Component, Key } from \"./description.js\";\nimport type { Listener, Ref } from \"./index.js\";\nimport type { ReadonlySignal, Signal } from \"./reactive-types.js\";\n\ntype Value<T> = T | ReadonlySignal<T> | undefined;\ntype ScalarAttribute = Value<string | number | boolean | null>;\ntype DimensionAttribute = Value<string | number | null>;\ntype StringAttribute = Value<string | null>;\ntype BooleanAttribute = Value<boolean | null>;\ntype CssProperty =\n | `--${string}`\n | `${string}-${string}`\n | \"color\"\n | \"display\"\n | \"opacity\"\n | \"width\"\n | \"height\"\n | \"margin\"\n | \"padding\"\n | \"border\"\n | \"background\"\n | \"position\"\n | \"top\"\n | \"right\"\n | \"bottom\"\n | \"left\"\n | \"overflow\"\n | \"transform\"\n | \"transition\"\n | \"animation\"\n | \"font\"\n | \"flex\"\n | \"grid\"\n | \"gap\";\ntype CssStyle = Readonly<Partial<Record<CssProperty, string | number | null | undefined>>>;\n// The custom-name index must also accept every mapped listener under strict function variance.\ntype AnyListener = Listener<any>;\ntype EventProps<TEl extends Element, TMap extends Record<keyof TMap, Event>> = {\n [K in keyof TMap & string as `on:${K}` | `on:${K}:capture`]?: Listener<\n TMap[K] & { currentTarget: TEl }\n >;\n} & {\n [name: `on:${string}`]: AnyListener | undefined;\n};\ntype DataAria = {\n [name: `data-${string}`]: ScalarAttribute;\n} & {\n [name: `aria-${string}`]: ScalarAttribute;\n};\n\ninterface ReservedProps<T extends Element = Element> {\n children?: Child | undefined;\n key?: Key | undefined;\n ref?: Ref<T> | undefined;\n rawHtml?: Value<string | null>;\n}\n\ninterface CommonAttributes<T extends Element = Element> extends ReservedProps<T> {\n id?: StringAttribute;\n class?: StringAttribute;\n title?: StringAttribute;\n lang?: StringAttribute;\n dir?: StringAttribute;\n slot?: StringAttribute;\n role?: StringAttribute;\n style?: Value<string | CssStyle | null>;\n hidden?: BooleanAttribute;\n inert?: BooleanAttribute;\n contenteditable?: StringAttribute;\n draggable?: StringAttribute;\n spellcheck?: StringAttribute;\n tabindex?: Value<number | null>;\n accesskey?: StringAttribute;\n translate?: StringAttribute;\n onclick?: string | undefined;\n onload?: string | undefined;\n onerror?: string | undefined;\n}\n\ninterface HtmlAttributes<T extends Element = HTMLElement> extends CommonAttributes<T> {\n href?: StringAttribute;\n target?: StringAttribute;\n rel?: StringAttribute;\n download?: StringAttribute;\n src?: StringAttribute;\n alt?: StringAttribute;\n width?: Value<string | number | null>;\n height?: Value<string | number | null>;\n type?: StringAttribute;\n name?: StringAttribute;\n value?: string | number | null | undefined;\n placeholder?: StringAttribute;\n for?: StringAttribute;\n charset?: StringAttribute;\n datetime?: StringAttribute;\n readonly?: BooleanAttribute;\n autofocus?: BooleanAttribute;\n required?: BooleanAttribute;\n disabled?: BooleanAttribute;\n checked?: boolean | null | undefined;\n selected?: BooleanAttribute;\n multiple?: BooleanAttribute;\n reversed?: BooleanAttribute;\n open?: BooleanAttribute;\n controls?: BooleanAttribute;\n muted?: BooleanAttribute;\n loop?: BooleanAttribute;\n autoplay?: BooleanAttribute;\n novalidate?: BooleanAttribute;\n formnovalidate?: BooleanAttribute;\n maxlength?: Value<number | null>;\n minlength?: Value<number | null>;\n min?: StringAttribute;\n max?: StringAttribute;\n step?: StringAttribute;\n start?: Value<string | number | null>;\n pattern?: StringAttribute;\n autocomplete?: StringAttribute;\n accept?: StringAttribute;\n \"accept-charset\"?: StringAttribute;\n \"http-equiv\"?: StringAttribute;\n content?: StringAttribute;\n media?: StringAttribute;\n method?: StringAttribute;\n action?: StringAttribute;\n enctype?: StringAttribute;\n rows?: Value<number | null>;\n cols?: Value<number | null>;\n colspan?: Value<number | null>;\n rowspan?: Value<number | null>;\n scope?: StringAttribute;\n cite?: StringAttribute;\n poster?: StringAttribute;\n loading?: StringAttribute;\n decoding?: StringAttribute;\n sizes?: StringAttribute;\n srcset?: StringAttribute;\n crossorigin?: StringAttribute;\n referrerpolicy?: StringAttribute;\n sandbox?: StringAttribute;\n allow?: StringAttribute;\n allowfullscreen?: BooleanAttribute;\n}\n\ntype HtmlProps<\n TRef extends Element = HTMLElement,\n TEvent extends HTMLElement = HTMLElement,\n> = HtmlAttributes<TRef> & DataAria & EventProps<TEvent, HTMLElementEventMap>;\ntype RawTextProps<TEvent extends HTMLElement = HTMLElement> = Omit<\n HtmlAttributes<HTMLElement>,\n \"children\" | \"rawHtml\"\n> &\n DataAria &\n EventProps<TEvent, HTMLElementEventMap> & {\n children?: never;\n rawHtml?: string | undefined;\n };\ntype InputBase = Omit<HtmlAttributes<HTMLInputElement>, \"type\"> &\n DataAria &\n EventProps<HTMLInputElement, HTMLElementEventMap> & {\n defaultValue?: string | undefined;\n defaultChecked?: boolean | undefined;\n };\ntype InputProps = InputBase &\n (\n | {\n type?: \"text\" | \"search\" | \"email\" | \"url\" | \"tel\" | \"password\" | undefined;\n modelValue?: Signal<string> | undefined;\n modelChecked?: never;\n }\n | {\n type: \"checkbox\";\n modelChecked?: Signal<boolean> | undefined;\n modelValue?: never;\n }\n | {\n type: \"radio\";\n name: string;\n value: string;\n modelValue?: Signal<string | null> | undefined;\n modelChecked?: never;\n }\n | {\n type: string;\n modelValue?: never;\n modelChecked?: never;\n }\n );\ntype TextareaProps = HtmlProps<HTMLTextAreaElement, HTMLTextAreaElement> & {\n modelValue?: Signal<string> | undefined;\n defaultValue?: string | undefined;\n};\ntype SelectProps = HtmlProps<HTMLSelectElement, HTMLSelectElement> & {\n modelValue?: Signal<string> | undefined;\n defaultValue?: string | undefined;\n};\n\ninterface SvgAttributes extends CommonAttributes<SVGElement> {\n width?: DimensionAttribute;\n height?: DimensionAttribute;\n viewBox?: StringAttribute;\n preserveAspectRatio?: StringAttribute;\n gradientUnits?: StringAttribute;\n gradientTransform?: StringAttribute;\n markerWidth?: ScalarAttribute;\n markerHeight?: ScalarAttribute;\n refX?: ScalarAttribute;\n refY?: ScalarAttribute;\n \"xlink:href\"?: StringAttribute;\n \"xml:lang\"?: StringAttribute;\n \"stroke-width\"?: ScalarAttribute;\n \"fill-rule\"?: StringAttribute;\n \"clip-rule\"?: StringAttribute;\n \"stroke-linecap\"?: StringAttribute;\n \"stroke-linejoin\"?: StringAttribute;\n \"stop-color\"?: StringAttribute;\n \"stop-opacity\"?: ScalarAttribute;\n fill?: StringAttribute;\n stroke?: StringAttribute;\n d?: StringAttribute;\n x?: ScalarAttribute;\n y?: ScalarAttribute;\n x1?: ScalarAttribute;\n x2?: ScalarAttribute;\n y1?: ScalarAttribute;\n y2?: ScalarAttribute;\n cx?: ScalarAttribute;\n cy?: ScalarAttribute;\n r?: ScalarAttribute;\n rx?: ScalarAttribute;\n ry?: ScalarAttribute;\n points?: StringAttribute;\n transform?: StringAttribute;\n opacity?: ScalarAttribute;\n offset?: ScalarAttribute;\n id?: StringAttribute;\n}\n\ntype SvgProps<TEvent extends SVGElement = SVGElement> = SvgAttributes &\n DataAria &\n EventProps<TEvent, SVGElementEventMap>;\ntype CustomProps = ReservedProps &\n EventProps<HTMLElement, GlobalEventHandlersEventMap> & {\n value?: string | null | undefined;\n checked?: null | undefined;\n [attribute: string]: StringAttribute | Child | Ref<Element> | AnyListener | undefined;\n };\n\ntype HtmlTag =\n | \"html\"\n | \"head\"\n | \"body\"\n | \"title\"\n | \"base\"\n | \"link\"\n | \"meta\"\n | \"style\"\n | \"script\"\n | \"div\"\n | \"span\"\n | \"p\"\n | \"a\"\n | \"br\"\n | \"hr\"\n | \"main\"\n | \"header\"\n | \"footer\"\n | \"nav\"\n | \"section\"\n | \"article\"\n | \"aside\"\n | \"h1\"\n | \"h2\"\n | \"h3\"\n | \"h4\"\n | \"h5\"\n | \"h6\"\n | \"ul\"\n | \"ol\"\n | \"li\"\n | \"dl\"\n | \"dt\"\n | \"dd\"\n | \"blockquote\"\n | \"pre\"\n | \"code\"\n | \"strong\"\n | \"em\"\n | \"b\"\n | \"i\"\n | \"small\"\n | \"mark\"\n | \"time\"\n | \"figure\"\n | \"figcaption\"\n | \"img\"\n | \"picture\"\n | \"source\"\n | \"video\"\n | \"audio\"\n | \"track\"\n | \"canvas\"\n | \"form\"\n | \"label\"\n | \"input\"\n | \"button\"\n | \"textarea\"\n | \"select\"\n | \"option\"\n | \"optgroup\"\n | \"fieldset\"\n | \"legend\"\n | \"output\"\n | \"progress\"\n | \"meter\"\n | \"datalist\"\n | \"table\"\n | \"caption\"\n | \"thead\"\n | \"tbody\"\n | \"tfoot\"\n | \"tr\"\n | \"th\"\n | \"td\"\n | \"col\"\n | \"colgroup\"\n | \"details\"\n | \"summary\"\n | \"dialog\"\n | \"template\"\n | \"slot\"\n | \"iframe\"\n | \"noscript\"\n | \"address\"\n | \"abbr\"\n | \"bdi\"\n | \"bdo\"\n | \"cite\"\n | \"data\"\n | \"del\"\n | \"dfn\"\n | \"ins\"\n | \"kbd\"\n | \"map\"\n | \"area\"\n | \"object\"\n | \"param\"\n | \"q\"\n | \"rp\"\n | \"rt\"\n | \"ruby\"\n | \"s\"\n | \"samp\"\n | \"sub\"\n | \"sup\"\n | \"u\"\n | \"var\"\n | \"wbr\"\n | \"embed\";\n\ntype SvgTag =\n | \"svg\"\n | \"g\"\n | \"path\"\n | \"circle\"\n | \"ellipse\"\n | \"rect\"\n | \"line\"\n | \"polyline\"\n | \"polygon\"\n | \"text\"\n | \"tspan\"\n | \"defs\"\n | \"symbol\"\n | \"use\"\n | \"clipPath\"\n | \"mask\"\n | \"linearGradient\"\n | \"radialGradient\"\n | \"stop\"\n | \"desc\"\n | \"foreignObject\";\n\nexport namespace JSX {\n export type Element = Child;\n export type ElementType =\n | string\n | Component<any>\n | typeof import(\"../island.js\").Island\n | typeof import(\"./description.js\").Fragment;\n export type IntrinsicElements = {\n [K in HtmlTag]: K extends \"input\"\n ? InputProps\n : K extends \"textarea\"\n ? TextareaProps\n : K extends \"select\"\n ? SelectProps\n : K extends \"script\" | \"style\"\n ? RawTextProps<\n K extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[K] : HTMLElement\n >\n : HtmlProps<\n HTMLElement,\n K extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[K] : HTMLElement\n >;\n } & {\n [K in SvgTag]: SvgProps<\n K extends keyof SVGElementTagNameMap ? SVGElementTagNameMap[K] : SVGElement\n >;\n } & {\n [K in `${string}-${string}`]: CustomProps;\n };\n export interface IntrinsicAttributes {\n key?: Key | undefined;\n }\n export interface ElementChildrenAttribute {\n children: unknown;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"jsx-types.js","sourceRoot":"","sources":["../../src/zudo-react/jsx-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { CSSProperties } from \"./style.js\";\nexport type { CSSProperties, CssProperty } from \"./style.js\";\nimport type { Child, Component, Description, Key } from \"./description.js\";\nimport type { Listener, Ref } from \"./index.js\";\nimport type { ReadonlySignal, Signal } from \"./reactive-types.js\";\n\ntype Value<T> = T | ReadonlySignal<T> | undefined;\ntype ScalarAttribute = Value<string | number | boolean | null>;\ntype DimensionAttribute = Value<string | number | null>;\ntype StringAttribute = Value<string | null>;\ntype BooleanAttribute = Value<boolean | null>;\n// The custom-name index must also accept every mapped listener under strict function variance.\ntype AnyListener = Listener<any>;\ntype EventProps<TEl extends Element, TMap extends Record<keyof TMap, Event>> = {\n [K in keyof TMap & string as `on:${K}` | `on:${K}:capture`]?: Listener<\n TMap[K] & { currentTarget: TEl }\n >;\n} & {\n [name: `on:${string}`]: AnyListener | undefined;\n};\ntype DataAria = {\n [name: `data-${string}`]: ScalarAttribute;\n} & {\n [name: `aria-${string}`]: ScalarAttribute;\n};\n\ninterface ReservedProps<T extends Element = Element> {\n children?: Child | undefined;\n key?: Key | undefined;\n ref?: Ref<T> | undefined;\n rawHtml?: Value<string | null>;\n}\n\ninterface CommonAttributes<T extends Element = Element> extends ReservedProps<T> {\n id?: StringAttribute;\n class?: StringAttribute;\n title?: StringAttribute;\n lang?: StringAttribute;\n dir?: StringAttribute;\n slot?: StringAttribute;\n role?: StringAttribute;\n style?: Value<string | CSSProperties | null>;\n hidden?: BooleanAttribute;\n inert?: BooleanAttribute;\n contenteditable?: Value<string | boolean | null>;\n draggable?: Value<string | boolean | null>;\n spellcheck?: Value<string | boolean | null>;\n tabindex?: Value<number | null>;\n accesskey?: StringAttribute;\n translate?: StringAttribute;\n onclick?: string | undefined;\n onload?: string | undefined;\n onerror?: string | undefined;\n}\n\ninterface HtmlBaseAttributes<T extends HTMLElement = HTMLElement> extends CommonAttributes<T> {\n href?: StringAttribute;\n target?: StringAttribute;\n rel?: StringAttribute;\n download?: Value<string | boolean | null>;\n property?: StringAttribute;\n itemprop?: StringAttribute;\n hreflang?: StringAttribute;\n as?: StringAttribute;\n integrity?: StringAttribute;\n async?: BooleanAttribute;\n defer?: BooleanAttribute;\n nonce?: StringAttribute;\n popover?: StringAttribute;\n popovertarget?: StringAttribute;\n popovertargetaction?: StringAttribute;\n srcdoc?: StringAttribute;\n fetchpriority?: StringAttribute;\n inputmode?: StringAttribute;\n autocapitalize?: StringAttribute;\n form?: StringAttribute;\n label?: StringAttribute;\n preload?: StringAttribute;\n playsinline?: BooleanAttribute;\n wrap?: StringAttribute;\n closedby?: StringAttribute;\n src?: StringAttribute;\n alt?: StringAttribute;\n width?: Value<string | number | null>;\n height?: Value<string | number | null>;\n type?: StringAttribute;\n name?: StringAttribute;\n value?: string | number | null | undefined;\n placeholder?: StringAttribute;\n for?: StringAttribute;\n charset?: StringAttribute;\n datetime?: StringAttribute;\n readonly?: BooleanAttribute;\n autofocus?: BooleanAttribute;\n required?: BooleanAttribute;\n disabled?: BooleanAttribute;\n checked?: boolean | null | undefined;\n selected?: BooleanAttribute;\n multiple?: BooleanAttribute;\n reversed?: BooleanAttribute;\n open?: BooleanAttribute;\n controls?: BooleanAttribute;\n muted?: BooleanAttribute;\n loop?: BooleanAttribute;\n autoplay?: BooleanAttribute;\n novalidate?: BooleanAttribute;\n formnovalidate?: BooleanAttribute;\n maxlength?: Value<number | null>;\n minlength?: Value<number | null>;\n min?: StringAttribute;\n max?: StringAttribute;\n step?: StringAttribute;\n start?: Value<string | number | null>;\n pattern?: StringAttribute;\n autocomplete?: StringAttribute;\n accept?: StringAttribute;\n \"accept-charset\"?: StringAttribute;\n \"http-equiv\"?: StringAttribute;\n content?: StringAttribute;\n media?: StringAttribute;\n method?: StringAttribute;\n action?: StringAttribute;\n enctype?: StringAttribute;\n rows?: Value<number | null>;\n cols?: Value<number | null>;\n colspan?: Value<number | null>;\n rowspan?: Value<number | null>;\n scope?: StringAttribute;\n cite?: StringAttribute;\n poster?: StringAttribute;\n loading?: StringAttribute;\n decoding?: StringAttribute;\n sizes?: StringAttribute;\n srcset?: StringAttribute;\n crossorigin?: StringAttribute;\n referrerpolicy?: StringAttribute;\n sandbox?: StringAttribute;\n allow?: StringAttribute;\n allowfullscreen?: BooleanAttribute;\n}\n\nexport type HTMLAttributes<T extends HTMLElement = HTMLElement> = HtmlBaseAttributes<T> &\n DataAria &\n EventProps<T, HTMLElementEventMap>;\ntype RawTextProps<T extends HTMLElement = HTMLElement> = Omit<\n HtmlBaseAttributes<T>,\n \"children\" | \"rawHtml\"\n> &\n DataAria &\n EventProps<T, HTMLElementEventMap> & {\n children?: never;\n rawHtml?: string | undefined;\n };\ntype IframeProps = Omit<HtmlBaseAttributes<HTMLIFrameElement>, \"children\" | \"rawHtml\"> &\n DataAria &\n EventProps<HTMLIFrameElement, HTMLElementEventMap> & {\n children?: never;\n rawHtml?: never;\n };\ntype InputBase = Omit<HtmlBaseAttributes<HTMLInputElement>, \"type\"> &\n DataAria &\n EventProps<HTMLInputElement, HTMLElementEventMap>;\nexport type InputProps = InputBase &\n (\n | {\n type?: \"text\" | \"search\" | \"email\" | \"url\" | \"tel\" | \"password\" | undefined;\n defaultValue?: string | undefined;\n defaultChecked?: never;\n modelValue?: Signal<string> | undefined;\n modelChecked?: never;\n }\n | {\n type: \"checkbox\";\n defaultValue?: never;\n defaultChecked?: boolean | undefined;\n modelChecked?: Signal<boolean> | undefined;\n modelValue?: never;\n }\n | {\n type: \"radio\";\n name: string;\n value: string;\n defaultValue?: never;\n defaultChecked?: boolean | undefined;\n modelValue: Signal<string | null>;\n modelChecked?: never;\n }\n | {\n type: \"radio\";\n defaultValue?: never;\n defaultChecked?: boolean | undefined;\n modelValue?: undefined;\n modelChecked?: never;\n }\n | {\n type: string;\n defaultValue?: never;\n defaultChecked?: never;\n modelValue?: never;\n modelChecked?: never;\n }\n );\nexport type TextareaProps = HTMLAttributes<HTMLTextAreaElement> & {\n modelValue?: Signal<string> | undefined;\n defaultValue?: string | undefined;\n};\nexport type SelectProps = HTMLAttributes<HTMLSelectElement> & {\n modelValue?: Signal<string> | undefined;\n defaultValue?: string | undefined;\n};\n\ninterface SvgBaseAttributes<T extends SVGElement = SVGElement> extends CommonAttributes<T> {\n width?: DimensionAttribute;\n height?: DimensionAttribute;\n viewBox?: StringAttribute;\n preserveAspectRatio?: StringAttribute;\n gradientUnits?: StringAttribute;\n gradientTransform?: StringAttribute;\n markerWidth?: ScalarAttribute;\n markerHeight?: ScalarAttribute;\n refX?: ScalarAttribute;\n refY?: ScalarAttribute;\n \"xlink:href\"?: StringAttribute;\n \"xml:lang\"?: StringAttribute;\n xmlns?: StringAttribute;\n \"xmlns:xlink\"?: StringAttribute;\n href?: StringAttribute;\n focusable?: StringAttribute;\n \"stroke-width\"?: ScalarAttribute;\n \"fill-rule\"?: StringAttribute;\n \"clip-rule\"?: StringAttribute;\n \"stroke-linecap\"?: StringAttribute;\n \"stroke-linejoin\"?: StringAttribute;\n \"stop-color\"?: StringAttribute;\n \"stop-opacity\"?: ScalarAttribute;\n \"fill-opacity\"?: ScalarAttribute;\n \"stroke-dasharray\"?: StringAttribute;\n \"text-anchor\"?: StringAttribute;\n fill?: StringAttribute;\n stroke?: StringAttribute;\n d?: StringAttribute;\n x?: ScalarAttribute;\n y?: ScalarAttribute;\n x1?: ScalarAttribute;\n x2?: ScalarAttribute;\n y1?: ScalarAttribute;\n y2?: ScalarAttribute;\n cx?: ScalarAttribute;\n cy?: ScalarAttribute;\n r?: ScalarAttribute;\n rx?: ScalarAttribute;\n ry?: ScalarAttribute;\n points?: StringAttribute;\n transform?: StringAttribute;\n opacity?: ScalarAttribute;\n offset?: ScalarAttribute;\n id?: StringAttribute;\n}\n\nexport type SVGAttributes<T extends SVGElement = SVGElement> = SvgBaseAttributes<T> &\n DataAria &\n EventProps<T, SVGElementEventMap>;\ntype CustomProps = ReservedProps &\n EventProps<HTMLElement, GlobalEventHandlersEventMap> & {\n value?: string | null | undefined;\n checked?: null | undefined;\n [attribute: string]: StringAttribute | Child | Ref<Element> | AnyListener | undefined;\n };\n\ntype HtmlTag =\n | \"html\"\n | \"head\"\n | \"body\"\n | \"title\"\n | \"base\"\n | \"link\"\n | \"meta\"\n | \"style\"\n | \"script\"\n | \"div\"\n | \"span\"\n | \"p\"\n | \"a\"\n | \"br\"\n | \"hr\"\n | \"main\"\n | \"header\"\n | \"footer\"\n | \"nav\"\n | \"section\"\n | \"article\"\n | \"aside\"\n | \"search\"\n | \"hgroup\"\n | \"menu\"\n | \"h1\"\n | \"h2\"\n | \"h3\"\n | \"h4\"\n | \"h5\"\n | \"h6\"\n | \"ul\"\n | \"ol\"\n | \"li\"\n | \"dl\"\n | \"dt\"\n | \"dd\"\n | \"blockquote\"\n | \"pre\"\n | \"code\"\n | \"strong\"\n | \"em\"\n | \"b\"\n | \"i\"\n | \"small\"\n | \"mark\"\n | \"time\"\n | \"figure\"\n | \"figcaption\"\n | \"img\"\n | \"picture\"\n | \"source\"\n | \"video\"\n | \"audio\"\n | \"track\"\n | \"canvas\"\n | \"form\"\n | \"label\"\n | \"input\"\n | \"button\"\n | \"textarea\"\n | \"select\"\n | \"option\"\n | \"optgroup\"\n | \"fieldset\"\n | \"legend\"\n | \"output\"\n | \"progress\"\n | \"meter\"\n | \"datalist\"\n | \"table\"\n | \"caption\"\n | \"thead\"\n | \"tbody\"\n | \"tfoot\"\n | \"tr\"\n | \"th\"\n | \"td\"\n | \"col\"\n | \"colgroup\"\n | \"details\"\n | \"summary\"\n | \"dialog\"\n | \"template\"\n | \"slot\"\n | \"iframe\"\n | \"noscript\"\n | \"address\"\n | \"abbr\"\n | \"bdi\"\n | \"bdo\"\n | \"cite\"\n | \"data\"\n | \"del\"\n | \"dfn\"\n | \"ins\"\n | \"kbd\"\n | \"map\"\n | \"area\"\n | \"object\"\n | \"param\"\n | \"q\"\n | \"rp\"\n | \"rb\"\n | \"rt\"\n | \"ruby\"\n | \"s\"\n | \"samp\"\n | \"sub\"\n | \"sup\"\n | \"u\"\n | \"var\"\n | \"wbr\"\n | \"embed\";\n\ntype SvgTag =\n | \"svg\"\n | \"g\"\n | \"path\"\n | \"circle\"\n | \"ellipse\"\n | \"rect\"\n | \"line\"\n | \"polyline\"\n | \"polygon\"\n | \"text\"\n | \"tspan\"\n | \"defs\"\n | \"symbol\"\n | \"use\"\n | \"clipPath\"\n | \"mask\"\n | \"linearGradient\"\n | \"radialGradient\"\n | \"stop\"\n | \"desc\"\n | \"foreignObject\"\n | \"pattern\"\n | \"filter\"\n | \"marker\"\n | \"image\";\n\n/** DOM element corresponding to an owned intrinsic tag. */\nexport type ElementForTag<Tag extends HtmlTag | SvgTag> = Tag extends HtmlTag\n ? Tag extends keyof HTMLElementTagNameMap\n ? HTMLElementTagNameMap[Tag]\n : HTMLElement\n : Tag extends keyof SVGElementTagNameMap\n ? SVGElementTagNameMap[Tag]\n : SVGElement;\n\nexport namespace JSX {\n export type Element = Description;\n export type HTMLAttributes<T extends HTMLElement = HTMLElement> =\n import(\"./jsx-types.js\").HTMLAttributes<T>;\n export type SVGAttributes<T extends SVGElement = SVGElement> =\n import(\"./jsx-types.js\").SVGAttributes<T>;\n export type CSSProperties = import(\"./jsx-types.js\").CSSProperties;\n export type ElementType =\n | string\n | Component<any>\n | typeof import(\"../island.js\").Island\n | typeof import(\"./description.js\").Fragment;\n export type IntrinsicElements = {\n [K in HtmlTag]: K extends \"input\"\n ? InputProps\n : K extends \"textarea\"\n ? TextareaProps\n : K extends \"select\"\n ? SelectProps\n : K extends \"iframe\"\n ? IframeProps\n : K extends \"script\" | \"style\"\n ? RawTextProps<ElementForTag<K>>\n : HTMLAttributes<ElementForTag<K>>;\n } & {\n [K in SvgTag]: SVGAttributes<ElementForTag<K>>;\n } & {\n [K in `${string}-${string}`]: CustomProps;\n };\n export interface IntrinsicAttributes {\n key?: Key | undefined;\n }\n export interface ElementChildrenAttribute {\n children: unknown;\n }\n}\n"]}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
export declare function normalizeProps(props: Record<string, unknown>): Record<string, unknown>;
|
|
1
2
|
export declare function serializeProps(props: Record<string, unknown>): string;
|
|
3
|
+
export declare function emptyChildren(value: unknown, ancestors?: Set<object>): boolean;
|
|
2
4
|
export declare function parseProps(json: string): Record<string, unknown>;
|
|
@@ -2,13 +2,13 @@ const forbidden = new Set(["__proto__", "prototype", "constructor"]);
|
|
|
2
2
|
function fail(code, path, detail = "") {
|
|
3
3
|
throw new TypeError(`${code} at ${path}${detail ? ` (${detail})` : ""}`);
|
|
4
4
|
}
|
|
5
|
-
function
|
|
5
|
+
function normalize(value, path, ancestors) {
|
|
6
6
|
if (value === null || typeof value === "string" || typeof value === "boolean")
|
|
7
|
-
return;
|
|
7
|
+
return value;
|
|
8
8
|
if (typeof value === "number") {
|
|
9
9
|
if (!Number.isFinite(value))
|
|
10
10
|
fail("ZR_PROPS_NUMBER", path);
|
|
11
|
-
return;
|
|
11
|
+
return value;
|
|
12
12
|
}
|
|
13
13
|
if (value === undefined)
|
|
14
14
|
fail("ZR_PROPS_UNDEFINED", path);
|
|
@@ -23,6 +23,7 @@ function validate(value, path, ancestors) {
|
|
|
23
23
|
if (ancestor !== undefined)
|
|
24
24
|
fail("ZR_PROPS_CYCLE", path, `ancestor ${ancestor}`);
|
|
25
25
|
const array = Array.isArray(record);
|
|
26
|
+
const length = array ? record.length : 0;
|
|
26
27
|
if (!array &&
|
|
27
28
|
Object.getPrototypeOf(record) !== Object.prototype &&
|
|
28
29
|
Object.getPrototypeOf(record) !== null)
|
|
@@ -30,6 +31,9 @@ function validate(value, path, ancestors) {
|
|
|
30
31
|
ancestors.set(record, path);
|
|
31
32
|
try {
|
|
32
33
|
const descriptors = Object.getOwnPropertyDescriptors(record);
|
|
34
|
+
const copy = array
|
|
35
|
+
? []
|
|
36
|
+
: Object.create(Object.getPrototypeOf(record));
|
|
33
37
|
for (const key of Reflect.ownKeys(descriptors)) {
|
|
34
38
|
if (typeof key === "symbol")
|
|
35
39
|
fail("ZR_PROPS_PROPERTY", path, "symbol key");
|
|
@@ -41,22 +45,30 @@ function validate(value, path, ancestors) {
|
|
|
41
45
|
const descriptor = descriptors[key];
|
|
42
46
|
if (!descriptor || !descriptor.enumerable || !("value" in descriptor))
|
|
43
47
|
fail("ZR_PROPS_PROPERTY", next);
|
|
44
|
-
if (array && (!/^(0|[1-9]\d*)$/.test(key) || Number(key) >=
|
|
48
|
+
if (array && (!/^(0|[1-9]\d*)$/.test(key) || Number(key) >= length))
|
|
45
49
|
fail("ZR_PROPS_PROPERTY", next);
|
|
46
|
-
|
|
50
|
+
if (!array && descriptor.value === undefined)
|
|
51
|
+
continue;
|
|
52
|
+
Object.defineProperty(copy, key, {
|
|
53
|
+
value: normalize(descriptor.value, next, ancestors),
|
|
54
|
+
enumerable: true,
|
|
55
|
+
writable: true,
|
|
56
|
+
configurable: true,
|
|
57
|
+
});
|
|
47
58
|
}
|
|
48
59
|
if (array) {
|
|
49
|
-
for (let index = 0; index <
|
|
60
|
+
for (let index = 0; index < length; index++) {
|
|
50
61
|
if (!Object.hasOwn(record, index))
|
|
51
62
|
fail("ZR_PROPS_UNDEFINED", `${path}[${index}]`);
|
|
52
63
|
}
|
|
53
64
|
}
|
|
65
|
+
return copy;
|
|
54
66
|
}
|
|
55
67
|
finally {
|
|
56
68
|
ancestors.delete(record);
|
|
57
69
|
}
|
|
58
70
|
}
|
|
59
|
-
export function
|
|
71
|
+
export function normalizeProps(props) {
|
|
60
72
|
if (props === null || Array.isArray(props) || typeof props !== "object")
|
|
61
73
|
fail("ZR_PROPS_OBJECT_KIND", "props");
|
|
62
74
|
const descriptors = Object.getOwnPropertyDescriptors(props);
|
|
@@ -69,13 +81,29 @@ export function serializeProps(props) {
|
|
|
69
81
|
delete descriptors.children;
|
|
70
82
|
}
|
|
71
83
|
const payload = Object.defineProperties(Object.create(Object.getPrototypeOf(props)), descriptors);
|
|
72
|
-
|
|
73
|
-
return JSON.stringify(payload);
|
|
84
|
+
return normalize(payload, "props", new Map());
|
|
74
85
|
}
|
|
75
|
-
function
|
|
76
|
-
return (
|
|
77
|
-
|
|
78
|
-
|
|
86
|
+
export function serializeProps(props) {
|
|
87
|
+
return JSON.stringify(normalizeProps(props));
|
|
88
|
+
}
|
|
89
|
+
export function emptyChildren(value, ancestors = new Set()) {
|
|
90
|
+
if (value == null || typeof value === "boolean")
|
|
91
|
+
return true;
|
|
92
|
+
if (!Array.isArray(value) || ancestors.has(value))
|
|
93
|
+
return false;
|
|
94
|
+
ancestors.add(value);
|
|
95
|
+
try {
|
|
96
|
+
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
97
|
+
for (let index = 0; index < value.length; index++) {
|
|
98
|
+
const descriptor = descriptors[index];
|
|
99
|
+
if (descriptor && (!("value" in descriptor) || !emptyChildren(descriptor.value, ancestors)))
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
ancestors.delete(value);
|
|
106
|
+
}
|
|
79
107
|
}
|
|
80
108
|
export function parseProps(json) {
|
|
81
109
|
let parsed;
|
|
@@ -89,7 +117,7 @@ export function parseProps(json) {
|
|
|
89
117
|
fail("ZR_PROPS_OBJECT_KIND", "props");
|
|
90
118
|
if (Object.hasOwn(parsed, "children"))
|
|
91
119
|
fail("ZR_PROPS_CHILDREN", "props.children");
|
|
92
|
-
|
|
120
|
+
normalize(parsed, "props", new Map());
|
|
93
121
|
return parsed;
|
|
94
122
|
}
|
|
95
123
|
//# sourceMappingURL=props-transport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"props-transport.js","sourceRoot":"","sources":["../../src/zudo-react/props-transport.ts"],"names":[],"mappings":"AAAA,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC;AAErE,SAAS,IAAI,CAAC,IAAY,EAAE,IAAY,EAAE,MAAM,GAAG,EAAE;IACnD,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,OAAO,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC3E,CAAC;AAED,SAAS,
|
|
1
|
+
{"version":3,"file":"props-transport.js","sourceRoot":"","sources":["../../src/zudo-react/props-transport.ts"],"names":[],"mappings":"AAAA,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC;AAErE,SAAS,IAAI,CAAC,IAAY,EAAE,IAAY,EAAE,MAAM,GAAG,EAAE;IACnD,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,OAAO,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC3E,CAAC;AAED,SAAS,SAAS,CAAC,KAAc,EAAE,IAAY,EAAE,SAA8B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O,IAAI,CAAC;IACd,CAAC;YAAS,CAAC;QACT,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;AACH,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;IACD,IAAI,MAAM,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,OAAO,MAAM,KAAK,QAAQ;QACxE,IAAI,CAAC,sBAAsB,EAAE,OAAO,CAAC,CAAC;IACxC,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;QAAE,IAAI,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,CAAC;IACnF,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;IACtC,OAAO,MAAiC,CAAC;AAC3C,CAAC","sourcesContent":["const forbidden = new Set([\"__proto__\", \"prototype\", \"constructor\"]);\n\nfunction fail(code: string, path: string, detail = \"\"): never {\n throw new TypeError(`${code} at ${path}${detail ? ` (${detail})` : \"\"}`);\n}\n\nfunction normalize(value: unknown, path: string, ancestors: Map<object, string>): unknown {\n if (value === null || typeof value === \"string\" || typeof value === \"boolean\") return value;\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) fail(\"ZR_PROPS_NUMBER\", path);\n return value;\n }\n if (value === undefined) fail(\"ZR_PROPS_UNDEFINED\", path);\n if (typeof value === \"function\" || typeof value === \"symbol\" || typeof value === \"bigint\")\n fail(`ZR_PROPS_${typeof value}`.toUpperCase(), path);\n if (typeof value !== \"object\") fail(\"ZR_PROPS_VALUE\", path);\n const record = value as object;\n if (\"$$zudo\" in record || \"$$zudoReactive\" in record) fail(\"ZR_PROPS_RUNTIME_VALUE\", path);\n const ancestor = ancestors.get(record);\n if (ancestor !== undefined) fail(\"ZR_PROPS_CYCLE\", path, `ancestor ${ancestor}`);\n const array = Array.isArray(record);\n const length = array ? (record as unknown[]).length : 0;\n if (\n !array &&\n Object.getPrototypeOf(record) !== Object.prototype &&\n Object.getPrototypeOf(record) !== null\n )\n fail(\"ZR_PROPS_OBJECT_KIND\", path);\n ancestors.set(record, path);\n try {\n const descriptors = Object.getOwnPropertyDescriptors(record);\n const copy: Record<string, unknown> | unknown[] = array\n ? []\n : Object.create(Object.getPrototypeOf(record));\n for (const key of Reflect.ownKeys(descriptors)) {\n if (typeof key === \"symbol\") fail(\"ZR_PROPS_PROPERTY\", path, \"symbol key\");\n if (array && key === \"length\") continue;\n const next = array ? `${path}[${key}]` : `${path}.${key}`;\n if (forbidden.has(key)) fail(\"ZR_PROPS_KEY\", next);\n const descriptor = descriptors[key];\n if (!descriptor || !descriptor.enumerable || !(\"value\" in descriptor))\n fail(\"ZR_PROPS_PROPERTY\", next);\n if (array && (!/^(0|[1-9]\\d*)$/.test(key) || Number(key) >= length))\n fail(\"ZR_PROPS_PROPERTY\", next);\n if (!array && descriptor.value === undefined) continue;\n Object.defineProperty(copy, key, {\n value: normalize(descriptor.value, next, ancestors),\n enumerable: true,\n writable: true,\n configurable: true,\n });\n }\n if (array) {\n for (let index = 0; index < length; index++) {\n if (!Object.hasOwn(record, index)) fail(\"ZR_PROPS_UNDEFINED\", `${path}[${index}]`);\n }\n }\n return copy;\n } finally {\n ancestors.delete(record);\n }\n}\n\nexport function normalizeProps(props: Record<string, unknown>): Record<string, unknown> {\n if (props === null || Array.isArray(props) || typeof props !== \"object\")\n fail(\"ZR_PROPS_OBJECT_KIND\", \"props\");\n const descriptors = Object.getOwnPropertyDescriptors(props);\n const child = descriptors.children;\n if (child) {\n if (!child.enumerable || !(\"value\" in child)) fail(\"ZR_PROPS_PROPERTY\", \"props.children\");\n if (!emptyChildren(child.value)) fail(\"ZR_PROPS_CHILDREN\", \"props.children\");\n delete descriptors.children;\n }\n const payload = Object.defineProperties(Object.create(Object.getPrototypeOf(props)), descriptors);\n return normalize(payload, \"props\", new Map()) as Record<string, unknown>;\n}\n\nexport function serializeProps(props: Record<string, unknown>): string {\n return JSON.stringify(normalizeProps(props));\n}\n\nexport function emptyChildren(value: unknown, ancestors = new Set<object>()): boolean {\n if (value == null || typeof value === \"boolean\") return true;\n if (!Array.isArray(value) || ancestors.has(value)) return false;\n ancestors.add(value);\n try {\n const descriptors = Object.getOwnPropertyDescriptors(value);\n for (let index = 0; index < value.length; index++) {\n const descriptor = descriptors[index];\n if (descriptor && (!(\"value\" in descriptor) || !emptyChildren(descriptor.value, ancestors)))\n return false;\n }\n return true;\n } finally {\n ancestors.delete(value);\n }\n}\n\nexport function parseProps(json: string): Record<string, unknown> {\n let parsed: unknown;\n try {\n parsed = JSON.parse(json);\n } catch {\n fail(\"ZR_PROPS_JSON\", \"props\");\n }\n if (parsed === null || Array.isArray(parsed) || typeof parsed !== \"object\")\n fail(\"ZR_PROPS_OBJECT_KIND\", \"props\");\n if (Object.hasOwn(parsed, \"children\")) fail(\"ZR_PROPS_CHILDREN\", \"props.children\");\n normalize(parsed, \"props\", new Map());\n return parsed as Record<string, unknown>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function rawHtmlReserved(payload: string, tag: string): boolean;
|