@furystack/shades 6.1.5 → 7.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.
Files changed (67) hide show
  1. package/dist/component-factory.spec.js +6 -6
  2. package/dist/component-factory.spec.js.map +1 -1
  3. package/dist/components/lazy-load.js +17 -14
  4. package/dist/components/lazy-load.js.map +1 -1
  5. package/dist/components/route-link.js +7 -3
  6. package/dist/components/route-link.js.map +1 -1
  7. package/dist/components/route-link.spec.js +2 -2
  8. package/dist/components/route-link.spec.js.map +1 -1
  9. package/dist/components/router.js +25 -26
  10. package/dist/components/router.js.map +1 -1
  11. package/dist/components/router.spec.js +2 -2
  12. package/dist/components/router.spec.js.map +1 -1
  13. package/dist/models/render-options.js +23 -0
  14. package/dist/models/render-options.js.map +1 -1
  15. package/dist/services/location-service.js +16 -4
  16. package/dist/services/location-service.js.map +1 -1
  17. package/dist/services/location-service.spec.js +1 -1
  18. package/dist/services/location-service.spec.js.map +1 -1
  19. package/dist/services/resource-manager.js +48 -0
  20. package/dist/services/resource-manager.js.map +1 -0
  21. package/dist/services/resource-manager.spec.js +32 -0
  22. package/dist/services/resource-manager.spec.js.map +1 -0
  23. package/dist/shade-component.js +28 -14
  24. package/dist/shade-component.js.map +1 -1
  25. package/dist/shade-resources.integration.spec.js +7 -8
  26. package/dist/shade-resources.integration.spec.js.map +1 -1
  27. package/dist/shade.js +33 -69
  28. package/dist/shade.js.map +1 -1
  29. package/dist/shades.integration.spec.js +197 -187
  30. package/dist/shades.integration.spec.js.map +1 -1
  31. package/package.json +5 -5
  32. package/src/component-factory.spec.tsx +7 -7
  33. package/src/components/lazy-load.tsx +19 -15
  34. package/src/components/route-link.spec.tsx +2 -2
  35. package/src/components/route-link.tsx +11 -10
  36. package/src/components/router.spec.tsx +2 -2
  37. package/src/components/router.tsx +32 -32
  38. package/src/jsx.ts +3 -2
  39. package/src/models/render-options.ts +37 -9
  40. package/src/services/location-service.spec.ts +1 -1
  41. package/src/services/location-service.tsx +18 -4
  42. package/src/services/resource-manager.spec.ts +33 -0
  43. package/src/services/resource-manager.ts +60 -0
  44. package/src/shade-component.ts +35 -15
  45. package/src/shade-resources.integration.spec.tsx +8 -14
  46. package/src/shade.ts +34 -107
  47. package/src/shades.integration.spec.tsx +265 -252
  48. package/types/components/lazy-load.d.ts +1 -1
  49. package/types/components/lazy-load.d.ts.map +1 -1
  50. package/types/components/route-link.d.ts +1 -1
  51. package/types/components/route-link.d.ts.map +1 -1
  52. package/types/components/router.d.ts +6 -8
  53. package/types/components/router.d.ts.map +1 -1
  54. package/types/jsx.d.ts +3 -2
  55. package/types/jsx.d.ts.map +1 -1
  56. package/types/models/render-options.d.ts +7 -7
  57. package/types/models/render-options.d.ts.map +1 -1
  58. package/types/services/location-service.d.ts +12 -1
  59. package/types/services/location-service.d.ts.map +1 -1
  60. package/types/services/resource-manager.d.ts +16 -0
  61. package/types/services/resource-manager.d.ts.map +1 -0
  62. package/types/services/resource-manager.spec.d.ts +2 -0
  63. package/types/services/resource-manager.spec.d.ts.map +1 -0
  64. package/types/shade-component.d.ts +16 -5
  65. package/types/shade-component.d.ts.map +1 -1
  66. package/types/shade.d.ts +8 -27
  67. package/types/shade.d.ts.map +1 -1
