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.
Files changed (69) hide show
  1. package/dist/jaxs.d.ts +634 -0
  2. package/dist/jaxs.js +793 -1071
  3. package/dist/jaxs.umd.cjs +1 -0
  4. package/package.json +41 -34
  5. package/.env +0 -1
  6. package/README.md +0 -15
  7. package/bun.lockb +0 -0
  8. package/bundle.ts +0 -5
  9. package/bunfig.toml +0 -0
  10. package/cypress/e2e/add-remove-nested-children.cy.js +0 -39
  11. package/cypress/e2e/add-remove-root-children.cy.js +0 -37
  12. package/cypress/e2e/svg-renders.cy.js +0 -10
  13. package/cypress/jaxs-apps/add-remove-nested-children.html +0 -12
  14. package/cypress/jaxs-apps/add-remove-nested-children.jsx +0 -85
  15. package/cypress/jaxs-apps/add-remove-root-children.html +0 -15
  16. package/cypress/jaxs-apps/add-remove-root-children.jsx +0 -54
  17. package/cypress/jaxs-apps/dist/add-remove-nested-children.afcab974.js +0 -1022
  18. package/cypress/jaxs-apps/dist/add-remove-nested-children.afcab974.js.map +0 -1
  19. package/cypress/jaxs-apps/dist/add-remove-nested-children.html +0 -12
  20. package/cypress/jaxs-apps/dist/add-remove-root-children.3bb9b3f5.js +0 -1665
  21. package/cypress/jaxs-apps/dist/add-remove-root-children.3bb9b3f5.js.map +0 -1
  22. package/cypress/jaxs-apps/dist/add-remove-root-children.fbb4ec9b.js +0 -1011
  23. package/cypress/jaxs-apps/dist/add-remove-root-children.fbb4ec9b.js.map +0 -1
  24. package/cypress/jaxs-apps/dist/add-remove-root-children.html +0 -15
  25. package/cypress/jaxs-apps/dist/svg.04290504.js +0 -644
  26. package/cypress/jaxs-apps/dist/svg.04290504.js.map +0 -1
  27. package/cypress/jaxs-apps/dist/svg.html +0 -11
  28. package/cypress/jaxs-apps/svg.html +0 -11
  29. package/cypress/jaxs-apps/svg.jsx +0 -15
  30. package/cypress/support/commands.js +0 -25
  31. package/cypress/support/e2e.js +0 -20
  32. package/cypress.config.js +0 -10
  33. package/src/app.ts +0 -84
  34. package/src/debugging.js +0 -5
  35. package/src/jaxs.ts +0 -7
  36. package/src/jsx.js +0 -27
  37. package/src/messageBus.ts +0 -70
  38. package/src/navigation/findHref.js +0 -10
  39. package/src/navigation/routeState.js +0 -15
  40. package/src/navigation/setupHistory.js +0 -38
  41. package/src/navigation/setupNavigation.js +0 -25
  42. package/src/navigation.ts +0 -2
  43. package/src/rendering/change/compile.ts +0 -1
  44. package/src/rendering/change/instructions/attributes.ts +0 -81
  45. package/src/rendering/change/instructions/children.ts +0 -127
  46. package/src/rendering/change/instructions/element.ts +0 -49
  47. package/src/rendering/change/instructions/events.ts +0 -51
  48. package/src/rendering/change/instructions/generate.ts +0 -122
  49. package/src/rendering/change/instructions/idMap.js +0 -55
  50. package/src/rendering/change/instructions/node.ts +0 -55
  51. package/src/rendering/change/instructions/text.ts +0 -10
  52. package/src/rendering/change.ts +0 -139
  53. package/src/rendering/dom/attributesAndEvents.ts +0 -33
  54. package/src/rendering/dom/create.ts +0 -66
  55. package/src/rendering/dom/svg.ts +0 -18
  56. package/src/rendering/templates/bound.js +0 -56
  57. package/src/rendering/templates/children.ts +0 -99
  58. package/src/rendering/templates/root.ts +0 -55
  59. package/src/rendering/templates/tag.ts +0 -92
  60. package/src/rendering/templates/text.ts +0 -17
  61. package/src/state/equality.js +0 -36
  62. package/src/state/stores.js +0 -63
  63. package/src/state/testingTypes.js +0 -6
  64. package/src/state.js +0 -89
  65. package/src/types.ts +0 -160
  66. package/src/views/conditionals.jsx +0 -18
  67. package/src/views/link.jsx +0 -5
  68. package/src/views.js +0 -7
  69. package/tsconfig.json +0 -26
