jaxs 0.3.2 → 0.4.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/jaxs.d.ts +634 -0
- package/dist/jaxs.js +793 -1071
- package/dist/jaxs.umd.cjs +1 -0
- package/package.json +41 -34
- package/.env +0 -1
- package/README.md +0 -15
- package/bun.lockb +0 -0
- package/bundle.ts +0 -5
- package/bunfig.toml +0 -0
- package/cypress/e2e/add-remove-nested-children.cy.js +0 -39
- package/cypress/e2e/add-remove-root-children.cy.js +0 -37
- package/cypress/e2e/svg-renders.cy.js +0 -10
- package/cypress/jaxs-apps/add-remove-nested-children.html +0 -12
- package/cypress/jaxs-apps/add-remove-nested-children.jsx +0 -85
- package/cypress/jaxs-apps/add-remove-root-children.html +0 -15
- package/cypress/jaxs-apps/add-remove-root-children.jsx +0 -54
- package/cypress/jaxs-apps/dist/add-remove-nested-children.afcab974.js +0 -1022
- package/cypress/jaxs-apps/dist/add-remove-nested-children.afcab974.js.map +0 -1
- package/cypress/jaxs-apps/dist/add-remove-nested-children.html +0 -12
- package/cypress/jaxs-apps/dist/add-remove-root-children.3bb9b3f5.js +0 -1665
- package/cypress/jaxs-apps/dist/add-remove-root-children.3bb9b3f5.js.map +0 -1
- package/cypress/jaxs-apps/dist/add-remove-root-children.fbb4ec9b.js +0 -1011
- package/cypress/jaxs-apps/dist/add-remove-root-children.fbb4ec9b.js.map +0 -1
- package/cypress/jaxs-apps/dist/add-remove-root-children.html +0 -15
- package/cypress/jaxs-apps/dist/svg.04290504.js +0 -644
- package/cypress/jaxs-apps/dist/svg.04290504.js.map +0 -1
- package/cypress/jaxs-apps/dist/svg.html +0 -11
- package/cypress/jaxs-apps/svg.html +0 -11
- package/cypress/jaxs-apps/svg.jsx +0 -15
- package/cypress/support/commands.js +0 -25
- package/cypress/support/e2e.js +0 -20
- package/cypress.config.js +0 -10
- package/src/app.ts +0 -84
- package/src/debugging.js +0 -5
- package/src/jaxs.ts +0 -7
- package/src/jsx.js +0 -27
- package/src/messageBus.ts +0 -70
- package/src/navigation/findHref.js +0 -10
- package/src/navigation/routeState.js +0 -15
- package/src/navigation/setupHistory.js +0 -38
- package/src/navigation/setupNavigation.js +0 -25
- package/src/navigation.ts +0 -2
- package/src/rendering/change/compile.ts +0 -1
- package/src/rendering/change/instructions/attributes.ts +0 -81
- package/src/rendering/change/instructions/children.ts +0 -127
- package/src/rendering/change/instructions/element.ts +0 -49
- package/src/rendering/change/instructions/events.ts +0 -51
- package/src/rendering/change/instructions/generate.ts +0 -122
- package/src/rendering/change/instructions/idMap.js +0 -55
- package/src/rendering/change/instructions/node.ts +0 -55
- package/src/rendering/change/instructions/text.ts +0 -10
- package/src/rendering/change.ts +0 -139
- package/src/rendering/dom/attributesAndEvents.ts +0 -33
- package/src/rendering/dom/create.ts +0 -66
- package/src/rendering/dom/svg.ts +0 -18
- package/src/rendering/templates/bound.js +0 -56
- package/src/rendering/templates/children.ts +0 -99
- package/src/rendering/templates/root.ts +0 -55
- package/src/rendering/templates/tag.ts +0 -92
- package/src/rendering/templates/text.ts +0 -17
- package/src/state/equality.js +0 -36
- package/src/state/stores.js +0 -63
- package/src/state/testingTypes.js +0 -6
- package/src/state.js +0 -89
- package/src/types.ts +0 -160
- package/src/views/conditionals.jsx +0 -18
- package/src/views/link.jsx +0 -5
- package/src/views.js +0 -7
- package/tsconfig.json +0 -26
package/dist/jaxs.d.ts
ADDED
|
@@ -0,0 +1,634 @@
|
|
|
1
|
+
declare module "state/is" {
|
|
2
|
+
export const isBoolean: (value: any) => value is boolean;
|
|
3
|
+
export const isNumber: (value: any) => value is number;
|
|
4
|
+
export const isString: (value: any) => value is string;
|
|
5
|
+
export const isArray: (value: any) => value is any[];
|
|
6
|
+
export const isObject: (value: any) => boolean;
|
|
7
|
+
}
|
|
8
|
+
declare module "state/equality" {
|
|
9
|
+
type Object = Record<string, any>;
|
|
10
|
+
export const areElementsEqual: (oldValue: any, newValue: any) => boolean;
|
|
11
|
+
export const areObjectsEqual: (oldValue: Object, newValue: Object) => any;
|
|
12
|
+
export const areArraysEqual: (oldValue: any[], newValue: any[]) => any;
|
|
13
|
+
export const areEqual: (oldValue: any, newValue: any) => any;
|
|
14
|
+
}
|
|
15
|
+
declare module "state/store-updater" {
|
|
16
|
+
import type { JaxsStore, JaxsStoreUpdateValue, JaxsStoreUpdaterFunction, JaxStoreUpdatersCollection } from "state/store";
|
|
17
|
+
export class JaxsStoreUpdater<T> {
|
|
18
|
+
store: JaxsStore<T>;
|
|
19
|
+
constructor(store: JaxsStore<T>);
|
|
20
|
+
update(updater: JaxsStoreUpdateValue<T>): void;
|
|
21
|
+
reset(): void;
|
|
22
|
+
get value(): T;
|
|
23
|
+
addUpdaterFunction(name: string, updater: JaxsStoreUpdaterFunction<T>): void;
|
|
24
|
+
addUpdaterFunctions(updaters: JaxStoreUpdatersCollection<T>): void;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
declare module "state/updaters/list" {
|
|
28
|
+
import { JaxsStoreUpdater } from "state/store-updater";
|
|
29
|
+
export type JaxsStoreListSorter<T> = (left: T, right: T) => number;
|
|
30
|
+
export class ListUpdater<T> extends JaxsStoreUpdater<T[]> {
|
|
31
|
+
push(element: T): void;
|
|
32
|
+
pop(): T;
|
|
33
|
+
unshift(element: T): void;
|
|
34
|
+
shift(): T;
|
|
35
|
+
addSorter(name: string, sorter: JaxsStoreListSorter<T>): void;
|
|
36
|
+
sortBy(sorter: JaxsStoreListSorter<T>): void;
|
|
37
|
+
insertAt(index: number, item: T): void;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
declare module "state/store" {
|
|
41
|
+
import type { JaxsState, JaxsStoreName } from "state/index";
|
|
42
|
+
import { JaxsStoreUpdater } from "state/store-updater";
|
|
43
|
+
import { JaxsStoreListSorter } from "state/updaters/list";
|
|
44
|
+
type JaxsStoreInitializationOptions<T> = {
|
|
45
|
+
name: JaxsStoreName;
|
|
46
|
+
parent: JaxsState;
|
|
47
|
+
value: T;
|
|
48
|
+
};
|
|
49
|
+
type JaxsStoreDataUpdater<T> = (originalValue: T) => T;
|
|
50
|
+
export type JaxsStoreUpdateValue<T> = T | JaxsStoreDataUpdater<T>;
|
|
51
|
+
export type JaxsStoreUpdaterFunction<T> = (value: T, ...args: any[]) => T;
|
|
52
|
+
export type JaxStoreUpdatersCollection<T> = Record<string, JaxsStoreUpdaterFunction<T>>;
|
|
53
|
+
export class JaxsStore<T> {
|
|
54
|
+
parent: JaxsState;
|
|
55
|
+
name: JaxsStoreName;
|
|
56
|
+
updater: JaxsStoreUpdater<T>;
|
|
57
|
+
_value: T;
|
|
58
|
+
initialState: T;
|
|
59
|
+
constructor(options: JaxsStoreInitializationOptions<T>);
|
|
60
|
+
get ['value'](): T;
|
|
61
|
+
set ['value'](value: T);
|
|
62
|
+
update(updater: JaxsStoreUpdateValue<T>): void;
|
|
63
|
+
updateValue(newValue: T): void;
|
|
64
|
+
getUpdatedValue(updater: JaxsStoreDataUpdater<T>): T;
|
|
65
|
+
addUpdaters(updaters: JaxStoreUpdatersCollection<T>): void;
|
|
66
|
+
addUpdater(name: string, updater: JaxsStoreUpdaterFunction<T>): void;
|
|
67
|
+
addSorter(name: string, sorter: JaxsStoreListSorter<T>): void;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
declare module "state/updaters/boolean" {
|
|
71
|
+
import { JaxsStoreUpdater } from "state/store-updater";
|
|
72
|
+
export class BooleanUpdater extends JaxsStoreUpdater<boolean> {
|
|
73
|
+
toggle(): void;
|
|
74
|
+
setTrue(): void;
|
|
75
|
+
setFalse(): void;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
declare module "state/updaters/object" {
|
|
79
|
+
import { JaxsStoreUpdater } from "state/store-updater";
|
|
80
|
+
export class ObjectUpdater<T> extends JaxsStoreUpdater<T> {
|
|
81
|
+
updateAttribute(name: keyof T, value: T[keyof T]): void;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
declare module "state/index" {
|
|
85
|
+
import { JaxsStore } from "state/store";
|
|
86
|
+
import { BooleanUpdater } from "state/updaters/boolean";
|
|
87
|
+
import { ListUpdater } from "state/updaters/list";
|
|
88
|
+
import { ObjectUpdater } from "state/updaters/object";
|
|
89
|
+
import type { StoreValue } from "types";
|
|
90
|
+
export { JaxsStoreUpdater } from "state/store-updater";
|
|
91
|
+
export type JaxsStatePublisher = (event: string, payload: any) => void;
|
|
92
|
+
export type JaxsStateTransactionUpdater = (collection: JaxsStoresCollection) => void;
|
|
93
|
+
export type JaxsStoreName = string;
|
|
94
|
+
type JaxsStoresCollection = Record<string, JaxsStore<any>>;
|
|
95
|
+
export const eventName = "state";
|
|
96
|
+
export class JaxsState {
|
|
97
|
+
publisher: JaxsStatePublisher;
|
|
98
|
+
stores: JaxsStoresCollection;
|
|
99
|
+
eventNamePrefix: string;
|
|
100
|
+
notifications: Set<JaxsStoreName>;
|
|
101
|
+
inTransaction: boolean;
|
|
102
|
+
constructor(publisher: JaxsStatePublisher);
|
|
103
|
+
create<T>(name: JaxsStoreName, initialState: T): JaxsStore<T>;
|
|
104
|
+
createBoolean(name: JaxsStoreName, initialState: boolean): JaxsStore<boolean>;
|
|
105
|
+
createRecord<T>(name: JaxsStoreName, initialState: T): JaxsStore<T>;
|
|
106
|
+
createList<T>(name: JaxsStoreName, initialState: T[]): JaxsStore<T[]>;
|
|
107
|
+
store(name: JaxsStoreName): JaxsStore<any>;
|
|
108
|
+
get(name: JaxsStoreName): StoreValue;
|
|
109
|
+
getAll(names: JaxsStoreName[]): {};
|
|
110
|
+
notify(name: JaxsStoreName): void;
|
|
111
|
+
update(name: JaxsStoreName, newValue: any): void;
|
|
112
|
+
transaction(updater: JaxsStateTransactionUpdater): void;
|
|
113
|
+
publishAll(): void;
|
|
114
|
+
publish(name: JaxsStoreName): void;
|
|
115
|
+
event(name: JaxsStoreName): string;
|
|
116
|
+
}
|
|
117
|
+
export const createState: (publisher: JaxsStatePublisher) => JaxsState;
|
|
118
|
+
export { JaxsStore, BooleanUpdater, ListUpdater, ObjectUpdater };
|
|
119
|
+
}
|
|
120
|
+
declare module "types" {
|
|
121
|
+
import { JaxsState } from "state/index";
|
|
122
|
+
export type TextValue = string | number;
|
|
123
|
+
export interface JsxIded {
|
|
124
|
+
__jsx?: string;
|
|
125
|
+
}
|
|
126
|
+
export type JsxChangeId = {
|
|
127
|
+
element: JaxsNode;
|
|
128
|
+
index: number;
|
|
129
|
+
};
|
|
130
|
+
export type EventMap = {
|
|
131
|
+
domEvent: string;
|
|
132
|
+
busEvent: string;
|
|
133
|
+
listener: EventListener;
|
|
134
|
+
};
|
|
135
|
+
export type TagEventMaps = Record<string, EventMap>;
|
|
136
|
+
interface JsxEventMapped {
|
|
137
|
+
eventMaps: TagEventMaps;
|
|
138
|
+
}
|
|
139
|
+
export type JaxsElement = Element & JsxIded & JsxEventMapped;
|
|
140
|
+
export type JaxsText = Text & JsxIded;
|
|
141
|
+
export type JaxsSvgElement = SVGElement & JsxIded;
|
|
142
|
+
export type JaxsNode = JaxsElement | JaxsText | JaxsSvgElement;
|
|
143
|
+
export type JaxsNodes = JaxsNode[] | NodeListOf<JaxsNode>;
|
|
144
|
+
export type JaxsInput = HTMLInputElement & JsxIded & JsxEventMapped;
|
|
145
|
+
type NullValues = null | undefined;
|
|
146
|
+
export type ReactSourceObject = {
|
|
147
|
+
fileName: string;
|
|
148
|
+
lineNumber: string;
|
|
149
|
+
columnNumber: string;
|
|
150
|
+
};
|
|
151
|
+
interface SourceMap {
|
|
152
|
+
__source?: ReactSourceObject;
|
|
153
|
+
}
|
|
154
|
+
export type Props<T> = Partial<{
|
|
155
|
+
__source: ReactSourceObject;
|
|
156
|
+
children: JsxCollection;
|
|
157
|
+
}> & T;
|
|
158
|
+
export type PropValue = TextValue | NullValues | boolean | ReactSourceObject | JsxCollection;
|
|
159
|
+
export type TagAttributes = SourceMap & Record<string, string>;
|
|
160
|
+
export type TagEventAttributes = Record<string, string>;
|
|
161
|
+
export type TagAttributesAndEvents = {
|
|
162
|
+
attributes: TagAttributes;
|
|
163
|
+
events: TagEventAttributes;
|
|
164
|
+
};
|
|
165
|
+
export type DomPublish = (eventName: string, domEvent: Event) => void;
|
|
166
|
+
export type Subscribe = (matcher: JaxsBusEventMatcher, listener: JaxsBusListener<any>) => void;
|
|
167
|
+
export type RenderKit = {
|
|
168
|
+
document: Document;
|
|
169
|
+
window: Window;
|
|
170
|
+
publish: DomPublish;
|
|
171
|
+
subscribe: Subscribe;
|
|
172
|
+
state: JaxsState;
|
|
173
|
+
parent?: JaxsNode | null;
|
|
174
|
+
};
|
|
175
|
+
export interface Renderable {
|
|
176
|
+
render: (renderKit: RenderKit, parentElement?: JaxsElement) => JaxsNode[];
|
|
177
|
+
isSvg: boolean;
|
|
178
|
+
}
|
|
179
|
+
export type StaticTemplate = () => Renderable;
|
|
180
|
+
export type TypedTemplate<T> = (props: Props<T>) => Renderable;
|
|
181
|
+
export type JaxsTemplate<T> = StaticTemplate | TypedTemplate<T>;
|
|
182
|
+
export type JsxCollection = (Renderable | TextValue)[];
|
|
183
|
+
export enum ChangeInstructionTypes {
|
|
184
|
+
removeNode = 0,
|
|
185
|
+
insertNode = 1,// can be to move an existing element in the dom, or to add one
|
|
186
|
+
replaceNode = 2,
|
|
187
|
+
removeAttribute = 3,
|
|
188
|
+
addAttribute = 4,
|
|
189
|
+
updateAttribute = 5,
|
|
190
|
+
removeEvent = 6,
|
|
191
|
+
addEvent = 7,
|
|
192
|
+
updateEvent = 8,
|
|
193
|
+
changeValue = 9,
|
|
194
|
+
changeText = 10
|
|
195
|
+
}
|
|
196
|
+
export type RemoveInstructionData = {
|
|
197
|
+
name: string;
|
|
198
|
+
isSvg?: boolean;
|
|
199
|
+
};
|
|
200
|
+
export type AttributeInstructionData = {
|
|
201
|
+
name: string;
|
|
202
|
+
value: string;
|
|
203
|
+
isSvg?: boolean;
|
|
204
|
+
};
|
|
205
|
+
export type EventInstructionData = {
|
|
206
|
+
name: string;
|
|
207
|
+
value: EventListener;
|
|
208
|
+
};
|
|
209
|
+
export type UpdateEventInstructionData = {
|
|
210
|
+
name: string;
|
|
211
|
+
sourceValue: EventListener;
|
|
212
|
+
targetValue: EventListener;
|
|
213
|
+
};
|
|
214
|
+
export type InsertNodeData = {
|
|
215
|
+
parent: JaxsElement;
|
|
216
|
+
index: number;
|
|
217
|
+
};
|
|
218
|
+
type NullData = Record<string, never>;
|
|
219
|
+
export type InstructionData = RemoveInstructionData | AttributeInstructionData | EventInstructionData | UpdateEventInstructionData | InsertNodeData | NullData;
|
|
220
|
+
export type ChangeInstruction = {
|
|
221
|
+
source: JaxsNode;
|
|
222
|
+
target: JaxsNode;
|
|
223
|
+
type: ChangeInstructionTypes;
|
|
224
|
+
data: InstructionData;
|
|
225
|
+
};
|
|
226
|
+
export type ChangeInstructions = Array<ChangeInstruction>;
|
|
227
|
+
export type Updater = (instruction: ChangeInstruction) => void;
|
|
228
|
+
export type StoreValue = string | number | boolean | null | StoreValue[] | {
|
|
229
|
+
[key: string]: StoreValue;
|
|
230
|
+
};
|
|
231
|
+
export type StoreMap = {
|
|
232
|
+
[key: string]: StoreValue;
|
|
233
|
+
};
|
|
234
|
+
export type JaxsViewModel<ATTRIBUTES, STORE_MAP> = (storeMap: STORE_MAP) => Partial<ATTRIBUTES>;
|
|
235
|
+
export type BindSubscriptionList = string[];
|
|
236
|
+
export type BindParams<T, U> = {
|
|
237
|
+
Template: JaxsTemplate<T>;
|
|
238
|
+
viewModel?: JaxsViewModel<T, U>;
|
|
239
|
+
subscriptions?: BindSubscriptionList;
|
|
240
|
+
};
|
|
241
|
+
export type AppAdditionListenerOptions = {
|
|
242
|
+
state: JaxsState;
|
|
243
|
+
document: Document;
|
|
244
|
+
window: Window;
|
|
245
|
+
};
|
|
246
|
+
export type DefaultBusListenerOptions<T> = {
|
|
247
|
+
publish: JaxsPublishFunction<T>;
|
|
248
|
+
eventName: string;
|
|
249
|
+
};
|
|
250
|
+
export type JaxsBusOptions = AppAdditionListenerOptions & DefaultBusListenerOptions<any>;
|
|
251
|
+
export type JaxsPublishFunction<T> = (event: string, payload: T) => void;
|
|
252
|
+
export type JaxsBusListener<T> = (payload: T, listenerKit: JaxsBusOptions) => void;
|
|
253
|
+
export type JaxsBusEventMatcher = string | RegExp;
|
|
254
|
+
export type ExactSubscriptionData<T> = {
|
|
255
|
+
listener: JaxsBusListener<T>;
|
|
256
|
+
index: number;
|
|
257
|
+
matcher: string;
|
|
258
|
+
};
|
|
259
|
+
export type FuzzySubscriptionData<T> = {
|
|
260
|
+
listener: JaxsBusListener<T>;
|
|
261
|
+
index: number;
|
|
262
|
+
matcher: RegExp;
|
|
263
|
+
};
|
|
264
|
+
export type Unsubscribe = () => void;
|
|
265
|
+
}
|
|
266
|
+
declare module "rendering/dom/tag" {
|
|
267
|
+
import type { JaxsElement, TagAttributes, TagEventAttributes, DomPublish, RenderKit } from "types";
|
|
268
|
+
export const createNode: (type: string, document: Document) => HTMLElement;
|
|
269
|
+
export const setAttributesOnElement: (element: Element, attributes: TagAttributes) => void;
|
|
270
|
+
export const setEventsOnElement: (element: JaxsElement, events: TagEventAttributes, publish: DomPublish) => void;
|
|
271
|
+
export const createDecoratedNode: (type: string, attributes: TagAttributes, events: TagEventAttributes, renderKit: RenderKit) => JaxsElement;
|
|
272
|
+
}
|
|
273
|
+
declare module "rendering/dom/svg" {
|
|
274
|
+
import type { TagAttributes, JaxsElement } from "types";
|
|
275
|
+
export const namespace = "http://www.w3.org/2000/svg";
|
|
276
|
+
export const isSvgTag: (tagType: string) => tagType is "svg";
|
|
277
|
+
export const createSvgNode: (type: string, attributes: TagAttributes, document: Document) => JaxsElement;
|
|
278
|
+
export const elementIsSvg: (element: JaxsElement) => boolean;
|
|
279
|
+
}
|
|
280
|
+
declare module "rendering/dom/text" {
|
|
281
|
+
export const createTextNode: (value: string, document: Document) => Text;
|
|
282
|
+
}
|
|
283
|
+
declare module "rendering/templates/text" {
|
|
284
|
+
import { Renderable, TextValue, RenderKit } from "types";
|
|
285
|
+
export class TextTemplate implements Renderable {
|
|
286
|
+
value: string;
|
|
287
|
+
isSvg: boolean;
|
|
288
|
+
constructor(content: TextValue);
|
|
289
|
+
render(renderKit: RenderKit): Text[];
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
declare module "rendering/templates/children/text" {
|
|
293
|
+
import { TextValue, Renderable } from "types";
|
|
294
|
+
import { TextTemplate } from "rendering/templates/text";
|
|
295
|
+
export const isTextValue: <T>(child: TextValue | T) => child is string | number | (T & string) | (T & number);
|
|
296
|
+
export const textNode: (content: TextValue) => TextTemplate;
|
|
297
|
+
export const replaceTextNodes: (child: TextValue | Renderable) => Renderable | TextTemplate;
|
|
298
|
+
}
|
|
299
|
+
declare module "rendering/templates/children/svg" {
|
|
300
|
+
import { Renderable } from "types";
|
|
301
|
+
export const withSvgFlag: (isSvg: boolean) => (template: Renderable) => Renderable;
|
|
302
|
+
}
|
|
303
|
+
declare module "rendering/templates/children/normalize" {
|
|
304
|
+
import { JsxCollection, Renderable, Props } from "types";
|
|
305
|
+
export const normalizeJsxChildren: (jsxChildren: JsxCollection, isSvg: boolean) => Renderable[];
|
|
306
|
+
export const normalizeToArray: <T>(children: T | T[]) => T[];
|
|
307
|
+
type AttributesWithChildren<T> = Props<T> & {
|
|
308
|
+
children?: JsxCollection;
|
|
309
|
+
};
|
|
310
|
+
export const ensureJsxChildrenArray: <T>(maybeChildren?: JsxCollection, attributes?: AttributesWithChildren<T>) => JsxCollection;
|
|
311
|
+
}
|
|
312
|
+
declare module "rendering/templates/tag/attributes-and-events" {
|
|
313
|
+
import type { Props, TagAttributesAndEvents, JsxCollection } from "types";
|
|
314
|
+
export const separateAttrsAndEvents: <T>(props: Props<T>, defaultValue?: string) => TagAttributesAndEvents;
|
|
315
|
+
export const packageJsxAttributes: <T>(maybeAttributes?: Props<T>, maybeChildren?: JsxCollection) => Props<T>;
|
|
316
|
+
}
|
|
317
|
+
declare module "rendering/templates/children/render" {
|
|
318
|
+
import { Renderable, RenderKit, JaxsNode } from "types";
|
|
319
|
+
export const recursiveRender: (children: Renderable[], renderKit: RenderKit, rendered?: JaxsNode[]) => JaxsNode[];
|
|
320
|
+
}
|
|
321
|
+
declare module "rendering/templates/children" {
|
|
322
|
+
import { JaxsElement, Renderable, JsxCollection, RenderKit, JaxsNodes, JaxsNode } from "types";
|
|
323
|
+
export class Children implements Renderable {
|
|
324
|
+
collection: Renderable[];
|
|
325
|
+
parentElement?: JaxsElement;
|
|
326
|
+
isSvg: boolean;
|
|
327
|
+
constructor(jsxChildren: JsxCollection, isSvg?: boolean);
|
|
328
|
+
render(renderKit: RenderKit, parentElement: JaxsElement | undefined): JaxsNode[];
|
|
329
|
+
generateDom(renderKit: RenderKit): JaxsNode[];
|
|
330
|
+
attachToParent(dom: JaxsNodes): void;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
declare module "rendering/templates/tag/jsx-key" {
|
|
334
|
+
import { TagAttributes } from "types";
|
|
335
|
+
export class JsxKey {
|
|
336
|
+
attributes: TagAttributes;
|
|
337
|
+
type: string;
|
|
338
|
+
constructor(type: string, attributes: TagAttributes);
|
|
339
|
+
generate(): string;
|
|
340
|
+
sourceKey(): string;
|
|
341
|
+
createKeyFromAttributes(): string;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
declare module "rendering/templates/tag" {
|
|
345
|
+
import type { Props, JaxsNode, TagEventAttributes, Renderable, RenderKit, TagAttributes, JsxCollection } from "types";
|
|
346
|
+
import { Children } from "rendering/templates/children";
|
|
347
|
+
export class Tag<T> implements Renderable {
|
|
348
|
+
type: string;
|
|
349
|
+
events: TagEventAttributes;
|
|
350
|
+
attributes: TagAttributes;
|
|
351
|
+
props: Props<T>;
|
|
352
|
+
children: Children;
|
|
353
|
+
isSvg: boolean;
|
|
354
|
+
constructor(tagType: string, props: Props<T>, children?: JsxCollection, isSvg?: boolean);
|
|
355
|
+
render(renderKit: RenderKit): JaxsNode[];
|
|
356
|
+
generateDom(renderKit: RenderKit): import("types").JaxsElement;
|
|
357
|
+
generateHtmlDom(renderKit: RenderKit): import("types").JaxsElement;
|
|
358
|
+
generateSvgDom(renderKit: RenderKit): import("types").JaxsElement;
|
|
359
|
+
jsxKey(): string;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
declare module "rendering/jsx" {
|
|
363
|
+
import type { JsxCollection, Props, JaxsTemplate, Renderable } from "types";
|
|
364
|
+
import { Children } from "rendering/templates/children";
|
|
365
|
+
const jsx: {
|
|
366
|
+
<T>(type: string | JaxsTemplate<T>, attributes: Props<T>, ...children: JsxCollection): Renderable;
|
|
367
|
+
fragment<T>(attributes: Props<T>, maybeChildren: JsxCollection): Children;
|
|
368
|
+
};
|
|
369
|
+
export { jsx };
|
|
370
|
+
}
|
|
371
|
+
declare module "bus/exact-subscriptions" {
|
|
372
|
+
import { ExactSubscriptionData, JaxsBusListener, Unsubscribe } from "types";
|
|
373
|
+
export class ExactSubscriptions {
|
|
374
|
+
lookup: Record<string, ExactSubscriptionData<any>[]>;
|
|
375
|
+
constructor();
|
|
376
|
+
add<T>(matcher: string, listener: JaxsBusListener<T>, index: number): Unsubscribe;
|
|
377
|
+
remove<T>(subscription: ExactSubscriptionData<T>): void;
|
|
378
|
+
matches(event: string): ExactSubscriptionData<any>[];
|
|
379
|
+
ensureArrayFor(matcher: string): void;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
declare module "bus/fuzzy-subscriptions" {
|
|
383
|
+
import { FuzzySubscriptionData, JaxsBusListener, Unsubscribe } from "types";
|
|
384
|
+
export class FuzzySubscriptions {
|
|
385
|
+
lookup: FuzzySubscriptionData<any>[];
|
|
386
|
+
constructor();
|
|
387
|
+
add<T>(matcher: RegExp, listener: JaxsBusListener<T>, index: number): Unsubscribe;
|
|
388
|
+
remove<T>(subscription: FuzzySubscriptionData<T>): void;
|
|
389
|
+
matches(event: string): FuzzySubscriptionData<any>[];
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
declare module "bus/index" {
|
|
393
|
+
import { JaxsBusEventMatcher, JaxsBusListener, Unsubscribe, AppAdditionListenerOptions, JaxsBusOptions } from "types";
|
|
394
|
+
import { ExactSubscriptions } from "bus/exact-subscriptions";
|
|
395
|
+
import { FuzzySubscriptions } from "bus/fuzzy-subscriptions";
|
|
396
|
+
class JaxsBus {
|
|
397
|
+
options?: AppAdditionListenerOptions;
|
|
398
|
+
exactSubscriptions: ExactSubscriptions;
|
|
399
|
+
fuzzySubscriptions: FuzzySubscriptions;
|
|
400
|
+
currentIndex: number;
|
|
401
|
+
constructor();
|
|
402
|
+
subscribe<T>(matcher: JaxsBusEventMatcher, listener: JaxsBusListener<T>): Unsubscribe;
|
|
403
|
+
publish<T>(event: string, payload: T): void;
|
|
404
|
+
addListenerOptions(options: AppAdditionListenerOptions): void;
|
|
405
|
+
listenerOptions(event: string): JaxsBusOptions;
|
|
406
|
+
}
|
|
407
|
+
const createBus: () => {
|
|
408
|
+
bus: JaxsBus;
|
|
409
|
+
publish: (event: string, payload: any) => void;
|
|
410
|
+
subscribe: (matcher: JaxsBusEventMatcher, listener: JaxsBusListener<any>) => Unsubscribe;
|
|
411
|
+
};
|
|
412
|
+
export { createBus, JaxsBus, ExactSubscriptions, FuzzySubscriptions };
|
|
413
|
+
}
|
|
414
|
+
declare module "rendering/templates/root" {
|
|
415
|
+
import type { JaxsElement, JaxsNodes, RenderKit, Renderable, JaxsNode } from "types";
|
|
416
|
+
export class Root {
|
|
417
|
+
template: Renderable;
|
|
418
|
+
selector: string;
|
|
419
|
+
renderKit: RenderKit;
|
|
420
|
+
dom: JaxsNodes;
|
|
421
|
+
parentElement?: JaxsElement | null;
|
|
422
|
+
constructor(template: Renderable, selector: string, renderKit: RenderKit);
|
|
423
|
+
renderAndAttach(renderKit: RenderKit): void;
|
|
424
|
+
render(renderKit: RenderKit): JaxsNode[];
|
|
425
|
+
attach(): void;
|
|
426
|
+
getParentElement(): Element;
|
|
427
|
+
}
|
|
428
|
+
export const render: (template: Renderable, selector: string, renderKit: RenderKit) => Root;
|
|
429
|
+
}
|
|
430
|
+
declare module "navigation/events" {
|
|
431
|
+
export const linkNavigationEvent = "go-to-href";
|
|
432
|
+
export const locationChangeEvent = "navigation:location-change";
|
|
433
|
+
export const routeChangeEvent = "navigation:route-change";
|
|
434
|
+
}
|
|
435
|
+
declare module "navigation/route-state" {
|
|
436
|
+
import { JaxsState } from "state/index";
|
|
437
|
+
export type RouteState = {
|
|
438
|
+
host: string;
|
|
439
|
+
path: string;
|
|
440
|
+
query: Record<string, string>;
|
|
441
|
+
};
|
|
442
|
+
export const createRouteState: (state: JaxsState) => void;
|
|
443
|
+
}
|
|
444
|
+
declare module "navigation/find-href" {
|
|
445
|
+
export const findHref: (node: HTMLElement) => string;
|
|
446
|
+
}
|
|
447
|
+
declare module "navigation/navigate" {
|
|
448
|
+
import { JaxsBusOptions } from "types";
|
|
449
|
+
export const navigate: (path: string, { publish, window }: JaxsBusOptions) => void;
|
|
450
|
+
}
|
|
451
|
+
declare module "navigation/on-link-click" {
|
|
452
|
+
import { JaxsBusOptions } from "types";
|
|
453
|
+
export const onLinkClick: (domEvent: MouseEvent, options: JaxsBusOptions) => void;
|
|
454
|
+
}
|
|
455
|
+
declare module "navigation/extract-query-params" {
|
|
456
|
+
export const extractQueryParams: (queryString: string) => {};
|
|
457
|
+
}
|
|
458
|
+
declare module "navigation/on-location-change" {
|
|
459
|
+
import { JaxsBusOptions } from "types";
|
|
460
|
+
export const onLocationChange: (_: null, listenerOptions: JaxsBusOptions) => void;
|
|
461
|
+
}
|
|
462
|
+
declare module "navigation/start" {
|
|
463
|
+
import type { App } from "app/index";
|
|
464
|
+
export const subscribeToNavigation: (app: App) => void;
|
|
465
|
+
export const subscribeToHistoryChange: (app: App) => void;
|
|
466
|
+
export const publishLocation: (app: App) => void;
|
|
467
|
+
export const startNavigation: (app: App) => void;
|
|
468
|
+
}
|
|
469
|
+
declare module "app/index" {
|
|
470
|
+
import type { Renderable, RenderKit, Subscribe, JaxsPublishFunction } from "types";
|
|
471
|
+
import type { JaxsState } from "state/index";
|
|
472
|
+
import type { JaxsBus } from "bus/index";
|
|
473
|
+
import { Root } from "rendering/templates/root";
|
|
474
|
+
export class App {
|
|
475
|
+
window: Window;
|
|
476
|
+
document: Document;
|
|
477
|
+
publish: JaxsPublishFunction<any>;
|
|
478
|
+
subscribe: Subscribe;
|
|
479
|
+
bus: JaxsBus;
|
|
480
|
+
state: JaxsState;
|
|
481
|
+
renderKit: RenderKit;
|
|
482
|
+
roots: Root[];
|
|
483
|
+
constructor({ window, document, publish, subscribe, bus, state, renderKit }: {
|
|
484
|
+
window: any;
|
|
485
|
+
document: any;
|
|
486
|
+
publish: any;
|
|
487
|
+
subscribe: any;
|
|
488
|
+
bus: any;
|
|
489
|
+
state: any;
|
|
490
|
+
renderKit: any;
|
|
491
|
+
});
|
|
492
|
+
render(template: Renderable, selector: string): Root;
|
|
493
|
+
startNavigation(): void;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
declare module "app/builder" {
|
|
497
|
+
import { App } from "app/index";
|
|
498
|
+
import { JaxsBus } from "bus/index";
|
|
499
|
+
import { JaxsState } from "state/index";
|
|
500
|
+
import { JaxsPublishFunction, Subscribe, RenderKit } from "types";
|
|
501
|
+
type CreateAppBuilderArguments = {
|
|
502
|
+
window?: Window;
|
|
503
|
+
document?: Document;
|
|
504
|
+
};
|
|
505
|
+
class AppBuilder {
|
|
506
|
+
window: Window;
|
|
507
|
+
document: Document;
|
|
508
|
+
publish: JaxsPublishFunction<any>;
|
|
509
|
+
subscribe: Subscribe;
|
|
510
|
+
bus: JaxsBus;
|
|
511
|
+
state: JaxsState;
|
|
512
|
+
renderKit: RenderKit;
|
|
513
|
+
constructor(domEnvironment: CreateAppBuilderArguments);
|
|
514
|
+
setup(): App;
|
|
515
|
+
setupDomEnvironment(domEnvironment: CreateAppBuilderArguments): void;
|
|
516
|
+
setupBus(): void;
|
|
517
|
+
setupState(): void;
|
|
518
|
+
addBusOptions(): void;
|
|
519
|
+
setRenderKit(): void;
|
|
520
|
+
}
|
|
521
|
+
const createApp: (domEnvironment?: CreateAppBuilderArguments) => App;
|
|
522
|
+
export { App, AppBuilder, createApp };
|
|
523
|
+
}
|
|
524
|
+
declare module "rendering/update/instructions/instructions" {
|
|
525
|
+
import { JaxsInput, ChangeInstruction, JaxsElement, RemoveInstructionData, AttributeInstructionData, EventInstructionData, UpdateEventInstructionData, InsertNodeData } from "types";
|
|
526
|
+
export const changeText: (source: Text, target: Text) => ChangeInstruction;
|
|
527
|
+
export const replaceNode: (source: JaxsElement, target: JaxsElement) => ChangeInstruction;
|
|
528
|
+
export const removeAttribute: (source: JaxsElement, target: JaxsElement, data: RemoveInstructionData) => ChangeInstruction;
|
|
529
|
+
export const addAttribute: (source: JaxsElement, target: JaxsElement, data: AttributeInstructionData) => ChangeInstruction;
|
|
530
|
+
export const updateAttribute: (source: JaxsElement, target: JaxsElement, data: AttributeInstructionData) => ChangeInstruction;
|
|
531
|
+
export const removeEvent: (source: JaxsElement, target: JaxsElement, data: EventInstructionData) => ChangeInstruction;
|
|
532
|
+
export const addEvent: (source: JaxsElement, target: JaxsElement, data: EventInstructionData) => ChangeInstruction;
|
|
533
|
+
export const updateEvent: (source: JaxsElement, target: JaxsElement, data: UpdateEventInstructionData) => ChangeInstruction;
|
|
534
|
+
export const removeNode: (source: JaxsElement) => ChangeInstruction;
|
|
535
|
+
export const insertNode: (target: JaxsElement, data: InsertNodeData) => ChangeInstruction;
|
|
536
|
+
export const changeValue: (source: JaxsInput, target: JaxsInput, data: AttributeInstructionData) => ChangeInstruction;
|
|
537
|
+
export const instructionsSorter: (left: ChangeInstruction, right: ChangeInstruction) => 0 | 1 | -1;
|
|
538
|
+
}
|
|
539
|
+
declare module "rendering/update/instructions/id-map" {
|
|
540
|
+
import type { JaxsNode, JaxsNodes, JsxChangeId } from "types";
|
|
541
|
+
export class IdMap {
|
|
542
|
+
map: Record<string, JsxChangeId[]>;
|
|
543
|
+
constructor();
|
|
544
|
+
populate(list: JaxsNodes): void;
|
|
545
|
+
pullMatch(element: JaxsNode): JsxChangeId;
|
|
546
|
+
clear(element: JaxsNode): void;
|
|
547
|
+
check(element: JaxsNode): boolean;
|
|
548
|
+
remaining(): JsxChangeId[];
|
|
549
|
+
}
|
|
550
|
+
export const createIdMap: (list: JaxsNodes) => IdMap;
|
|
551
|
+
}
|
|
552
|
+
declare module "rendering/update/instructions/nodes/element/attributes" {
|
|
553
|
+
import type { JaxsElement, ChangeInstructions } from "types";
|
|
554
|
+
export const compileForAttributes: (source: JaxsElement, target: JaxsElement, isSvg?: boolean) => ChangeInstructions;
|
|
555
|
+
}
|
|
556
|
+
declare module "rendering/update/instructions/nodes/element/events" {
|
|
557
|
+
import type { JaxsElement, ChangeInstructions } from "types";
|
|
558
|
+
export const compileForEvents: (source: JaxsElement, target: JaxsElement) => ChangeInstructions;
|
|
559
|
+
}
|
|
560
|
+
declare module "rendering/update/instructions/nodes/input" {
|
|
561
|
+
import { ChangeInstructions, JaxsElement } from "types";
|
|
562
|
+
export const compileForInputValue: (sourceElement: JaxsElement, targetElement: JaxsElement) => ChangeInstructions;
|
|
563
|
+
}
|
|
564
|
+
declare module "rendering/update/instructions/nodes/element" {
|
|
565
|
+
import type { JaxsElement } from "types";
|
|
566
|
+
export const compileForElement: (source: JaxsElement, target: JaxsElement) => import("types").ChangeInstruction[];
|
|
567
|
+
}
|
|
568
|
+
declare module "rendering/update/instructions/nodes/svg" {
|
|
569
|
+
import { JaxsElement } from "types";
|
|
570
|
+
export const compileForSvg: (source: JaxsElement, target: JaxsElement) => import("types").ChangeInstructions;
|
|
571
|
+
}
|
|
572
|
+
declare module "rendering/update/instructions/nodes/text" {
|
|
573
|
+
import type { ChangeInstructions } from "types";
|
|
574
|
+
export const compileForText: (source: Text, target: Text) => ChangeInstructions;
|
|
575
|
+
}
|
|
576
|
+
declare module "rendering/update/instructions/node" {
|
|
577
|
+
import type { JaxsElement, JaxsNode, JaxsNodes, ChangeInstructions } from "types";
|
|
578
|
+
type CompileChildren = (sourceList: JaxsNodes, targetList: JaxsNodes, parent: JaxsElement) => ChangeInstructions;
|
|
579
|
+
export const compileForNode: (source: JaxsNode, target: JaxsNode, compileChildren: CompileChildren) => ChangeInstructions;
|
|
580
|
+
}
|
|
581
|
+
declare module "rendering/update/instructions/collection" {
|
|
582
|
+
import type { JaxsElement, JaxsNodes } from "types";
|
|
583
|
+
export const compileCollection: (sourceList: JaxsNodes, targetList: JaxsNodes, parent: JaxsElement) => import("types").ChangeInstruction[];
|
|
584
|
+
}
|
|
585
|
+
declare module "rendering/update/perform-change" {
|
|
586
|
+
import type { JaxsElement, JaxsNodes } from "types";
|
|
587
|
+
export const performChange: (source: JaxsNodes, target: JaxsNodes, parent: JaxsElement) => void;
|
|
588
|
+
}
|
|
589
|
+
declare module "rendering/templates/bound" {
|
|
590
|
+
import { JaxsElement, JaxsNodes, Props, JaxsTemplate, RenderKit, JaxsViewModel, BindParams, BindSubscriptionList } from "types";
|
|
591
|
+
export class Bound<ATTRIBUTES, STATE_MAP> {
|
|
592
|
+
Template: JaxsTemplate<ATTRIBUTES>;
|
|
593
|
+
viewModel: JaxsViewModel<ATTRIBUTES, STATE_MAP>;
|
|
594
|
+
attributes: Partial<Props<ATTRIBUTES>>;
|
|
595
|
+
subscriptions: BindSubscriptionList;
|
|
596
|
+
dom: JaxsNodes;
|
|
597
|
+
parentElement: JaxsElement | null;
|
|
598
|
+
renderKit?: RenderKit;
|
|
599
|
+
constructor({ Template, subscriptions, attributes, viewModel }: {
|
|
600
|
+
Template: any;
|
|
601
|
+
subscriptions: any;
|
|
602
|
+
attributes: any;
|
|
603
|
+
viewModel: any;
|
|
604
|
+
});
|
|
605
|
+
render(renderKit: RenderKit): import("types").JaxsNode[];
|
|
606
|
+
generateDom(renderKit: RenderKit): import("types").JaxsNode[];
|
|
607
|
+
rerender(): void;
|
|
608
|
+
subscribeForRerender(): void;
|
|
609
|
+
eventName(storeName: string): string;
|
|
610
|
+
}
|
|
611
|
+
export const bind: <ATTRIBUTES, STATE_MAP>({ Template, viewModel, subscriptions, }: BindParams<ATTRIBUTES, STATE_MAP>) => (attributes: Partial<Props<ATTRIBUTES>>) => Bound<unknown, unknown>;
|
|
612
|
+
}
|
|
613
|
+
declare module "navigation/index" {
|
|
614
|
+
import * as events from "navigation/events";
|
|
615
|
+
import { extractQueryParams } from "navigation/extract-query-params";
|
|
616
|
+
import { findHref } from "navigation/find-href";
|
|
617
|
+
import { navigate } from "navigation/navigate";
|
|
618
|
+
import { onLinkClick } from "navigation/on-link-click";
|
|
619
|
+
import { onLocationChange } from "navigation/on-location-change";
|
|
620
|
+
import { createRouteState } from "navigation/route-state";
|
|
621
|
+
import * as start from "navigation/start";
|
|
622
|
+
export type { RouteState } from "navigation/route-state";
|
|
623
|
+
export { events, extractQueryParams, findHref, navigate, onLinkClick, onLocationChange, createRouteState, start, };
|
|
624
|
+
}
|
|
625
|
+
declare module "jaxs" {
|
|
626
|
+
export { jsx } from "rendering/jsx";
|
|
627
|
+
export { createApp } from "app/builder";
|
|
628
|
+
export { bind } from "rendering/templates/bound";
|
|
629
|
+
export * as JaxsTypes from "types";
|
|
630
|
+
export * as navigation from "navigation/index";
|
|
631
|
+
export * as appBuilding from "app/index";
|
|
632
|
+
export * as messageBus from "bus/index";
|
|
633
|
+
export * as state from "state/index";
|
|
634
|
+
}
|