@@ -1,4 +1,5 @@
1
1
  import { Injector } from '@furystack/inject'
2
+ import { usingAsync } from '@furystack/utils'
2
3
 
3
4
  import { TextEncoder, TextDecoder } from 'util'
4
5
 
@@ -7,7 +8,7 @@ global.TextDecoder = TextDecoder as any
7
8
 
8
9
  import { initializeShadeRoot } from './initialize'
9
10
  import { Shade } from './shade'
10
- import { createComponent, createFragment } from './shade-component'
11
+ import { createComponent } from './shade-component'
11
12
 
12
13
  describe('Shades integration tests', () => {
13
14
  beforeEach(() => (document.body.innerHTML = '<div id="root"></div>'))
@@ -43,289 +44,301 @@ describe('Shades integration tests', () => {
43
44
  )
44
45
  })
45
46
 
46
- it('Should mount a custom component with null render result', () => {
47
- const injector = new Injector()
48
- const rootElement = document.getElementById('root') as HTMLDivElement
47
+ it('Should mount a custom component with null render result', async () => {
48
+ await usingAsync(new Injector(), async (injector) => {
49
+ const rootElement = document.getElementById('root') as HTMLDivElement
49
50
 
50
- const ExampleComponent = Shade({ render: () => null, shadowDomName: 'shades-null-render-result' })
51
+ const ExampleComponent = Shade({ render: () => null, shadowDomName: 'shades-null-render-result' })
51
52
 
52
- initializeShadeRoot({
53
- injector,
54
- rootElement,
55
- jsxElement: <ExampleComponent />,
53
+ initializeShadeRoot({
54
+ injector,
55
+ rootElement,
56
+ jsxElement: <ExampleComponent />,
57
+ })
58
+ expect(document.body.innerHTML).toBe(
59
+ '<div id="root"><shades-null-render-result></shades-null-render-result></div>',
60
+ )
56
61
  })
57
- expect(document.body.innerHTML).toBe('<div id="root"><shades-null-render-result></shades-null-render-result></div>')
58
62
  })
59
63
 
60
- it('Should mount a custom component with a document fragment render result', () => {
61
- const injector = new Injector()
62
- const rootElement = document.getElementById('root') as HTMLDivElement
63
-
64
- const ExampleComponent = Shade({
65
- render: () => (
66
- <>
67
- <p>1</p>
68
- <p>2</p>
69
- </>
70
- ),
71
- shadowDomName: 'shades-fragment-render-result',
72
- })
64
+ it('Should mount a custom component with a document fragment render result', async () => {
65
+ await usingAsync(new Injector(), async (injector) => {
66
+ const rootElement = document.getElementById('root') as HTMLDivElement
73
67
 
74
- initializeShadeRoot({
75
- injector,
76
- rootElement,
77
- jsxElement: <ExampleComponent />,
78
- })
79
- expect(document.body.innerHTML).toBe(
80
- '<div id="root"><shades-fragment-render-result><p>1</p><p>2</p></shades-fragment-render-result></div>',
81
- )
82
- })
83
-
84
- it('Should mount a custom component with a nested document fragment render result', () => {
85
- const injector = new Injector()
86
- const rootElement = document.getElementById('root') as HTMLDivElement
87
-
88
- const ExampleComponent = Shade({
89
- render: () => (
90
- <p>
68
+ const ExampleComponent = Shade({
69
+ render: () => (
91
70
  <>
92
71
  <p>1</p>
93
72
  <p>2</p>
94
73
  </>
95
- </p>
96
- ),
97
- shadowDomName: 'shades-fragment-render-result-nested',
74
+ ),
75
+ shadowDomName: 'shades-fragment-render-result',
76
+ })
77
+
78
+ initializeShadeRoot({
79
+ injector,
80
+ rootElement,
81
+ jsxElement: <ExampleComponent />,
82
+ })
83
+ expect(document.body.innerHTML).toBe(
84
+ '<div id="root"><shades-fragment-render-result><p>1</p><p>2</p></shades-fragment-render-result></div>',
85
+ )
98
86
  })
99
-
100
- initializeShadeRoot({
101
- injector,
102
- rootElement,
103
- jsxElement: <ExampleComponent />,
104
- })
105
- expect(document.body.innerHTML).toBe(
106
- '<div id="root"><shades-fragment-render-result-nested><p><p>1</p><p>2</p></p></shades-fragment-render-result-nested></div>',
107
- )
108
87
  })
109
88
 
110
- it('Should mount a custom component with a document fragment that contains custom components', () => {
111
- const injector = new Injector()
112
- const rootElement = document.getElementById('root') as HTMLDivElement
113
-
114
- const CustomComponent = Shade({
115
- shadowDomName: 'shades-fragment-test-custom-component',
116
- render: () => <p>Hello</p>,
117
- })
118
-
119
- const ExampleComponent = Shade({
120
- render: () => (
121
- <>
122
- <CustomComponent />
123
- <CustomComponent />
124
- </>
125
- ),
126
- shadowDomName: 'shades-fragment-render-result-2',
127
- })
128
-
129
- initializeShadeRoot({
130
- injector,
131
- rootElement,
132
- jsxElement: <ExampleComponent />,
89
+ it('Should mount a custom component with a nested document fragment render result', async () => {
90
+ await usingAsync(new Injector(), async (injector) => {
91
+ const rootElement = document.getElementById('root') as HTMLDivElement
92
+
93
+ const ExampleComponent = Shade({
94
+ render: () => (
95
+ <p>
96
+ <>
97
+ <p>1</p>
98
+ <p>2</p>
99
+ </>
100
+ </p>
101
+ ),
102
+ shadowDomName: 'shades-fragment-render-result-nested',
103
+ })
104
+
105
+ initializeShadeRoot({
106
+ injector,
107
+ rootElement,
108
+ jsxElement: <ExampleComponent />,
109
+ })
110
+ expect(document.body.innerHTML).toBe(
111
+ '<div id="root"><shades-fragment-render-result-nested><p><p>1</p><p>2</p></p></shades-fragment-render-result-nested></div>',
112
+ )
133
113
  })
134
- expect(document.body.innerHTML).toBe(
135
- '<div id="root"><shades-fragment-render-result-2><shades-fragment-test-custom-component><p>Hello</p></shades-fragment-test-custom-component><shades-fragment-test-custom-component><p>Hello</p></shades-fragment-test-custom-component></shades-fragment-render-result-2></div>',
136
- )
137
114
  })
138
115
 
139
- it('Should mount nested Shades components', () => {
140
- const injector = new Injector()
141
- const rootElement = document.getElementById('root') as HTMLDivElement
142
-
143
- const ExampleComponent = Shade({
144
- render: ({ children }) => <div>{children}</div>,
145
- shadowDomName: 'shades-example-2',
146
- })
116
+ it('Should mount a custom component with a document fragment that contains custom components', async () => {
117
+ await usingAsync(new Injector(), async (injector) => {
118
+ const rootElement = document.getElementById('root') as HTMLDivElement
147
119
 
148
- const ExampleSubs = Shade<{ no: number }>({
149
- render: ({ props }) => <div>{props.no}</div>,
150
- shadowDomName: 'shades-example-sub',
151
- })
120
+ const CustomComponent = Shade({
121
+ shadowDomName: 'shades-fragment-test-custom-component',
122
+ render: () => <p>Hello</p>,
123
+ })
152
124
 
153
- initializeShadeRoot({
154
- injector,
155
- rootElement,
156
- jsxElement: (
157
- <ExampleComponent>
158
- <ExampleSubs no={1} />
159
- <ExampleSubs no={2} />
160
- <ExampleSubs no={3} />
161
- </ExampleComponent>
162
- ),
125
+ const ExampleComponent = Shade({
126
+ render: () => (
127
+ <>
128
+ <CustomComponent />
129
+ <CustomComponent />
130
+ </>
131
+ ),
132
+ shadowDomName: 'shades-fragment-render-result-2',
133
+ })
134
+
135
+ initializeShadeRoot({
136
+ injector,
137
+ rootElement,
138
+ jsxElement: <ExampleComponent />,
139
+ })
140
+ expect(document.body.innerHTML).toBe(
141
+ '<div id="root"><shades-fragment-render-result-2><shades-fragment-test-custom-component><p>Hello</p></shades-fragment-test-custom-component><shades-fragment-test-custom-component><p>Hello</p></shades-fragment-test-custom-component></shades-fragment-render-result-2></div>',
142
+ )
163
143
  })
164
- expect(document.body.innerHTML).toBe(
165
- '<div id="root"><shades-example-2><div><shades-example-sub><div></div></shades-example-sub><shades-example-sub><div></div></shades-example-sub><shades-example-sub><div></div></shades-example-sub></div></shades-example-2></div>',
166
- )
167
144
  })
168
145
 
169
- it("Should execute the constructed and constructed's cleanup callback", () => {
170
- const injector = new Injector()
171
- const rootElement = document.getElementById('root') as HTMLDivElement
172
- const cleanup = jest.fn()
173
- const constructed = jest.fn(() => cleanup)
174
-
175
- const ExampleComponent = Shade({
176
- constructed,
177
- shadowDomName: 'example-component-1',
178
- render: () => <div>Hello</div>,
179
- })
180
-
181
- initializeShadeRoot({
182
- injector,
183
- rootElement,
184
- jsxElement: <ExampleComponent />,
146
+ it('Should mount nested Shades components', async () => {
147
+ await usingAsync(new Injector(), async (injector) => {
148
+ const rootElement = document.getElementById('root') as HTMLDivElement
149
+
150
+ const ExampleComponent = Shade({
151
+ render: ({ children }) => <div>{children}</div>,
152
+ shadowDomName: 'shades-example-2',
153
+ })
154
+
155
+ const ExampleSubs = Shade<{ no: number }>({
156
+ render: ({ props }) => <div>{props.no}</div>,
157
+ shadowDomName: 'shades-example-sub',
158
+ })
159
+
160
+ initializeShadeRoot({
161
+ injector,
162
+ rootElement,
163
+ jsxElement: (
164
+ <ExampleComponent>
165
+ <ExampleSubs no={1} />
166
+ <ExampleSubs no={2} />
167
+ <ExampleSubs no={3} />
168
+ </ExampleComponent>
169
+ ),
170
+ })
171
+ expect(document.body.innerHTML).toBe(
172
+ '<div id="root"><shades-example-2><div><shades-example-sub><div>1</div></shades-example-sub><shades-example-sub><div>2</div></shades-example-sub><shades-example-sub><div>3</div></shades-example-sub></div></shades-example-2></div>',
173
+ )
185
174
  })
186
- expect(constructed).toBeCalled()
187
- expect(cleanup).not.toBeCalled()
188
- document.body.innerHTML = ''
189
- expect(cleanup).toBeCalled()
190
175
  })
191
176
 
192
- it('Should execute the onAttach and onDetach callbacks', () => {
193
- const injector = new Injector()
194
- const rootElement = document.getElementById('root') as HTMLDivElement
195
- const onAttach = jest.fn()
196
- const onDetach = jest.fn()
197
-
198
- const ExampleComponent = Shade({
199
- onAttach,
200
- onDetach,
201
- shadowDomName: 'example-component-2',
202
- render: () => <div>Hello</div>,
203
- })
204
-
205
- initializeShadeRoot({
206
- injector,
207
- rootElement,
208
- jsxElement: <ExampleComponent />,
177
+ it("Should execute the constructed and constructed's cleanup callback", async () => {
178
+ await usingAsync(new Injector(), async (injector) => {
179
+ const rootElement = document.getElementById('root') as HTMLDivElement
180
+ const cleanup = jest.fn()
181
+ const constructed = jest.fn(() => cleanup)
182
+
183
+ const ExampleComponent = Shade({
184
+ constructed,
185
+ shadowDomName: 'example-component-1',
186
+ render: () => <div>Hello</div>,
187
+ })
188
+
189
+ initializeShadeRoot({
190
+ injector,
191
+ rootElement,
192
+ jsxElement: <ExampleComponent />,
193
+ })
194
+ expect(constructed).toBeCalled()
195
+ expect(cleanup).not.toBeCalled()
196
+ document.body.innerHTML = ''
197
+ expect(cleanup).toBeCalled()
209
198
  })
210
- expect(onAttach).toBeCalled()
211
- expect(onDetach).not.toBeCalled()
212
- document.body.innerHTML = ''
213
- expect(onDetach).toBeCalled()
214
199
  })
215
200
 
216
- it('Should update state', () => {
217
- const injector = new Injector()
218
- const rootElement = document.getElementById('root') as HTMLDivElement
219
-
220
- const ExampleComponent = Shade({
221
- shadowDomName: 'example-component-3',
222
- getInitialState: () => ({ count: 0 }),
223
- render: ({ getState, updateState }) => {
224
- const { count } = getState()
225
- return (
226
- <div>
227
- Count is {getState().count.toString()}
228
- <button id="plus" onclick={() => updateState({ count: count + 1 })}>
229
- +
230
- </button>
231
- <button id="minus" onclick={() => updateState({ count: count - 1 })}>
232
- -
233
- </button>
234
- </div>
235
- )
236
- },
237
- })
238
- initializeShadeRoot({
239
- injector,
240
- rootElement,
241
- jsxElement: <ExampleComponent />,
201
+ it('Should execute the onAttach and onDetach callbacks', async () => {
202
+ await usingAsync(new Injector(), async (injector) => {
203
+ const rootElement = document.getElementById('root') as HTMLDivElement
204
+ const onAttach = jest.fn()
205
+ const onDetach = jest.fn()
206
+
207
+ const ExampleComponent = Shade({
208
+ onAttach,
209
+ onDetach,
210
+ shadowDomName: 'example-component-2',
211
+ render: () => <div>Hello</div>,
212
+ })
213
+
214
+ initializeShadeRoot({
215
+ injector,
216
+ rootElement,
217
+ jsxElement: <ExampleComponent />,
218
+ })
219
+ expect(onAttach).toBeCalled()
220
+ expect(onDetach).not.toBeCalled()
221
+ document.body.innerHTML = ''
222
+ expect(onDetach).toBeCalled()
242
223
  })
243
-
244
- const plus = () => document.getElementById('plus')?.click()
245
- const minus = () => document.getElementById('minus')?.click()
246
- const expectCount = (count: number) => expect(document.body.innerHTML).toContain(`Count is ${count}`)
247
-
248
- expectCount(0)
249
- plus()
250
- expectCount(1)
251
- plus()
252
- expectCount(2)
253
-
254
- minus()
255
- minus()
256
- expectCount(0)
257
224
  })
258
225
 
259
- it('Should allow children update after unmount and remount', () => {
260
- const injector = new Injector()
261
- const rootElement = document.getElementById('root') as HTMLDivElement
262
- const Parent = Shade<unknown, { areChildrenVisible: boolean }>({
263
- shadowDomName: 'shade-remount-parent',
264
- getInitialState: () => ({ areChildrenVisible: true }),
265
- render: ({ children, getState, updateState }) => (
266
- <div>
267
- <button
268
- id="showHideChildren"
269
- onclick={() => {
270
- updateState({ areChildrenVisible: !getState().areChildrenVisible })
271
- }}
272
- >
273
- Toggle
274
- </button>
275
- {getState().areChildrenVisible ? children : <div />}
276
- </div>
277
- ),
278
- })
279
-
280
- const Child = Shade({
281
- shadowDomName: 'example-remount-child',
282
- getInitialState: () => ({ count: 0 }),
283
- render: ({ getState, updateState }) => {
284
- const { count } = getState()
285
- return (
286
- <div>
287
- Count is {getState().count.toString()}
288
- <button id="plus" onclick={() => updateState({ count: count + 1 })}>
289
- +
290
- </button>
291
- <button id="minus" onclick={() => updateState({ count: count - 1 })}>
292
- -
293
- </button>
294
- </div>
295
- )
296
- },
226
+ it('Should update state', async () => {
227
+ await usingAsync(new Injector(), async (injector) => {
228
+ const rootElement = document.getElementById('root') as HTMLDivElement
229
+
230
+ const ExampleComponent = Shade({
231
+ shadowDomName: 'example-component-3',
232
+ render: ({ useState }) => {
233
+ const [count, setCount] = useState('count', 0)
234
+ return (
235
+ <div>
236
+ Count is {count}
237
+ <button id="plus" onclick={() => setCount(count + 1)}>
238
+ +
239
+ </button>
240
+ <button id="minus" onclick={() => setCount(count - 1)}>
241
+ -
242
+ </button>
243
+ </div>
244
+ )
245
+ },
246
+ })
247
+ initializeShadeRoot({
248
+ injector,
249
+ rootElement,
250
+ jsxElement: <ExampleComponent />,
251
+ })
252
+
253
+ const plus = () => document.getElementById('plus')?.click()
254
+ const minus = () => document.getElementById('minus')?.click()
255
+ const expectCount = (count: number) => expect(document.body.innerHTML).toContain(`Count is ${count}`)
256
+
257
+ expectCount(0)
258
+ plus()
259
+ expectCount(1)
260
+ plus()
261
+ expectCount(2)
262
+
263
+ minus()
264
+ minus()
265
+ expectCount(0)
297
266
  })
267
+ })
298
268
 
299
- initializeShadeRoot({
300
- injector,
301
- rootElement,
302
- jsxElement: (
303
- <Parent>
304
- <Child />
305
- </Parent>
306
- ),
269
+ it('Should allow children update after unmount and remount', async () => {
270
+ await usingAsync(new Injector(), async (injector) => {
271
+ const rootElement = document.getElementById('root') as HTMLDivElement
272
+ const Parent = Shade({
273
+ shadowDomName: 'shade-remount-parent',
274
+ render: ({ children, useState }) => {
275
+ const [areChildrenVisible, setAreChildrenVisible] = useState('areChildrenVisible', true)
276
+ return (
277
+ <div>
278
+ <button
279
+ id="showHideChildren"
280
+ onclick={() => {
281
+ setAreChildrenVisible(!areChildrenVisible)
282
+ }}
283
+ >
284
+ Toggle
285
+ </button>
286
+ {areChildrenVisible ? children : null}
287
+ </div>
288
+ )
289
+ },
290
+ })
291
+
292
+ const Child = Shade({
293
+ shadowDomName: 'example-remount-child',
294
+ render: ({ useState }) => {
295
+ const [count, setCount] = useState('count', 0)
296
+
297
+ return (
298
+ <div>
299
+ Count is {`${count}`}
300
+ <button id="plus" onclick={() => setCount(count + 1)}>
301
+ +
302
+ </button>
303
+ <button id="minus" onclick={() => setCount(count - 1)}>
304
+ -
305
+ </button>
306
+ </div>
307
+ )
308
+ },
309
+ })
310
+
311
+ initializeShadeRoot({
312
+ injector,
313
+ rootElement,
314
+ jsxElement: (
315
+ <Parent>
316
+ <Child />
317
+ </Parent>
318
+ ),
319
+ })
320
+
321
+ const plus = () => document.getElementById('plus')?.click()
322
+ const minus = () => document.getElementById('minus')?.click()
323
+ const expectCount = (count: number) => expect(document.body.innerHTML).toContain(`Count is ${count}`)
324
+ const toggleChildren = () => document.getElementById('showHideChildren')?.click()
325
+
326
+ expectCount(0)
327
+ plus()
328
+ expectCount(1)
329
+
330
+ toggleChildren()
331
+
332
+ expect(document.getElementById('plus')).toBeNull()
333
+
334
+ toggleChildren()
335
+ expect(document.getElementById('plus')).toBeDefined()
336
+
337
+ expectCount(0)
338
+ plus()
339
+ expectCount(1)
340
+ minus()
341
+ expectCount(0)
307
342
  })
308
-
309
- const plus = () => document.getElementById('plus')?.click()
310
- const minus = () => document.getElementById('minus')?.click()
311
- const expectCount = (count: number) => expect(document.body.innerHTML).toContain(`Count is ${count}`)
312
- const toggleChildren = () => document.getElementById('showHideChildren')?.click()
313
-
314
- expectCount(0)
315
- plus()
316
- expectCount(1)
317
-
318
- toggleChildren()
319
-
320
- expect(document.getElementById('plus')).toBeNull()
321
-
322
- toggleChildren()
323
- expect(document.getElementById('plus')).toBeDefined()
324
-
325
- // expectCount(0)
326
- plus()
327
- expectCount(1)
328
- minus()
329
- expectCount(0)
330
343
  })
331
344
  })
@@ -7,5 +7,5 @@ export interface LazyLoadState {
7
7
  component?: JSX.Element;
8
8
  error?: unknown;
9
9
  }
10
- export declare const LazyLoad: (props: LazyLoadProps, children: import("..").ChildrenList) => JSX.Element<any, any>;
10
+ export declare const LazyLoad: (props: LazyLoadProps, children: import("..").ChildrenList) => JSX.Element<any>;
11
11
  //# sourceMappingURL=lazy-load.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lazy-load.d.ts","sourceRoot":"","sources":["../../src/components/lazy-load.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,GAAG,CAAC,OAAO,CAAA;IACnB,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,KAAK,GAAG,CAAC,OAAO,CAAA;IAC1D,SAAS,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;CACtC;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,GAAG,CAAC,OAAO,CAAA;IACvB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,eAAO,MAAM,QAAQ,sFAiCnB,CAAA"}
1
+ {"version":3,"file":"lazy-load.d.ts","sourceRoot":"","sources":["../../src/components/lazy-load.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,GAAG,CAAC,OAAO,CAAA;IACnB,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,KAAK,GAAG,CAAC,OAAO,CAAA;IAC1D,SAAS,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;CACtC;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,GAAG,CAAC,OAAO,CAAA;IACvB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,eAAO,MAAM,QAAQ,iFAqCnB,CAAA"}
@@ -2,5 +2,5 @@ import type { PartialElement } from '../models';
2
2
  export type RouteLinkProps = PartialElement<HTMLAnchorElement>;
3
3
  export declare const RouteLink: (props: Omit<Partial<HTMLAnchorElement>, "style"> & {
4
4
  style?: Partial<CSSStyleDeclaration> | undefined;
5
- }, children: import("..").ChildrenList) => JSX.Element<any, any>;
5
+ }, children: import("..").ChildrenList) => JSX.Element<any>;
6
6
  //# sourceMappingURL=route-link.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"route-link.d.ts","sourceRoot":"","sources":["../../src/components/route-link.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAI/C,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC,iBAAiB,CAAC,CAAA;AAE9D,eAAO,MAAM,SAAS;;gEAgBpB,CAAA"}
1
+ {"version":3,"file":"route-link.d.ts","sourceRoot":"","sources":["../../src/components/route-link.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAI/C,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC,iBAAiB,CAAC,CAAA;AAE9D,eAAO,MAAM,SAAS;;2DAiBpB,CAAA"}
@@ -1,6 +1,5 @@
1
1
  import type { MatchResult, TokensToRegexpOptions } from 'path-to-regexp';
2
2
  import type { RenderOptions } from '../models';
3
- import Semaphore from 'semaphore-async-await';
4
3
  export interface Route<TMatchResult extends object> {
5
4
  url: string;
6
5
  component: (options: {
@@ -8,19 +7,18 @@ export interface Route<TMatchResult extends object> {
8
7
  match: MatchResult<TMatchResult>;
9
8
  }) => JSX.Element;
10
9
  routingOptions?: TokensToRegexpOptions;
11
- onVisit?: (options: RenderOptions<RouterProps, RouterState>) => Promise<void>;
12
- onLeave?: (options: RenderOptions<RouterProps, RouterState>) => Promise<void>;
10
+ onVisit?: (options: RenderOptions<unknown>) => Promise<void>;
11
+ onLeave?: (options: RenderOptions<unknown>) => Promise<void>;
13
12
  }
14
13
  export interface RouterProps {
15
14
  style?: CSSStyleDeclaration;
16
15
  routes: Array<Route<any>>;
17
- notFound?: (currentUrl: string) => JSX.Element;
16
+ notFound?: JSX.Element;
18
17
  }
19
18
  export interface RouterState {
20
- activeRoute?: Route<any>;
19
+ activeRoute?: Route<any> | null;
21
20
  activeRouteParams?: any;
22
- jsx?: JSX.Element;
23
- lock: Semaphore;
21
+ jsx: JSX.Element;
24
22
  }
25
- export declare const Router: (props: RouterProps, children: import("../models").ChildrenList) => JSX.Element<any, any>;
23
+ export declare const Router: (props: RouterProps, children: import("../models").ChildrenList) => JSX.Element<any>;
26
24
  //# sourceMappingURL=router.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/components/router.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AAExE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAC9C,OAAO,SAAS,MAAM,uBAAuB,CAAA;AAG7C,MAAM,WAAW,KAAK,CAAC,YAAY,SAAS,MAAM;IAChD,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,CAAC,OAAO,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,WAAW,CAAC,YAAY,CAAC,CAAA;KAAE,KAAK,GAAG,CAAC,OAAO,CAAA;IAC7F,cAAc,CAAC,EAAE,qBAAqB,CAAA;IACtC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,WAAW,EAAE,WAAW,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7E,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,WAAW,EAAE,WAAW,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAC9E;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,mBAAmB,CAAA;IAC3B,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;IACzB,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,GAAG,CAAC,OAAO,CAAA;CAC/C;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;IACxB,iBAAiB,CAAC,EAAE,GAAG,CAAA;IACvB,GAAG,CAAC,EAAE,GAAG,CAAC,OAAO,CAAA;IACjB,IAAI,EAAE,SAAS,CAAA;CAChB;AACD,eAAO,MAAM,MAAM,2FA+CjB,CAAA"}
1
+ {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/components/router.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AAExE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAI9C,MAAM,WAAW,KAAK,CAAC,YAAY,SAAS,MAAM;IAChD,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,CAAC,OAAO,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,WAAW,CAAC,YAAY,CAAC,CAAA;KAAE,KAAK,GAAG,CAAC,OAAO,CAAA;IAC7F,cAAc,CAAC,EAAE,qBAAqB,CAAA;IACtC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5D,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAC7D;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,mBAAmB,CAAA;IAC3B,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;IACzB,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,CAAA;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA;IAC/B,iBAAiB,CAAC,EAAE,GAAG,CAAA;IACvB,GAAG,EAAE,GAAG,CAAC,OAAO,CAAA;CACjB;AACD,eAAO,MAAM,MAAM,sFAgDjB,CAAA"}
package/types/jsx.d.ts CHANGED
@@ -1,14 +1,15 @@
1
1
  import type { Injector } from '@furystack/inject';
2
2
  import type { ChildrenList, PartialElement } from './models';
3
+ import type { ResourceManager } from './services/resource-manager';
3
4
  declare global {
4
5
  export namespace JSX {
5
- interface Element<TProps = any, TState = any> extends HTMLElement {
6
+ interface Element<TProps = any> extends HTMLElement {
6
7
  injector: Injector;
7
- state: TState;
8
8
  props: TProps;
9
9
  updateComponent: () => void;
10
10
  shadeChildren?: ChildrenList;
11
11
  callConstructed: () => void;
12
+ resourceManager: ResourceManager;
12
13
  }
13
14
  interface IntrinsicElements {
14
15
  /**