package/src/types.ts DELETED
@@ -1,160 +0,0 @@
1
- // Rendering & Dom ------
2
- import { State } from './state'
3
- export type DomEventPublisher = (eventName: string, domEvent: Event) => void;
4
-
5
- export type RenderKit = {
6
- document: Document;
7
- window: Window;
8
- publish: DomEventPublisher;
9
- subscribe: BusSubscribe;
10
- state: State;
11
- parent?: Element | null;
12
- };
13
-
14
- export interface JsxId {
15
- __jsx: string;
16
- }
17
- export interface ExpandedElement extends Element, JsxId {
18
- eventMaps: EventMaps;
19
- }
20
- export interface InputElement extends ExpandedElement {
21
- // deno-lint-ignore no-explicit-any
22
- value: any;
23
- }
24
- export type Dom = Text | ExpandedElement | SVGElement;
25
- export type DomCollection = Dom[];
26
- export type HtmlChildren =
27
- | HTMLCollection
28
- | NodeListOf<ChildNode>
29
- | DomCollection;
30
- export type TextValue = string | number;
31
- export type EventMap = {
32
- domEvent: string;
33
- busEvent: string;
34
- listener: EventListener;
35
- };
36
- export type EventMaps = Record<string, EventMap>;
37
-
38
- // deno-lint-ignore no-explicit-any
39
- export type Attributes = Record<string, any>;
40
- export type EventAttributes = Record<string, string>;
41
- export type AttributesAndEvents = {
42
- attributes: Attributes;
43
- events: EventAttributes;
44
- };
45
-
46
- export type TemplateEventListeners = Record<string, EventListener>;
47
-
48
- export interface Template {
49
- isSvg?: boolean,
50
- render: (
51
- renderKit: RenderKit,
52
- parentElement?: Element,
53
- ) => DomCollection;
54
- }
55
- export type TemplateClass = (attributes: Attributes) => Template;
56
-
57
- export type ViewModel = (state: Record<string,any>) => State;
58
-
59
- // Message Bus ----
60
- export type BusEventName = string;
61
- // deno-lint-ignore no-explicit-any
62
- export type BusOptions = Record<string, any>;
63
- // deno-lint-ignore no-explicit-any
64
- export type BusPayload = any;
65
- export type BusPublish = (eventName: BusEventName, payload: BusPayload) => void;
66
- export type BusSubscribe = (
67
- eventName: BusEventName,
68
- listener: BusListener,
69
- ) => void;
70
- export interface BusListenerKit {
71
- publish: BusPublish;
72
- eventName: BusEventName;
73
- // deno-lint-ignore no-explicit-any
74
- [key: string]: any;
75
- }
76
- export type BusListener = (
77
- payload: BusPayload,
78
- listenerKit: BusListenerKit,
79
- ) => void;
80
- export type BusListenersMap = Record<BusEventName, BusPayload>;
81
-
82
- // Change instructions
83
- export type RemoveInstructionData = {
84
- name: string;
85
- isSvg?: boolean;
86
- };
87
-
88
- export type AttributeInstructionData = {
89
- name: string;
90
- value: string;
91
- isSvg?: boolean;
92
- };
93
-
94
- export type EventInstructionData = {
95
- name: string;
96
- value: EventListener;
97
- };
98
-
99
- export type UpdateEventInstructionData = {
100
- name: string;
101
- sourceValue: EventListener;
102
- targetValue: EventListener;
103
- };
104
-
105
- export type InsertNodeData = {
106
- parent: ExpandedElement;
107
- index: number;
108
- };
109
-
110
- type NullData = Record<string, never>;
111
-
112
- export type InstructionData =
113
- | RemoveInstructionData
114
- | AttributeInstructionData
115
- | EventInstructionData
116
- | UpdateEventInstructionData
117
- | InsertNodeData
118
- | NullData;
119
-
120
- export type Instruction = {
121
- source: Dom;
122
- target: Dom;
123
- type: ChangeInstructions;
124
- data: InstructionData;
125
- };
126
-
127
- export type Instructions = Array<Instruction>;
128
-
129
- export enum ChangeInstructions {
130
- removeNode,
131
- insertNode, // can be to move an existing element in the dom, or to add one
132
- replaceNode,
133
- removeAttribute,
134
- addAttribute,
135
- updateAttribute,
136
- removeEvent,
137
- addEvent,
138
- updateEvent,
139
- changeValue,
140
- changeText,
141
- }
142
-
143
- export type Updater = (instruction: Instruction) => void;
144
-
145
- export type App = {
146
- publish?: BusPublish;
147
- subscribe?: BusSubscribe;
148
- // deno-lint-ignore no-explicit-any
149
- bus?: any;
150
- state?: State
151
- renderKit: RenderKit;
152
- render: (template: Template, selector: string) => Template;
153
- window: Window;
154
- document: Document;
155
- };
156
-
157
- export type DomEnvironment = {
158
- document?: Document;
159
- window?: Window;
160
- }
@@ -1,18 +0,0 @@
1
- import jsx from '../jsx'
2
-
3
- export const If = ({ condition, children }) => {
4
- if (!condition) return
5
- return <>{children}</>
6
- }
7
-
8
- export const Unless = ({ condition, children }) => {
9
- if (condition) return
10
- return <>{children}</>
11
- }
12
-
13
- export const IfElse = ({ condition, children }) => {
14
- const [first, ...rest] = children
15
-
16
- if (condition) return <>{first}</>
17
- return <>{rest}</>
18
- }
@@ -1,5 +0,0 @@
1
- import jsx from '../jsx'
2
-
3
- export const Link = ({ children, ...props }) => {
4
- return <a {...props} onClick='goToHref'>{children}</a>
5
- }
package/src/views.js DELETED
@@ -1,7 +0,0 @@
1
- import * as conditionals from './views/conditionals.jsx'
2
- import { Link } from './views/link.jsx'
3
-
4
- export const views = {
5
- ...conditionals,
6
- Link
7
- }
package/tsconfig.json DELETED
@@ -1,26 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "lib": ["ESNext"],
4
- "target": "ESNext",
5
- "module": "ESNext",
6
- "moduleDetection": "force",
7
- "allowJs": true,
8
-
9
- /* Bundler mode */
10
- "moduleResolution": "bundler",
11
- "allowImportingTsExtensions": true,
12
- "verbatimModuleSyntax": true,
13
- "noEmit": true,
14
-
15
- /* Linting */
16
- "skipLibCheck": true,
17
- "strict": true,
18
- "noFallthroughCasesInSwitch": true,
19
- "forceConsistentCasingInFileNames": true,
20
-
21
- /* Jaxs JSX */
22
- "jsx": "react",
23
- "jsxFactory": "jsx",
24
- "jsxFragmentFactory": "jsx.fragment"
25
- }
26
- }