creo 0.0.3-dev → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/functional/assert.d.ts +1 -0
- package/dist/functional/key.d.ts +2 -0
- package/dist/functional/maybe.d.ts +6 -0
- package/dist/functional/maybe_promise.d.ts +1 -0
- package/dist/functional/shallow_equal.d.ts +2 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +1373 -0
- package/dist/index.js.map +26 -0
- package/dist/internal/engine.d.ts +18 -0
- package/dist/internal/internal_view.d.ts +38 -0
- package/dist/internal/orchestrator.d.ts +16 -0
- package/dist/internal/wildcard.d.ts +1 -0
- package/dist/public/app.d.ts +19 -0
- package/dist/public/event_handle.d.ts +32 -0
- package/dist/public/primitive.d.ts +20 -0
- package/dist/public/primitives/primitives.d.ts +318 -0
- package/dist/public/state.d.ts +37 -0
- package/dist/public/store.d.ts +35 -0
- package/dist/public/view.d.ts +37 -0
- package/dist/render/canvas_render.d.ts +1 -0
- package/dist/render/html_render.d.ts +35 -0
- package/dist/render/json_render.d.ts +17 -0
- package/dist/render/render_interface.d.ts +7 -0
- package/dist/render/stream_render.d.ts +1 -0
- package/dist/render/string_render.d.ts +17 -0
- package/dist/structures/indexed_list.d.ts +46 -0
- package/dist/structures/list.d.ts +68 -0
- package/package.json +24 -7
- package/bun.lockb +0 -0
- package/index.html +0 -13
- package/src/main.ts +0 -13
- package/src/record/record.spec.ts +0 -146
- package/src/record/record.ts +0 -101
- package/src/style.css +0 -96
- package/src/tools/isRecordLike.spec.ts +0 -29
- package/src/tools/isRecordLike.ts +0 -3
- package/src/tools/optional.ts +0 -25
- package/src/ui/component.ts +0 -1
- package/src/ui/index.ts +0 -0
- package/src/ui/prop.ts +0 -13
- package/src/ui/state.ts +0 -0
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.json +0 -23
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { type EventHandlerProps } from "../primitive";
|
|
2
|
+
import { type PublicView } from "../view";
|
|
3
|
+
export type BaseEventData = {
|
|
4
|
+
stopPropagation: () => void;
|
|
5
|
+
preventDefault: () => void;
|
|
6
|
+
};
|
|
7
|
+
export type PointerEventData = BaseEventData & {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
};
|
|
11
|
+
export type KeyEventData = BaseEventData & {
|
|
12
|
+
key: string;
|
|
13
|
+
code: string;
|
|
14
|
+
};
|
|
15
|
+
export type InputEventData = BaseEventData & {
|
|
16
|
+
value: string;
|
|
17
|
+
};
|
|
18
|
+
export type FocusEventData = BaseEventData;
|
|
19
|
+
export type ContainerEvents = {
|
|
20
|
+
click: (e: PointerEventData) => void;
|
|
21
|
+
dblclick: (e: PointerEventData) => void;
|
|
22
|
+
pointerDown: (e: PointerEventData) => void;
|
|
23
|
+
pointerUp: (e: PointerEventData) => void;
|
|
24
|
+
pointerMove: (e: PointerEventData) => void;
|
|
25
|
+
keyDown: (e: KeyEventData) => void;
|
|
26
|
+
keyUp: (e: KeyEventData) => void;
|
|
27
|
+
focus: (e: FocusEventData) => void;
|
|
28
|
+
blur: (e: FocusEventData) => void;
|
|
29
|
+
};
|
|
30
|
+
export type FormEvents = ContainerEvents & {
|
|
31
|
+
input: (e: InputEventData) => void;
|
|
32
|
+
change: (e: InputEventData) => void;
|
|
33
|
+
keyDown: (e: KeyEventData) => void;
|
|
34
|
+
keyUp: (e: KeyEventData) => void;
|
|
35
|
+
};
|
|
36
|
+
export type HtmlAttrs = {
|
|
37
|
+
class?: string;
|
|
38
|
+
id?: string;
|
|
39
|
+
style?: string;
|
|
40
|
+
title?: string;
|
|
41
|
+
tabindex?: number;
|
|
42
|
+
hidden?: boolean;
|
|
43
|
+
role?: string;
|
|
44
|
+
draggable?: boolean;
|
|
45
|
+
[attr: string]: unknown;
|
|
46
|
+
};
|
|
47
|
+
export declare function html<Attrs extends HtmlAttrs = HtmlAttrs, Events = ContainerEvents>(tag: string): PublicView<Attrs & EventHandlerProps<Events>, void>;
|
|
48
|
+
export declare const text: PublicView<any, void>;
|
|
49
|
+
export declare const div: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
50
|
+
export declare const span: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
51
|
+
export declare const section: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
52
|
+
export declare const article: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
53
|
+
export declare const aside: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
54
|
+
export declare const nav: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
55
|
+
export declare const header: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
56
|
+
export declare const footer: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
57
|
+
export declare const main: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
58
|
+
export declare const p: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
59
|
+
export declare const h1: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
60
|
+
export declare const h2: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
61
|
+
export declare const h3: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
62
|
+
export declare const h4: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
63
|
+
export declare const h5: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
64
|
+
export declare const h6: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
65
|
+
export declare const pre: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
66
|
+
export declare const code: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
67
|
+
export declare const em: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
68
|
+
export declare const strong: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
69
|
+
export declare const small: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
70
|
+
export declare const br: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
71
|
+
export declare const hr: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
72
|
+
export declare const a: PublicView<HtmlAttrs & {
|
|
73
|
+
href?: string;
|
|
74
|
+
target?: string;
|
|
75
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
76
|
+
export declare const blockquote: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
77
|
+
export declare const label: PublicView<HtmlAttrs & {
|
|
78
|
+
for?: string;
|
|
79
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
80
|
+
export declare const ul: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
81
|
+
export declare const ol: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
82
|
+
export declare const li: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
83
|
+
export declare const table: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
84
|
+
export declare const thead: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
85
|
+
export declare const tbody: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
86
|
+
export declare const tfoot: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
87
|
+
export declare const tr: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
88
|
+
export declare const th: PublicView<HtmlAttrs & {
|
|
89
|
+
colspan?: number;
|
|
90
|
+
rowspan?: number;
|
|
91
|
+
scope?: string;
|
|
92
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
93
|
+
export declare const td: PublicView<HtmlAttrs & {
|
|
94
|
+
colspan?: number;
|
|
95
|
+
rowspan?: number;
|
|
96
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
97
|
+
export declare const form: PublicView<HtmlAttrs & {
|
|
98
|
+
action?: string;
|
|
99
|
+
method?: string;
|
|
100
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
101
|
+
export declare const button: PublicView<HtmlAttrs & {
|
|
102
|
+
disabled?: boolean;
|
|
103
|
+
type?: string;
|
|
104
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
105
|
+
export declare const input: PublicView<HtmlAttrs & {
|
|
106
|
+
type?: string;
|
|
107
|
+
value?: string;
|
|
108
|
+
placeholder?: string;
|
|
109
|
+
disabled?: boolean;
|
|
110
|
+
checked?: boolean;
|
|
111
|
+
readOnly?: boolean;
|
|
112
|
+
name?: string;
|
|
113
|
+
min?: string;
|
|
114
|
+
max?: string;
|
|
115
|
+
step?: string;
|
|
116
|
+
pattern?: string;
|
|
117
|
+
required?: boolean;
|
|
118
|
+
autofocus?: boolean;
|
|
119
|
+
} & EventHandlerProps<FormEvents>, void>;
|
|
120
|
+
export declare const textarea: PublicView<HtmlAttrs & {
|
|
121
|
+
value?: string;
|
|
122
|
+
placeholder?: string;
|
|
123
|
+
disabled?: boolean;
|
|
124
|
+
readOnly?: boolean;
|
|
125
|
+
rows?: number;
|
|
126
|
+
cols?: number;
|
|
127
|
+
name?: string;
|
|
128
|
+
required?: boolean;
|
|
129
|
+
} & EventHandlerProps<FormEvents>, void>;
|
|
130
|
+
export declare const select: PublicView<HtmlAttrs & {
|
|
131
|
+
value?: string;
|
|
132
|
+
disabled?: boolean;
|
|
133
|
+
name?: string;
|
|
134
|
+
multiple?: boolean;
|
|
135
|
+
required?: boolean;
|
|
136
|
+
} & EventHandlerProps<FormEvents>, void>;
|
|
137
|
+
export declare const option: PublicView<HtmlAttrs & {
|
|
138
|
+
value?: string;
|
|
139
|
+
selected?: boolean;
|
|
140
|
+
disabled?: boolean;
|
|
141
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
142
|
+
export declare const fieldset: PublicView<HtmlAttrs & {
|
|
143
|
+
disabled?: boolean;
|
|
144
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
145
|
+
export declare const legend: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
146
|
+
export declare const img: PublicView<HtmlAttrs & {
|
|
147
|
+
src: string;
|
|
148
|
+
alt?: string;
|
|
149
|
+
width?: number;
|
|
150
|
+
height?: number;
|
|
151
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
152
|
+
export declare const video: PublicView<HtmlAttrs & {
|
|
153
|
+
src?: string;
|
|
154
|
+
controls?: boolean;
|
|
155
|
+
autoplay?: boolean;
|
|
156
|
+
loop?: boolean;
|
|
157
|
+
muted?: boolean;
|
|
158
|
+
width?: number;
|
|
159
|
+
height?: number;
|
|
160
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
161
|
+
export declare const audio: PublicView<HtmlAttrs & {
|
|
162
|
+
src?: string;
|
|
163
|
+
controls?: boolean;
|
|
164
|
+
autoplay?: boolean;
|
|
165
|
+
loop?: boolean;
|
|
166
|
+
muted?: boolean;
|
|
167
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
168
|
+
export declare const canvas: PublicView<HtmlAttrs & {
|
|
169
|
+
width?: number;
|
|
170
|
+
height?: number;
|
|
171
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
172
|
+
export declare const source: PublicView<HtmlAttrs & {
|
|
173
|
+
src?: string;
|
|
174
|
+
type?: string;
|
|
175
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
176
|
+
export declare const details: PublicView<HtmlAttrs & {
|
|
177
|
+
open?: boolean;
|
|
178
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
179
|
+
export declare const summary: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
180
|
+
export declare const dialog: PublicView<HtmlAttrs & {
|
|
181
|
+
open?: boolean;
|
|
182
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
183
|
+
export declare const menu: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
184
|
+
export declare const iframe: PublicView<HtmlAttrs & {
|
|
185
|
+
src?: string;
|
|
186
|
+
width?: number;
|
|
187
|
+
height?: number;
|
|
188
|
+
sandbox?: string;
|
|
189
|
+
allow?: string;
|
|
190
|
+
loading?: string;
|
|
191
|
+
referrerpolicy?: string;
|
|
192
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
193
|
+
export declare const embed: PublicView<HtmlAttrs & {
|
|
194
|
+
src?: string;
|
|
195
|
+
type?: string;
|
|
196
|
+
width?: number;
|
|
197
|
+
height?: number;
|
|
198
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
199
|
+
export declare const object: PublicView<HtmlAttrs & {
|
|
200
|
+
data?: string;
|
|
201
|
+
type?: string;
|
|
202
|
+
width?: number;
|
|
203
|
+
height?: number;
|
|
204
|
+
name?: string;
|
|
205
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
206
|
+
export declare const picture: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
207
|
+
export declare const portal: PublicView<HtmlAttrs & {
|
|
208
|
+
src?: string;
|
|
209
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
210
|
+
export declare const svg: PublicView<HtmlAttrs & {
|
|
211
|
+
viewBox?: string;
|
|
212
|
+
xmlns?: string;
|
|
213
|
+
width?: number | string;
|
|
214
|
+
height?: number | string;
|
|
215
|
+
fill?: string;
|
|
216
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
217
|
+
export declare const script: PublicView<HtmlAttrs & {
|
|
218
|
+
src?: string;
|
|
219
|
+
type?: string;
|
|
220
|
+
async?: boolean;
|
|
221
|
+
defer?: boolean;
|
|
222
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
223
|
+
export declare const noscript: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
224
|
+
export declare const template: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
225
|
+
export declare const slot: PublicView<HtmlAttrs & {
|
|
226
|
+
name?: string;
|
|
227
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
228
|
+
export declare const address: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
229
|
+
export declare const hgroup: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
230
|
+
export declare const search: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
231
|
+
export declare const abbr: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
232
|
+
export declare const b: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
233
|
+
export declare const bdi: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
234
|
+
export declare const bdo: PublicView<HtmlAttrs & {
|
|
235
|
+
dir?: string;
|
|
236
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
237
|
+
export declare const cite: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
238
|
+
export declare const data: PublicView<HtmlAttrs & {
|
|
239
|
+
value?: string;
|
|
240
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
241
|
+
export declare const dfn: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
242
|
+
export declare const i: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
243
|
+
export declare const kbd: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
244
|
+
export declare const mark: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
245
|
+
export declare const q: PublicView<HtmlAttrs & {
|
|
246
|
+
cite?: string;
|
|
247
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
248
|
+
export declare const rp: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
249
|
+
export declare const rt: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
250
|
+
export declare const ruby: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
251
|
+
export declare const s: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
252
|
+
export declare const samp: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
253
|
+
export declare const sub: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
254
|
+
export declare const sup: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
255
|
+
export declare const time: PublicView<HtmlAttrs & {
|
|
256
|
+
datetime?: string;
|
|
257
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
258
|
+
export declare const u: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
259
|
+
export declare const varEl: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
260
|
+
export declare const wbr: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
261
|
+
export declare const del: PublicView<HtmlAttrs & {
|
|
262
|
+
cite?: string;
|
|
263
|
+
datetime?: string;
|
|
264
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
265
|
+
export declare const ins: PublicView<HtmlAttrs & {
|
|
266
|
+
cite?: string;
|
|
267
|
+
datetime?: string;
|
|
268
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
269
|
+
export declare const caption: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
270
|
+
export declare const colgroup: PublicView<HtmlAttrs & {
|
|
271
|
+
span?: number;
|
|
272
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
273
|
+
export declare const col: PublicView<HtmlAttrs & {
|
|
274
|
+
span?: number;
|
|
275
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
276
|
+
export declare const datalist: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
277
|
+
export declare const optgroup: PublicView<HtmlAttrs & {
|
|
278
|
+
label?: string;
|
|
279
|
+
disabled?: boolean;
|
|
280
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
281
|
+
export declare const output: PublicView<HtmlAttrs & {
|
|
282
|
+
for?: string;
|
|
283
|
+
name?: string;
|
|
284
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
285
|
+
export declare const progress: PublicView<HtmlAttrs & {
|
|
286
|
+
value?: number;
|
|
287
|
+
max?: number;
|
|
288
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
289
|
+
export declare const meter: PublicView<HtmlAttrs & {
|
|
290
|
+
value?: number;
|
|
291
|
+
min?: number;
|
|
292
|
+
max?: number;
|
|
293
|
+
low?: number;
|
|
294
|
+
high?: number;
|
|
295
|
+
optimum?: number;
|
|
296
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
297
|
+
export declare const figure: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
298
|
+
export declare const figcaption: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
299
|
+
export declare const dd: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
300
|
+
export declare const dl: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
301
|
+
export declare const dt: PublicView<HtmlAttrs & EventHandlerProps<ContainerEvents>, void>;
|
|
302
|
+
export declare const track: PublicView<HtmlAttrs & {
|
|
303
|
+
src?: string;
|
|
304
|
+
kind?: string;
|
|
305
|
+
srclang?: string;
|
|
306
|
+
label?: string;
|
|
307
|
+
default?: boolean;
|
|
308
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
309
|
+
export declare const map: PublicView<HtmlAttrs & {
|
|
310
|
+
name?: string;
|
|
311
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
312
|
+
export declare const area: PublicView<HtmlAttrs & {
|
|
313
|
+
alt?: string;
|
|
314
|
+
coords?: string;
|
|
315
|
+
href?: string;
|
|
316
|
+
shape?: string;
|
|
317
|
+
target?: string;
|
|
318
|
+
} & EventHandlerProps<ContainerEvents>, void>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { MaybePromise } from "../functional/maybe_promise";
|
|
2
|
+
/**
|
|
3
|
+
* Reactive value — the shared interface returned by `use()`.
|
|
4
|
+
* Both local state and store bindings implement this.
|
|
5
|
+
*/
|
|
6
|
+
export interface Reactive<T> {
|
|
7
|
+
get(): T;
|
|
8
|
+
set(value: T): void;
|
|
9
|
+
update(fn: (current: T) => MaybePromise<T>): void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A single reactive state slot.
|
|
13
|
+
* Returned by calling use(initial) during view init.
|
|
14
|
+
*
|
|
15
|
+
* const count = use(0);
|
|
16
|
+
* count.get() // read current value
|
|
17
|
+
* count.set(5) // set immediately, schedule render
|
|
18
|
+
* count.update(n => n + 1) // update via fn, schedule render
|
|
19
|
+
*/
|
|
20
|
+
export declare class State<T> implements Reactive<T> {
|
|
21
|
+
#private;
|
|
22
|
+
constructor(initial: T, schedule: () => void);
|
|
23
|
+
get(): T;
|
|
24
|
+
set(value: T): void;
|
|
25
|
+
update(fn: (current: T) => MaybePromise<T>): void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Use factory bound to a view.
|
|
29
|
+
* Tracks instances by call order (like React hooks).
|
|
30
|
+
*
|
|
31
|
+
* use(store) — subscribe to a Store, returns Store<T> (Reactive<T>)
|
|
32
|
+
* use(initial) — create local State<T> (Reactive<T>)
|
|
33
|
+
*/
|
|
34
|
+
export type Use = {
|
|
35
|
+
<T>(storeOrInitial: import("../public/store").Store<T>): Reactive<T>;
|
|
36
|
+
<T>(initial: T): Reactive<T>;
|
|
37
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { MaybePromise } from "../functional/maybe_promise";
|
|
2
|
+
declare const $store: unique symbol;
|
|
3
|
+
/**
|
|
4
|
+
* Store — globally visible reactive data.
|
|
5
|
+
*
|
|
6
|
+
* Create a store:
|
|
7
|
+
* const ThemeStore = store.new("light");
|
|
8
|
+
*
|
|
9
|
+
* Set from anywhere:
|
|
10
|
+
* ThemeStore.set("dark"); // updates all subscribers
|
|
11
|
+
*
|
|
12
|
+
* Read from a view:
|
|
13
|
+
* const myView = view(({ use }) => {
|
|
14
|
+
* const theme = use(ThemeStore); // re-renders on change
|
|
15
|
+
* return {
|
|
16
|
+
* render() {
|
|
17
|
+
* div(() => text(`Current theme: ${theme.get()}`));
|
|
18
|
+
* }
|
|
19
|
+
* };
|
|
20
|
+
* });
|
|
21
|
+
*/
|
|
22
|
+
export declare class Store<T> {
|
|
23
|
+
#private;
|
|
24
|
+
readonly [$store] = true;
|
|
25
|
+
constructor(initial: T);
|
|
26
|
+
get(): T;
|
|
27
|
+
set(value: T): void;
|
|
28
|
+
update(fn: (current: T) => MaybePromise<T>): void;
|
|
29
|
+
subscribe(cb: () => void): () => void;
|
|
30
|
+
}
|
|
31
|
+
export declare function isStore(value: unknown): value is Store<unknown>;
|
|
32
|
+
export declare const store: {
|
|
33
|
+
"new"<T>(initial: T): Store<T>;
|
|
34
|
+
};
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Key } from "../functional/key";
|
|
2
|
+
import type { Maybe } from "../functional/maybe";
|
|
3
|
+
import type { Use } from "./state";
|
|
4
|
+
import type { PendingView } from "../internal/internal_view";
|
|
5
|
+
import type { $primitive } from "./primitive";
|
|
6
|
+
export type ViewBody<Props, Api> = Api extends void ? {
|
|
7
|
+
render: () => void;
|
|
8
|
+
onMount?: () => void;
|
|
9
|
+
shouldUpdate?: (nextProps: Props) => boolean;
|
|
10
|
+
onUpdateBefore?: () => void;
|
|
11
|
+
onUpdateafter?: () => void;
|
|
12
|
+
} : {
|
|
13
|
+
render: () => void;
|
|
14
|
+
onMount?: () => void;
|
|
15
|
+
shouldUpdate?: (nextProps: Props) => boolean;
|
|
16
|
+
onUpdateBefore?: () => void;
|
|
17
|
+
onUpdateafter?: () => void;
|
|
18
|
+
api: Api;
|
|
19
|
+
};
|
|
20
|
+
/** Slot callback — passed by the caller at the call site. */
|
|
21
|
+
export type Slot = () => void;
|
|
22
|
+
/** Children — pre-collected PendingViews available inside the view. */
|
|
23
|
+
export type Children = Maybe<PendingView[]>;
|
|
24
|
+
export type ViewFn<Props, Api> = {
|
|
25
|
+
(ctx: {
|
|
26
|
+
props: () => Props;
|
|
27
|
+
use: Use;
|
|
28
|
+
slot: Slot;
|
|
29
|
+
}): ViewBody<Props, Api>;
|
|
30
|
+
[$primitive]?: string;
|
|
31
|
+
};
|
|
32
|
+
export declare function view<Props = void, Api = void>(body: ViewFn<Props, Api>): (props: Props extends void ? {
|
|
33
|
+
key?: Key;
|
|
34
|
+
} | void : Props & {
|
|
35
|
+
key?: Key;
|
|
36
|
+
}, slot?: Slot) => void;
|
|
37
|
+
export type PublicView<Props, Api> = ReturnType<typeof view<Props, Api>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { View } from "../internal/internal_view";
|
|
2
|
+
import type { IRender } from "./render_interface";
|
|
3
|
+
export declare class HtmlRender implements IRender<HTMLElement | Text> {
|
|
4
|
+
private container;
|
|
5
|
+
constructor(container: HTMLElement);
|
|
6
|
+
render(view: View): void;
|
|
7
|
+
unmount(view: View): void;
|
|
8
|
+
private buildDom;
|
|
9
|
+
private isEventProp;
|
|
10
|
+
private eventPropToCreoName;
|
|
11
|
+
private setAttributes;
|
|
12
|
+
private diffAttributes;
|
|
13
|
+
private bindEvent;
|
|
14
|
+
private unbindEvent;
|
|
15
|
+
private mapEventData;
|
|
16
|
+
private setAttribute;
|
|
17
|
+
private removeAttribute;
|
|
18
|
+
/**
|
|
19
|
+
* Compute where a view's DOM node should be placed in its parent.
|
|
20
|
+
*
|
|
21
|
+
* Fast paths (O(1)):
|
|
22
|
+
* - Last child → endComment (composite) or null/appendChild (primitive)
|
|
23
|
+
* - Previous sibling rendered → nextSibling of prev's last DOM node
|
|
24
|
+
*
|
|
25
|
+
* Slow path (O(k)): walk backward through unrendered siblings.
|
|
26
|
+
*
|
|
27
|
+
* Composite parents always return endComment as fallback (never null),
|
|
28
|
+
* so insertBefore(node, result) is safe for all parent types.
|
|
29
|
+
*/
|
|
30
|
+
private fastInsertionPoint;
|
|
31
|
+
private getParentDomNode;
|
|
32
|
+
private moveDomNodes;
|
|
33
|
+
private getFirstDomNode;
|
|
34
|
+
private removeDomNodes;
|
|
35
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { View } from "../internal/internal_view";
|
|
2
|
+
import type { IRender } from "./render_interface";
|
|
3
|
+
import type { Maybe } from "../functional/maybe";
|
|
4
|
+
export type JsonNode = {
|
|
5
|
+
type: string;
|
|
6
|
+
props: Record<string, unknown>;
|
|
7
|
+
children: JsonNode[];
|
|
8
|
+
key?: string | number;
|
|
9
|
+
};
|
|
10
|
+
export declare class JsonRender implements IRender<JsonNode> {
|
|
11
|
+
/** The root JSON node after mount. */
|
|
12
|
+
root: Maybe<JsonNode>;
|
|
13
|
+
render(view: View): void;
|
|
14
|
+
unmount(view: View): void;
|
|
15
|
+
private getNextSibling;
|
|
16
|
+
private buildNode;
|
|
17
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { View } from "../internal/internal_view";
|
|
2
|
+
export interface IRender<Output> {
|
|
3
|
+
/** Create output if view is new (no renderRef), or update if existing. */
|
|
4
|
+
render(view: View): void;
|
|
5
|
+
/** Remove a view's output artifacts. Called from View[Symbol.dispose]. */
|
|
6
|
+
unmount(view: View): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { View } from "../internal/internal_view";
|
|
2
|
+
import type { IRender } from "./render_interface";
|
|
3
|
+
/**
|
|
4
|
+
* Stateless string renderer — pull-based.
|
|
5
|
+
* mount/unmount/update are no-ops. Call renderToString() to
|
|
6
|
+
* get the current HTML string from the VDOM.
|
|
7
|
+
*/
|
|
8
|
+
export declare class StringRender implements IRender<string> {
|
|
9
|
+
private rootView;
|
|
10
|
+
render(view: View): void;
|
|
11
|
+
unmount(_view: View): void;
|
|
12
|
+
/** Build and return the current HTML string from the VDOM. */
|
|
13
|
+
renderToString(): string;
|
|
14
|
+
private buildString;
|
|
15
|
+
private buildVoidTag;
|
|
16
|
+
private buildChildren;
|
|
17
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IndexedList — linked list with O(1) identity-based lookup.
|
|
3
|
+
*
|
|
4
|
+
* Combines a doubly-linked list (O(1) insert/delete given a node)
|
|
5
|
+
* with a Map<T, INode<T>> for O(1) lookup by value identity.
|
|
6
|
+
*
|
|
7
|
+
* All mutating operations are O(1):
|
|
8
|
+
* push, delete, has, first, last, clear
|
|
9
|
+
*/
|
|
10
|
+
import { type INode } from "./list";
|
|
11
|
+
import type { Maybe } from "../functional/maybe";
|
|
12
|
+
export declare class IndexedList<T> {
|
|
13
|
+
#private;
|
|
14
|
+
/** Append item to the end. No-op if already present. Returns the node. */
|
|
15
|
+
push(item: T): INode<T>;
|
|
16
|
+
/** Insert item at the front. No-op if already present. */
|
|
17
|
+
unshift(item: T): void;
|
|
18
|
+
/** Insert item after ref. No-op if item already present. */
|
|
19
|
+
insertAfter(ref: T, item: T): void;
|
|
20
|
+
/** Remove item. O(1). */
|
|
21
|
+
delete(item: T): void;
|
|
22
|
+
/** Check membership. O(1). */
|
|
23
|
+
has(item: T): boolean;
|
|
24
|
+
/** Number of items. */
|
|
25
|
+
get length(): number;
|
|
26
|
+
/** Get the first item (head). O(1). */
|
|
27
|
+
first(): Maybe<T>;
|
|
28
|
+
/** Get the last item (tail). O(1). */
|
|
29
|
+
last(): Maybe<T>;
|
|
30
|
+
/** Get the linked-list node for an item. O(1). */
|
|
31
|
+
getNode(item: T): Maybe<INode<T>>;
|
|
32
|
+
/** Positional access. O(n) — prefer getNode + getNext for traversal. */
|
|
33
|
+
at(index: number): Maybe<T>;
|
|
34
|
+
/**
|
|
35
|
+
* Replace item at `pos`, or insert if nothing is there.
|
|
36
|
+
* If `pos >= length`, appends to the end.
|
|
37
|
+
* Returns the node.
|
|
38
|
+
*/
|
|
39
|
+
upsert(pos: number, item: T): INode<T>;
|
|
40
|
+
/** Swap two items in the list. O(1). No-op if either item is missing. */
|
|
41
|
+
swap(a: T, b: T): void;
|
|
42
|
+
/** Reset to empty. O(1). */
|
|
43
|
+
clear(): void;
|
|
44
|
+
/** Iterate values in insertion order. */
|
|
45
|
+
[Symbol.iterator](): IterableIterator<T>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Linked list implementation
|
|
3
|
+
*/
|
|
4
|
+
import type { Maybe } from "../functional/maybe";
|
|
5
|
+
declare const $next: unique symbol;
|
|
6
|
+
declare const $prev: unique symbol;
|
|
7
|
+
declare const $owner: unique symbol;
|
|
8
|
+
export interface INode<T> {
|
|
9
|
+
insertNext(value: T): INode<T>;
|
|
10
|
+
insertPrev(value: T): INode<T>;
|
|
11
|
+
v: T;
|
|
12
|
+
delete(): void;
|
|
13
|
+
getNext(): Maybe<INode<T>>;
|
|
14
|
+
getPrev(): Maybe<INode<T>>;
|
|
15
|
+
isFirst(): boolean;
|
|
16
|
+
isLast(): boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare class ListNode<T> implements INode<T> {
|
|
19
|
+
[$owner]: Maybe<IBaseContainer<T>>;
|
|
20
|
+
[$next]: Maybe<ListNode<T>>;
|
|
21
|
+
[$prev]: Maybe<ListNode<T>>;
|
|
22
|
+
v: T;
|
|
23
|
+
constructor(node: T, prev: Maybe<ListNode<T>>, next: Maybe<ListNode<T>>, list: IBaseContainer<T>);
|
|
24
|
+
isFirst(): boolean;
|
|
25
|
+
isLast(): boolean;
|
|
26
|
+
delete(): void;
|
|
27
|
+
clearFields(): void;
|
|
28
|
+
insertNext(value: T): INode<T>;
|
|
29
|
+
insertPrev(value: T): INode<T>;
|
|
30
|
+
getNext(): Maybe<ListNode<T>>;
|
|
31
|
+
getPrev(): Maybe<ListNode<T>>;
|
|
32
|
+
getList(): Maybe<IBaseContainer<T>>;
|
|
33
|
+
}
|
|
34
|
+
interface IBaseContainer<T> {
|
|
35
|
+
delete(node: INode<T>): void;
|
|
36
|
+
insertNext(ref: INode<T>, value: T): INode<T>;
|
|
37
|
+
insertPrev(ref: INode<T>, value: T): INode<T>;
|
|
38
|
+
}
|
|
39
|
+
export interface IList<T> extends Iterable<INode<T>>, IBaseContainer<T> {
|
|
40
|
+
insertStart(value: T): INode<T>;
|
|
41
|
+
insertEnd(value: T): INode<T>;
|
|
42
|
+
at(n: number): Maybe<INode<T>>;
|
|
43
|
+
first(): Maybe<INode<T>>;
|
|
44
|
+
last(): Maybe<INode<T>>;
|
|
45
|
+
readonly size: number;
|
|
46
|
+
[Symbol.iterator](): IterableIterator<INode<T>>;
|
|
47
|
+
}
|
|
48
|
+
export declare class InternalList<T> implements IList<T> {
|
|
49
|
+
#private;
|
|
50
|
+
insertStart(value: T): ListNode<T>;
|
|
51
|
+
delete(node: INode<T>): void;
|
|
52
|
+
at(n: number): Maybe<ListNode<T>>;
|
|
53
|
+
get size(): number;
|
|
54
|
+
/** Reset the list to empty. O(1). */
|
|
55
|
+
clear(): void;
|
|
56
|
+
/** O(1) head access. */
|
|
57
|
+
first(): Maybe<ListNode<T>>;
|
|
58
|
+
/** O(1) tail access. */
|
|
59
|
+
last(): Maybe<ListNode<T>>;
|
|
60
|
+
insertEnd(value: T): ListNode<T>;
|
|
61
|
+
insertNext(ref: INode<T>, value: T): ListNode<T>;
|
|
62
|
+
insertPrev(ref: INode<T>, value: T): ListNode<T>;
|
|
63
|
+
[Symbol.iterator](): Generator<ListNode<T>, void, unknown>;
|
|
64
|
+
}
|
|
65
|
+
export declare class List<T> extends InternalList<T> implements IList<T> {
|
|
66
|
+
static from<T>(arrayLike: Iterable<T>): List<T>;
|
|
67
|
+
}
|
|
68
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,15 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "creo",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
5
17
|
"scripts": {
|
|
6
|
-
"
|
|
7
|
-
"build": "
|
|
8
|
-
"
|
|
18
|
+
"build": "bun run build.ts",
|
|
19
|
+
"build-only": "rm -rf ./dist/*; bun run build.ts",
|
|
20
|
+
"test": "bun test src/",
|
|
21
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
22
|
+
"prepublishOnly": "bun run build"
|
|
9
23
|
},
|
|
10
24
|
"devDependencies": {
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
25
|
+
"@types/bun": "latest",
|
|
26
|
+
"happy-dom": "^20.8.4",
|
|
27
|
+
"tsc-alias": "^1.8.16"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"typescript": "^5"
|
|
14
31
|
}
|
|
15
32
|
}
|
package/bun.lockb
DELETED
|
Binary file
|