@furystack/shades 6.1.4 → 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.
- package/dist/component-factory.spec.js +6 -6
- package/dist/component-factory.spec.js.map +1 -1
- package/dist/components/lazy-load.js +17 -14
- package/dist/components/lazy-load.js.map +1 -1
- package/dist/components/route-link.js +7 -3
- package/dist/components/route-link.js.map +1 -1
- package/dist/components/route-link.spec.js +2 -2
- package/dist/components/route-link.spec.js.map +1 -1
- package/dist/components/router.js +25 -26
- package/dist/components/router.js.map +1 -1
- package/dist/components/router.spec.js +2 -2
- package/dist/components/router.spec.js.map +1 -1
- package/dist/models/render-options.js +23 -0
- package/dist/models/render-options.js.map +1 -1
- package/dist/services/location-service.js +16 -4
- package/dist/services/location-service.js.map +1 -1
- package/dist/services/location-service.spec.js +1 -1
- package/dist/services/location-service.spec.js.map +1 -1
- package/dist/services/resource-manager.js +48 -0
- package/dist/services/resource-manager.js.map +1 -0
- package/dist/services/resource-manager.spec.js +32 -0
- package/dist/services/resource-manager.spec.js.map +1 -0
- package/dist/shade-component.js +28 -14
- package/dist/shade-component.js.map +1 -1
- package/dist/shade-resources.integration.spec.js +7 -8
- package/dist/shade-resources.integration.spec.js.map +1 -1
- package/dist/shade.js +34 -75
- package/dist/shade.js.map +1 -1
- package/dist/shades.integration.spec.js +197 -187
- package/dist/shades.integration.spec.js.map +1 -1
- package/package.json +5 -5
- package/src/component-factory.spec.tsx +7 -7
- package/src/components/lazy-load.tsx +19 -15
- package/src/components/route-link.spec.tsx +2 -2
- package/src/components/route-link.tsx +11 -10
- package/src/components/router.spec.tsx +2 -2
- package/src/components/router.tsx +32 -32
- package/src/jsx.ts +3 -2
- package/src/models/render-options.ts +37 -9
- package/src/services/location-service.spec.ts +1 -1
- package/src/services/location-service.tsx +18 -4
- package/src/services/resource-manager.spec.ts +33 -0
- package/src/services/resource-manager.ts +60 -0
- package/src/shade-component.ts +35 -15
- package/src/shade-resources.integration.spec.tsx +8 -14
- package/src/shade.ts +35 -112
- package/src/shades.integration.spec.tsx +265 -252
- package/types/components/lazy-load.d.ts +1 -1
- package/types/components/lazy-load.d.ts.map +1 -1
- package/types/components/route-link.d.ts +1 -1
- package/types/components/route-link.d.ts.map +1 -1
- package/types/components/router.d.ts +6 -8
- package/types/components/router.d.ts.map +1 -1
- package/types/jsx.d.ts +3 -2
- package/types/jsx.d.ts.map +1 -1
- package/types/models/render-options.d.ts +7 -7
- package/types/models/render-options.d.ts.map +1 -1
- package/types/services/location-service.d.ts +12 -1
- package/types/services/location-service.d.ts.map +1 -1
- package/types/services/resource-manager.d.ts +16 -0
- package/types/services/resource-manager.d.ts.map +1 -0
- package/types/services/resource-manager.spec.d.ts +2 -0
- package/types/services/resource-manager.spec.d.ts.map +1 -0
- package/types/shade-component.d.ts +16 -5
- package/types/shade-component.d.ts.map +1 -1
- package/types/shade.d.ts +8 -27
- package/types/shade.d.ts.map +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const inject_1 = require("@furystack/inject");
|
|
4
|
+
const utils_1 = require("@furystack/utils");
|
|
4
5
|
const util_1 = require("util");
|
|
5
6
|
global.TextEncoder = util_1.TextEncoder;
|
|
6
7
|
global.TextDecoder = util_1.TextDecoder;
|
|
@@ -32,210 +33,219 @@ describe('Shades integration tests', () => {
|
|
|
32
33
|
});
|
|
33
34
|
expect(document.body.innerHTML).toBe('<div id="root"><shades-string-render-result>Hello</shades-string-render-result></div>');
|
|
34
35
|
});
|
|
35
|
-
it('Should mount a custom component with null render result', () => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
it('Should mount a custom component with null render result', async () => {
|
|
37
|
+
await (0, utils_1.usingAsync)(new inject_1.Injector(), async (injector) => {
|
|
38
|
+
const rootElement = document.getElementById('root');
|
|
39
|
+
const ExampleComponent = (0, shade_1.Shade)({ render: () => null, shadowDomName: 'shades-null-render-result' });
|
|
40
|
+
(0, initialize_1.initializeShadeRoot)({
|
|
41
|
+
injector,
|
|
42
|
+
rootElement,
|
|
43
|
+
jsxElement: (0, shade_component_1.createComponent)(ExampleComponent, null),
|
|
44
|
+
});
|
|
45
|
+
expect(document.body.innerHTML).toBe('<div id="root"><shades-null-render-result></shades-null-render-result></div>');
|
|
43
46
|
});
|
|
44
|
-
expect(document.body.innerHTML).toBe('<div id="root"><shades-null-render-result></shades-null-render-result></div>');
|
|
45
47
|
});
|
|
46
|
-
it('Should mount a custom component with a document fragment render result', () => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
(0, shade_component_1.createComponent)("p", null, "1"),
|
|
52
|
-
(0, shade_component_1.createComponent)("p", null, "2"))),
|
|
53
|
-
shadowDomName: 'shades-fragment-render-result',
|
|
54
|
-
});
|
|
55
|
-
(0, initialize_1.initializeShadeRoot)({
|
|
56
|
-
injector,
|
|
57
|
-
rootElement,
|
|
58
|
-
jsxElement: (0, shade_component_1.createComponent)(ExampleComponent, null),
|
|
59
|
-
});
|
|
60
|
-
expect(document.body.innerHTML).toBe('<div id="root"><shades-fragment-render-result><p>1</p><p>2</p></shades-fragment-render-result></div>');
|
|
61
|
-
});
|
|
62
|
-
it('Should mount a custom component with a nested document fragment render result', () => {
|
|
63
|
-
const injector = new inject_1.Injector();
|
|
64
|
-
const rootElement = document.getElementById('root');
|
|
65
|
-
const ExampleComponent = (0, shade_1.Shade)({
|
|
66
|
-
render: () => ((0, shade_component_1.createComponent)("p", null,
|
|
67
|
-
(0, shade_component_1.createComponent)(shade_component_1.createFragment, null,
|
|
48
|
+
it('Should mount a custom component with a document fragment render result', async () => {
|
|
49
|
+
await (0, utils_1.usingAsync)(new inject_1.Injector(), async (injector) => {
|
|
50
|
+
const rootElement = document.getElementById('root');
|
|
51
|
+
const ExampleComponent = (0, shade_1.Shade)({
|
|
52
|
+
render: () => ((0, shade_component_1.createComponent)(shade_component_1.createComponent, null,
|
|
68
53
|
(0, shade_component_1.createComponent)("p", null, "1"),
|
|
69
|
-
(0, shade_component_1.createComponent)("p", null, "2")))
|
|
70
|
-
|
|
54
|
+
(0, shade_component_1.createComponent)("p", null, "2"))),
|
|
55
|
+
shadowDomName: 'shades-fragment-render-result',
|
|
56
|
+
});
|
|
57
|
+
(0, initialize_1.initializeShadeRoot)({
|
|
58
|
+
injector,
|
|
59
|
+
rootElement,
|
|
60
|
+
jsxElement: (0, shade_component_1.createComponent)(ExampleComponent, null),
|
|
61
|
+
});
|
|
62
|
+
expect(document.body.innerHTML).toBe('<div id="root"><shades-fragment-render-result><p>1</p><p>2</p></shades-fragment-render-result></div>');
|
|
71
63
|
});
|
|
72
|
-
(0, initialize_1.initializeShadeRoot)({
|
|
73
|
-
injector,
|
|
74
|
-
rootElement,
|
|
75
|
-
jsxElement: (0, shade_component_1.createComponent)(ExampleComponent, null),
|
|
76
|
-
});
|
|
77
|
-
expect(document.body.innerHTML).toBe('<div id="root"><shades-fragment-render-result-nested><p><p>1</p><p>2</p></p></shades-fragment-render-result-nested></div>');
|
|
78
64
|
});
|
|
79
|
-
it('Should mount a custom component with a document fragment
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
65
|
+
it('Should mount a custom component with a nested document fragment render result', async () => {
|
|
66
|
+
await (0, utils_1.usingAsync)(new inject_1.Injector(), async (injector) => {
|
|
67
|
+
const rootElement = document.getElementById('root');
|
|
68
|
+
const ExampleComponent = (0, shade_1.Shade)({
|
|
69
|
+
render: () => ((0, shade_component_1.createComponent)("p", null,
|
|
70
|
+
(0, shade_component_1.createComponent)(shade_component_1.createComponent, null,
|
|
71
|
+
(0, shade_component_1.createComponent)("p", null, "1"),
|
|
72
|
+
(0, shade_component_1.createComponent)("p", null, "2")))),
|
|
73
|
+
shadowDomName: 'shades-fragment-render-result-nested',
|
|
74
|
+
});
|
|
75
|
+
(0, initialize_1.initializeShadeRoot)({
|
|
76
|
+
injector,
|
|
77
|
+
rootElement,
|
|
78
|
+
jsxElement: (0, shade_component_1.createComponent)(ExampleComponent, null),
|
|
79
|
+
});
|
|
80
|
+
expect(document.body.innerHTML).toBe('<div id="root"><shades-fragment-render-result-nested><p><p>1</p><p>2</p></p></shades-fragment-render-result-nested></div>');
|
|
91
81
|
});
|
|
92
|
-
(0, initialize_1.initializeShadeRoot)({
|
|
93
|
-
injector,
|
|
94
|
-
rootElement,
|
|
95
|
-
jsxElement: (0, shade_component_1.createComponent)(ExampleComponent, null),
|
|
96
|
-
});
|
|
97
|
-
expect(document.body.innerHTML).toBe('<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>');
|
|
98
82
|
});
|
|
99
|
-
it('Should mount
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
83
|
+
it('Should mount a custom component with a document fragment that contains custom components', async () => {
|
|
84
|
+
await (0, utils_1.usingAsync)(new inject_1.Injector(), async (injector) => {
|
|
85
|
+
const rootElement = document.getElementById('root');
|
|
86
|
+
const CustomComponent = (0, shade_1.Shade)({
|
|
87
|
+
shadowDomName: 'shades-fragment-test-custom-component',
|
|
88
|
+
render: () => (0, shade_component_1.createComponent)("p", null, "Hello"),
|
|
89
|
+
});
|
|
90
|
+
const ExampleComponent = (0, shade_1.Shade)({
|
|
91
|
+
render: () => ((0, shade_component_1.createComponent)(shade_component_1.createComponent, null,
|
|
92
|
+
(0, shade_component_1.createComponent)(CustomComponent, null),
|
|
93
|
+
(0, shade_component_1.createComponent)(CustomComponent, null))),
|
|
94
|
+
shadowDomName: 'shades-fragment-render-result-2',
|
|
95
|
+
});
|
|
96
|
+
(0, initialize_1.initializeShadeRoot)({
|
|
97
|
+
injector,
|
|
98
|
+
rootElement,
|
|
99
|
+
jsxElement: (0, shade_component_1.createComponent)(ExampleComponent, null),
|
|
100
|
+
});
|
|
101
|
+
expect(document.body.innerHTML).toBe('<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>');
|
|
109
102
|
});
|
|
110
|
-
(0, initialize_1.initializeShadeRoot)({
|
|
111
|
-
injector,
|
|
112
|
-
rootElement,
|
|
113
|
-
jsxElement: ((0, shade_component_1.createComponent)(ExampleComponent, null,
|
|
114
|
-
(0, shade_component_1.createComponent)(ExampleSubs, { no: 1 }),
|
|
115
|
-
(0, shade_component_1.createComponent)(ExampleSubs, { no: 2 }),
|
|
116
|
-
(0, shade_component_1.createComponent)(ExampleSubs, { no: 3 }))),
|
|
117
|
-
});
|
|
118
|
-
expect(document.body.innerHTML).toBe('<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>');
|
|
119
103
|
});
|
|
120
|
-
it(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
104
|
+
it('Should mount nested Shades components', async () => {
|
|
105
|
+
await (0, utils_1.usingAsync)(new inject_1.Injector(), async (injector) => {
|
|
106
|
+
const rootElement = document.getElementById('root');
|
|
107
|
+
const ExampleComponent = (0, shade_1.Shade)({
|
|
108
|
+
render: ({ children }) => (0, shade_component_1.createComponent)("div", null, children),
|
|
109
|
+
shadowDomName: 'shades-example-2',
|
|
110
|
+
});
|
|
111
|
+
const ExampleSubs = (0, shade_1.Shade)({
|
|
112
|
+
render: ({ props }) => (0, shade_component_1.createComponent)("div", null, props.no),
|
|
113
|
+
shadowDomName: 'shades-example-sub',
|
|
114
|
+
});
|
|
115
|
+
(0, initialize_1.initializeShadeRoot)({
|
|
116
|
+
injector,
|
|
117
|
+
rootElement,
|
|
118
|
+
jsxElement: ((0, shade_component_1.createComponent)(ExampleComponent, null,
|
|
119
|
+
(0, shade_component_1.createComponent)(ExampleSubs, { no: 1 }),
|
|
120
|
+
(0, shade_component_1.createComponent)(ExampleSubs, { no: 2 }),
|
|
121
|
+
(0, shade_component_1.createComponent)(ExampleSubs, { no: 3 }))),
|
|
122
|
+
});
|
|
123
|
+
expect(document.body.innerHTML).toBe('<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>');
|
|
134
124
|
});
|
|
135
|
-
expect(constructed).toBeCalled();
|
|
136
|
-
expect(cleanup).not.toBeCalled();
|
|
137
|
-
document.body.innerHTML = '';
|
|
138
|
-
expect(cleanup).toBeCalled();
|
|
139
125
|
});
|
|
140
|
-
it(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
126
|
+
it("Should execute the constructed and constructed's cleanup callback", async () => {
|
|
127
|
+
await (0, utils_1.usingAsync)(new inject_1.Injector(), async (injector) => {
|
|
128
|
+
const rootElement = document.getElementById('root');
|
|
129
|
+
const cleanup = jest.fn();
|
|
130
|
+
const constructed = jest.fn(() => cleanup);
|
|
131
|
+
const ExampleComponent = (0, shade_1.Shade)({
|
|
132
|
+
constructed,
|
|
133
|
+
shadowDomName: 'example-component-1',
|
|
134
|
+
render: () => (0, shade_component_1.createComponent)("div", null, "Hello"),
|
|
135
|
+
});
|
|
136
|
+
(0, initialize_1.initializeShadeRoot)({
|
|
137
|
+
injector,
|
|
138
|
+
rootElement,
|
|
139
|
+
jsxElement: (0, shade_component_1.createComponent)(ExampleComponent, null),
|
|
140
|
+
});
|
|
141
|
+
expect(constructed).toBeCalled();
|
|
142
|
+
expect(cleanup).not.toBeCalled();
|
|
143
|
+
document.body.innerHTML = '';
|
|
144
|
+
expect(cleanup).toBeCalled();
|
|
155
145
|
});
|
|
156
|
-
expect(onAttach).toBeCalled();
|
|
157
|
-
expect(onDetach).not.toBeCalled();
|
|
158
|
-
document.body.innerHTML = '';
|
|
159
|
-
expect(onDetach).toBeCalled();
|
|
160
146
|
});
|
|
161
|
-
it('Should
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
147
|
+
it('Should execute the onAttach and onDetach callbacks', async () => {
|
|
148
|
+
await (0, utils_1.usingAsync)(new inject_1.Injector(), async (injector) => {
|
|
149
|
+
const rootElement = document.getElementById('root');
|
|
150
|
+
const onAttach = jest.fn();
|
|
151
|
+
const onDetach = jest.fn();
|
|
152
|
+
const ExampleComponent = (0, shade_1.Shade)({
|
|
153
|
+
onAttach,
|
|
154
|
+
onDetach,
|
|
155
|
+
shadowDomName: 'example-component-2',
|
|
156
|
+
render: () => (0, shade_component_1.createComponent)("div", null, "Hello"),
|
|
157
|
+
});
|
|
158
|
+
(0, initialize_1.initializeShadeRoot)({
|
|
159
|
+
injector,
|
|
160
|
+
rootElement,
|
|
161
|
+
jsxElement: (0, shade_component_1.createComponent)(ExampleComponent, null),
|
|
162
|
+
});
|
|
163
|
+
expect(onAttach).toBeCalled();
|
|
164
|
+
expect(onDetach).not.toBeCalled();
|
|
165
|
+
document.body.innerHTML = '';
|
|
166
|
+
expect(onDetach).toBeCalled();
|
|
180
167
|
});
|
|
181
|
-
const plus = () => document.getElementById('plus')?.click();
|
|
182
|
-
const minus = () => document.getElementById('minus')?.click();
|
|
183
|
-
const expectCount = (count) => expect(document.body.innerHTML).toContain(`Count is ${count}`);
|
|
184
|
-
expectCount(0);
|
|
185
|
-
plus();
|
|
186
|
-
expectCount(1);
|
|
187
|
-
plus();
|
|
188
|
-
expectCount(2);
|
|
189
|
-
minus();
|
|
190
|
-
minus();
|
|
191
|
-
expectCount(0);
|
|
192
168
|
});
|
|
193
|
-
it('Should
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
169
|
+
it('Should update state', async () => {
|
|
170
|
+
await (0, utils_1.usingAsync)(new inject_1.Injector(), async (injector) => {
|
|
171
|
+
const rootElement = document.getElementById('root');
|
|
172
|
+
const ExampleComponent = (0, shade_1.Shade)({
|
|
173
|
+
shadowDomName: 'example-component-3',
|
|
174
|
+
render: ({ useState }) => {
|
|
175
|
+
const [count, setCount] = useState('count', 0);
|
|
176
|
+
return ((0, shade_component_1.createComponent)("div", null,
|
|
177
|
+
"Count is ",
|
|
178
|
+
count,
|
|
179
|
+
(0, shade_component_1.createComponent)("button", { id: "plus", onclick: () => setCount(count + 1) }, "+"),
|
|
180
|
+
(0, shade_component_1.createComponent)("button", { id: "minus", onclick: () => setCount(count - 1) }, "-")));
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
(0, initialize_1.initializeShadeRoot)({
|
|
184
|
+
injector,
|
|
185
|
+
rootElement,
|
|
186
|
+
jsxElement: (0, shade_component_1.createComponent)(ExampleComponent, null),
|
|
187
|
+
});
|
|
188
|
+
const plus = () => document.getElementById('plus')?.click();
|
|
189
|
+
const minus = () => document.getElementById('minus')?.click();
|
|
190
|
+
const expectCount = (count) => expect(document.body.innerHTML).toContain(`Count is ${count}`);
|
|
191
|
+
expectCount(0);
|
|
192
|
+
plus();
|
|
193
|
+
expectCount(1);
|
|
194
|
+
plus();
|
|
195
|
+
expectCount(2);
|
|
196
|
+
minus();
|
|
197
|
+
minus();
|
|
198
|
+
expectCount(0);
|
|
216
199
|
});
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
200
|
+
});
|
|
201
|
+
it('Should allow children update after unmount and remount', async () => {
|
|
202
|
+
await (0, utils_1.usingAsync)(new inject_1.Injector(), async (injector) => {
|
|
203
|
+
const rootElement = document.getElementById('root');
|
|
204
|
+
const Parent = (0, shade_1.Shade)({
|
|
205
|
+
shadowDomName: 'shade-remount-parent',
|
|
206
|
+
render: ({ children, useState }) => {
|
|
207
|
+
const [areChildrenVisible, setAreChildrenVisible] = useState('areChildrenVisible', true);
|
|
208
|
+
return ((0, shade_component_1.createComponent)("div", null,
|
|
209
|
+
(0, shade_component_1.createComponent)("button", { id: "showHideChildren", onclick: () => {
|
|
210
|
+
setAreChildrenVisible(!areChildrenVisible);
|
|
211
|
+
} }, "Toggle"),
|
|
212
|
+
areChildrenVisible ? children : null));
|
|
213
|
+
},
|
|
214
|
+
});
|
|
215
|
+
const Child = (0, shade_1.Shade)({
|
|
216
|
+
shadowDomName: 'example-remount-child',
|
|
217
|
+
render: ({ useState }) => {
|
|
218
|
+
const [count, setCount] = useState('count', 0);
|
|
219
|
+
return ((0, shade_component_1.createComponent)("div", null,
|
|
220
|
+
"Count is ",
|
|
221
|
+
`${count}`,
|
|
222
|
+
(0, shade_component_1.createComponent)("button", { id: "plus", onclick: () => setCount(count + 1) }, "+"),
|
|
223
|
+
(0, shade_component_1.createComponent)("button", { id: "minus", onclick: () => setCount(count - 1) }, "-")));
|
|
224
|
+
},
|
|
225
|
+
});
|
|
226
|
+
(0, initialize_1.initializeShadeRoot)({
|
|
227
|
+
injector,
|
|
228
|
+
rootElement,
|
|
229
|
+
jsxElement: ((0, shade_component_1.createComponent)(Parent, null,
|
|
230
|
+
(0, shade_component_1.createComponent)(Child, null))),
|
|
231
|
+
});
|
|
232
|
+
const plus = () => document.getElementById('plus')?.click();
|
|
233
|
+
const minus = () => document.getElementById('minus')?.click();
|
|
234
|
+
const expectCount = (count) => expect(document.body.innerHTML).toContain(`Count is ${count}`);
|
|
235
|
+
const toggleChildren = () => document.getElementById('showHideChildren')?.click();
|
|
236
|
+
expectCount(0);
|
|
237
|
+
plus();
|
|
238
|
+
expectCount(1);
|
|
239
|
+
toggleChildren();
|
|
240
|
+
expect(document.getElementById('plus')).toBeNull();
|
|
241
|
+
toggleChildren();
|
|
242
|
+
expect(document.getElementById('plus')).toBeDefined();
|
|
243
|
+
expectCount(0);
|
|
244
|
+
plus();
|
|
245
|
+
expectCount(1);
|
|
246
|
+
minus();
|
|
247
|
+
expectCount(0);
|
|
222
248
|
});
|
|
223
|
-
const plus = () => document.getElementById('plus')?.click();
|
|
224
|
-
const minus = () => document.getElementById('minus')?.click();
|
|
225
|
-
const expectCount = (count) => expect(document.body.innerHTML).toContain(`Count is ${count}`);
|
|
226
|
-
const toggleChildren = () => document.getElementById('showHideChildren')?.click();
|
|
227
|
-
expectCount(0);
|
|
228
|
-
plus();
|
|
229
|
-
expectCount(1);
|
|
230
|
-
toggleChildren();
|
|
231
|
-
expect(document.getElementById('plus')).toBeNull();
|
|
232
|
-
toggleChildren();
|
|
233
|
-
expect(document.getElementById('plus')).toBeDefined();
|
|
234
|
-
// expectCount(0)
|
|
235
|
-
plus();
|
|
236
|
-
expectCount(1);
|
|
237
|
-
minus();
|
|
238
|
-
expectCount(0);
|
|
239
249
|
});
|
|
240
250
|
});
|
|
241
251
|
//# sourceMappingURL=shades.integration.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shades.integration.spec.js","sourceRoot":"","sources":["../src/shades.integration.spec.tsx"],"names":[],"mappings":";;AAAA,8CAA4C;
|
|
1
|
+
{"version":3,"file":"shades.integration.spec.js","sourceRoot":"","sources":["../src/shades.integration.spec.tsx"],"names":[],"mappings":";;AAAA,8CAA4C;AAC5C,4CAA6C;AAE7C,+BAA+C;AAE/C,MAAM,CAAC,WAAW,GAAG,kBAAW,CAAA;AAChC,MAAM,CAAC,WAAW,GAAG,kBAAkB,CAAA;AAEvC,6CAAkD;AAClD,mCAA+B;AAC/B,uDAAmD;AAEnD,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,GAAG,uBAAuB,CAAC,CAAC,CAAA;IACrE,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC,CAAC,CAAA;IAE/C,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,QAAQ,GAAG,IAAI,iBAAQ,EAAE,CAAA;QAC/B,MAAM,WAAW,GAAG,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAmB,CAAA;QAErE,MAAM,gBAAgB,GAAG,IAAA,aAAK,EAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,4DAAgB,EAAE,aAAa,EAAE,gBAAgB,EAAE,CAAC,CAAA;QAEnG,IAAA,gCAAmB,EAAC;YAClB,QAAQ;YACR,WAAW;YACX,UAAU,EAAE,uCAAC,gBAAgB,OAAG;SACjC,CAAC,CAAA;QACF,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,wEAAwE,CAAC,CAAA;IAChH,CAAC,CAAC,CAAA;IAEF,E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2
2
|
"name": "@furystack/shades",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Google Authentication Provider for FuryStack",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -29,15 +29,15 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://github.com/furystack/furystack",
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/jest": "^29.2.
|
|
32
|
+
"@types/jest": "^29.2.6",
|
|
33
33
|
"@types/jsdom": "^20.0.1",
|
|
34
34
|
"@types/node": "^18.11.18",
|
|
35
35
|
"jsdom": "^21.0.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@furystack/core": "^11.2.
|
|
39
|
-
"@furystack/inject": "^7.1.
|
|
40
|
-
"@furystack/utils": "^3.1.
|
|
38
|
+
"@furystack/core": "^11.2.3",
|
|
39
|
+
"@furystack/inject": "^7.1.5",
|
|
40
|
+
"@furystack/utils": "^3.1.5",
|
|
41
41
|
"path-to-regexp": "^6.2.1",
|
|
42
42
|
"semaphore-async-await": "^1.5.1"
|
|
43
43
|
},
|
|
@@ -59,8 +59,7 @@ describe('Shades Component Factory', () => {
|
|
|
59
59
|
)
|
|
60
60
|
|
|
61
61
|
const shade = component.firstElementChild as JSX.Element
|
|
62
|
-
expect(shade.props).
|
|
63
|
-
expect(shade.state).toBe(undefined)
|
|
62
|
+
expect(shade.props).toEqual({})
|
|
64
63
|
expect(shade.shadeChildren).toEqual([])
|
|
65
64
|
})
|
|
66
65
|
|
|
@@ -81,17 +80,18 @@ describe('Shades Component Factory', () => {
|
|
|
81
80
|
shade.callConstructed()
|
|
82
81
|
|
|
83
82
|
expect(shade.props.foo).toEqual('example')
|
|
84
|
-
expect(shade.state).toBe(undefined)
|
|
85
83
|
expect(shade.shadeChildren).toEqual([])
|
|
86
84
|
|
|
87
85
|
expect(shade.innerHTML).toBe('<div>example</div>')
|
|
88
86
|
})
|
|
89
87
|
|
|
90
88
|
it('Should render a component with state', () => {
|
|
91
|
-
const Example = Shade
|
|
92
|
-
getInitialState: () => ({ foo: 'example' }),
|
|
89
|
+
const Example = Shade({
|
|
93
90
|
shadowDomName: 'example-with-state',
|
|
94
|
-
render: () =>
|
|
91
|
+
render: ({ useState }) => {
|
|
92
|
+
useState('foo', 'example')
|
|
93
|
+
return <div />
|
|
94
|
+
},
|
|
95
95
|
})
|
|
96
96
|
|
|
97
97
|
const component = (
|
|
@@ -102,7 +102,7 @@ describe('Shades Component Factory', () => {
|
|
|
102
102
|
|
|
103
103
|
const shade = component.firstElementChild as JSX.Element
|
|
104
104
|
shade.callConstructed()
|
|
105
|
-
expect(shade.
|
|
105
|
+
expect(shade.resourceManager.stateObservers.get('foo')?.getValue()).toEqual('example')
|
|
106
106
|
expect(shade.shadeChildren).toEqual([])
|
|
107
107
|
})
|
|
108
108
|
})
|
|
@@ -11,36 +11,40 @@ export interface LazyLoadState {
|
|
|
11
11
|
error?: unknown
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export const LazyLoad = Shade<LazyLoadProps
|
|
15
|
-
getInitialState: () => ({}),
|
|
14
|
+
export const LazyLoad = Shade<LazyLoadProps>({
|
|
16
15
|
shadowDomName: 'lazy-load',
|
|
17
|
-
constructed: async ({ props,
|
|
16
|
+
constructed: async ({ props, useState }) => {
|
|
17
|
+
const [_component, setComponent] = useState<JSX.Element | undefined>('component', undefined)
|
|
18
|
+
const [_errorState, setErrorState] = useState<unknown | undefined>('error', undefined)
|
|
18
19
|
try {
|
|
19
20
|
const loaded = await props.component()
|
|
20
|
-
|
|
21
|
+
setComponent(loaded)
|
|
21
22
|
} catch (error) {
|
|
22
23
|
if (props.error) {
|
|
23
|
-
|
|
24
|
+
setErrorState(error)
|
|
24
25
|
} else {
|
|
25
26
|
throw error
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
},
|
|
29
|
-
render: ({ props,
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
render: ({ props, useState }) => {
|
|
31
|
+
const [error, setError] = useState<unknown | undefined>('error', undefined)
|
|
32
|
+
const [component, setComponent] = useState<JSX.Element | undefined>('component', undefined)
|
|
33
|
+
|
|
34
|
+
if (error && props.error) {
|
|
35
|
+
return props.error(error, async () => {
|
|
33
36
|
try {
|
|
34
|
-
|
|
37
|
+
setError(undefined)
|
|
38
|
+
setComponent(undefined)
|
|
35
39
|
const loaded = await props.component()
|
|
36
|
-
|
|
37
|
-
} catch (
|
|
38
|
-
|
|
40
|
+
setComponent(loaded)
|
|
41
|
+
} catch (e) {
|
|
42
|
+
setError(e)
|
|
39
43
|
}
|
|
40
44
|
})
|
|
41
45
|
}
|
|
42
|
-
if (
|
|
43
|
-
return
|
|
46
|
+
if (component) {
|
|
47
|
+
return component
|
|
44
48
|
}
|
|
45
49
|
return props.loader
|
|
46
50
|
},
|
|
@@ -17,7 +17,7 @@ describe('RouteLink', () => {
|
|
|
17
17
|
|
|
18
18
|
const onRouteChange = jest.fn()
|
|
19
19
|
|
|
20
|
-
injector.getInstance(LocationService).
|
|
20
|
+
injector.getInstance(LocationService).onLocationPathChanged.subscribe(onRouteChange)
|
|
21
21
|
|
|
22
22
|
initializeShadeRoot({
|
|
23
23
|
injector,
|
|
@@ -29,7 +29,7 @@ describe('RouteLink', () => {
|
|
|
29
29
|
),
|
|
30
30
|
})
|
|
31
31
|
expect(document.body.innerHTML).toBe(
|
|
32
|
-
'<div id="root"><route-link
|
|
32
|
+
'<div id="root"><route-link id="route"><a href="/subroute" style="text-decoration: inherit;">Link</a></route-link></div>',
|
|
33
33
|
)
|
|
34
34
|
expect(onRouteChange).not.toBeCalled()
|
|
35
35
|
document.getElementById('route')?.click()
|