thunderous 2.1.0 → 2.2.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/index.cjs +40 -14
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +40 -14
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
@@ -193,21 +193,27 @@ var getServerRenderArgs = (tagName, registry) => ({
|
|
193
193
|
get elementRef() {
|
194
194
|
return new Proxy({}, {
|
195
195
|
get: () => {
|
196
|
-
|
196
|
+
const error = new Error("The `elementRef` property is not available on the server.");
|
197
|
+
console.error(error);
|
198
|
+
throw error;
|
197
199
|
}
|
198
200
|
});
|
199
201
|
},
|
200
202
|
get root() {
|
201
203
|
return new Proxy({}, {
|
202
204
|
get: () => {
|
203
|
-
|
205
|
+
const error = new Error("The `root` property is not available on the server.");
|
206
|
+
console.error(error);
|
207
|
+
throw error;
|
204
208
|
}
|
205
209
|
});
|
206
210
|
},
|
207
211
|
get internals() {
|
208
212
|
return new Proxy({}, {
|
209
213
|
get: () => {
|
210
|
-
|
214
|
+
const error = new Error("The `internals` property is not available on the server.");
|
215
|
+
console.error(error);
|
216
|
+
throw error;
|
211
217
|
}
|
212
218
|
});
|
213
219
|
},
|
@@ -399,9 +405,11 @@ var evaluateBindings = (element, fragment) => {
|
|
399
405
|
const result = signal();
|
400
406
|
const nextNode = createNewNode(result, element, uniqueKey);
|
401
407
|
if (nextNode instanceof Text) {
|
402
|
-
|
408
|
+
const error = new TypeError(
|
403
409
|
"Signal mismatch: expected DocumentFragment or Array<DocumentFragment>, but got Text"
|
404
410
|
);
|
411
|
+
console.error(error);
|
412
|
+
throw error;
|
405
413
|
}
|
406
414
|
for (const child2 of element.children) {
|
407
415
|
const key = child2.getAttribute("key");
|
@@ -616,7 +624,9 @@ var customElement = (render, options) => {
|
|
616
624
|
return this;
|
617
625
|
},
|
618
626
|
eject() {
|
619
|
-
|
627
|
+
const error = new Error("Cannot eject a custom element on the server.");
|
628
|
+
console.error(error);
|
629
|
+
throw error;
|
620
630
|
}
|
621
631
|
};
|
622
632
|
}
|
@@ -714,15 +724,15 @@ var customElement = (render, options) => {
|
|
714
724
|
};
|
715
725
|
const getter = () => {
|
716
726
|
const value = _getter();
|
717
|
-
if (value === void 0)
|
718
|
-
|
719
|
-
`
|
720
|
-
|
721
|
-
Property: ${prop}
|
722
|
-
|
727
|
+
if (value === void 0) {
|
728
|
+
const error = new Error(
|
729
|
+
`Error accessing property: "${prop}"
|
723
730
|
You must set an initial value before calling a property signal's getter.
|
724
731
|
`
|
725
732
|
);
|
733
|
+
console.error(error);
|
734
|
+
throw error;
|
735
|
+
}
|
726
736
|
return value;
|
727
737
|
};
|
728
738
|
getter.getter = true;
|
@@ -734,7 +744,12 @@ You must set an initial value before calling a property signal's getter.
|
|
734
744
|
setFromProp = false;
|
735
745
|
}
|
736
746
|
});
|
737
|
-
|
747
|
+
const publicSignal = [getter, setter];
|
748
|
+
publicSignal.init = (value) => {
|
749
|
+
_setter(value);
|
750
|
+
return [getter, setter];
|
751
|
+
};
|
752
|
+
return publicSignal;
|
738
753
|
},
|
739
754
|
set: () => {
|
740
755
|
console.error("Signals must be assigned via setters.");
|
@@ -788,7 +803,16 @@ You must set an initial value before calling a property signal's getter.
|
|
788
803
|
return observedAttributes;
|
789
804
|
}
|
790
805
|
constructor() {
|
791
|
-
|
806
|
+
try {
|
807
|
+
super();
|
808
|
+
} catch (error) {
|
809
|
+
const _error = new Error(
|
810
|
+
"Error instantiating element:\nThis usually occurs if you have errors in the function body of your component. Check prior logs for possible causes.\n",
|
811
|
+
{ cause: error }
|
812
|
+
);
|
813
|
+
console.error(_error);
|
814
|
+
throw _error;
|
815
|
+
}
|
792
816
|
if (!Object.prototype.hasOwnProperty.call(this, "__customCallbackFns")) {
|
793
817
|
this.__customCallbackFns = /* @__PURE__ */ new Map();
|
794
818
|
}
|
@@ -970,7 +994,9 @@ var createRegistry = (args) => {
|
|
970
994
|
getAllTagNames: () => Array.from(customElementTags),
|
971
995
|
eject: () => {
|
972
996
|
if (nativeRegistry === void 0) {
|
973
|
-
|
997
|
+
const error = new Error("Cannot eject a registry on the server.");
|
998
|
+
console.error(error);
|
999
|
+
throw error;
|
974
1000
|
}
|
975
1001
|
return nativeRegistry;
|
976
1002
|
},
|
package/dist/index.d.cts
CHANGED
@@ -46,7 +46,7 @@ type RenderArgs<Props extends CustomElementProps> = {
|
|
46
46
|
customCallback: (fn: () => void) => `this.getRootNode().host.__customCallbackFns.get('${string}')(event)` | '';
|
47
47
|
attrSignals: Record<string, Signal<string | null>>;
|
48
48
|
propSignals: {
|
49
|
-
[K in keyof Props]:
|
49
|
+
[K in keyof Props]: SignalWithInit<Props[K]>;
|
50
50
|
};
|
51
51
|
refs: Record<string, HTMLElement | null>;
|
52
52
|
adoptStyleSheet: (stylesheet: Styles) => void;
|
@@ -102,6 +102,10 @@ type SignalGetter<T> = {
|
|
102
102
|
type SignalSetter<T> = (newValue: T, options?: SignalOptions) => void;
|
103
103
|
type Signal<T = unknown> = [SignalGetter<T>, SignalSetter<T>];
|
104
104
|
|
105
|
+
// TODO: add `| undefined` to the uninitialized signal.
|
106
|
+
// The reason I didn't do it yet is that it's a breaking change. I'll wait for the next major version.
|
107
|
+
type SignalWithInit<T = unknown> = Signal<T> & { init: (value: T) => Signal<T> };
|
108
|
+
|
105
109
|
// Flexible typing is necessary to support generic functions
|
106
110
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
107
111
|
type AnyFn = (...args: any[]) => any;
|
package/dist/index.d.ts
CHANGED
@@ -46,7 +46,7 @@ type RenderArgs<Props extends CustomElementProps> = {
|
|
46
46
|
customCallback: (fn: () => void) => `this.getRootNode().host.__customCallbackFns.get('${string}')(event)` | '';
|
47
47
|
attrSignals: Record<string, Signal<string | null>>;
|
48
48
|
propSignals: {
|
49
|
-
[K in keyof Props]:
|
49
|
+
[K in keyof Props]: SignalWithInit<Props[K]>;
|
50
50
|
};
|
51
51
|
refs: Record<string, HTMLElement | null>;
|
52
52
|
adoptStyleSheet: (stylesheet: Styles) => void;
|
@@ -102,6 +102,10 @@ type SignalGetter<T> = {
|
|
102
102
|
type SignalSetter<T> = (newValue: T, options?: SignalOptions) => void;
|
103
103
|
type Signal<T = unknown> = [SignalGetter<T>, SignalSetter<T>];
|
104
104
|
|
105
|
+
// TODO: add `| undefined` to the uninitialized signal.
|
106
|
+
// The reason I didn't do it yet is that it's a breaking change. I'll wait for the next major version.
|
107
|
+
type SignalWithInit<T = unknown> = Signal<T> & { init: (value: T) => Signal<T> };
|
108
|
+
|
105
109
|
// Flexible typing is necessary to support generic functions
|
106
110
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
107
111
|
type AnyFn = (...args: any[]) => any;
|
package/dist/index.js
CHANGED
@@ -158,21 +158,27 @@ var getServerRenderArgs = (tagName, registry) => ({
|
|
158
158
|
get elementRef() {
|
159
159
|
return new Proxy({}, {
|
160
160
|
get: () => {
|
161
|
-
|
161
|
+
const error = new Error("The `elementRef` property is not available on the server.");
|
162
|
+
console.error(error);
|
163
|
+
throw error;
|
162
164
|
}
|
163
165
|
});
|
164
166
|
},
|
165
167
|
get root() {
|
166
168
|
return new Proxy({}, {
|
167
169
|
get: () => {
|
168
|
-
|
170
|
+
const error = new Error("The `root` property is not available on the server.");
|
171
|
+
console.error(error);
|
172
|
+
throw error;
|
169
173
|
}
|
170
174
|
});
|
171
175
|
},
|
172
176
|
get internals() {
|
173
177
|
return new Proxy({}, {
|
174
178
|
get: () => {
|
175
|
-
|
179
|
+
const error = new Error("The `internals` property is not available on the server.");
|
180
|
+
console.error(error);
|
181
|
+
throw error;
|
176
182
|
}
|
177
183
|
});
|
178
184
|
},
|
@@ -364,9 +370,11 @@ var evaluateBindings = (element, fragment) => {
|
|
364
370
|
const result = signal();
|
365
371
|
const nextNode = createNewNode(result, element, uniqueKey);
|
366
372
|
if (nextNode instanceof Text) {
|
367
|
-
|
373
|
+
const error = new TypeError(
|
368
374
|
"Signal mismatch: expected DocumentFragment or Array<DocumentFragment>, but got Text"
|
369
375
|
);
|
376
|
+
console.error(error);
|
377
|
+
throw error;
|
370
378
|
}
|
371
379
|
for (const child2 of element.children) {
|
372
380
|
const key = child2.getAttribute("key");
|
@@ -581,7 +589,9 @@ var customElement = (render, options) => {
|
|
581
589
|
return this;
|
582
590
|
},
|
583
591
|
eject() {
|
584
|
-
|
592
|
+
const error = new Error("Cannot eject a custom element on the server.");
|
593
|
+
console.error(error);
|
594
|
+
throw error;
|
585
595
|
}
|
586
596
|
};
|
587
597
|
}
|
@@ -679,15 +689,15 @@ var customElement = (render, options) => {
|
|
679
689
|
};
|
680
690
|
const getter = () => {
|
681
691
|
const value = _getter();
|
682
|
-
if (value === void 0)
|
683
|
-
|
684
|
-
`
|
685
|
-
|
686
|
-
Property: ${prop}
|
687
|
-
|
692
|
+
if (value === void 0) {
|
693
|
+
const error = new Error(
|
694
|
+
`Error accessing property: "${prop}"
|
688
695
|
You must set an initial value before calling a property signal's getter.
|
689
696
|
`
|
690
697
|
);
|
698
|
+
console.error(error);
|
699
|
+
throw error;
|
700
|
+
}
|
691
701
|
return value;
|
692
702
|
};
|
693
703
|
getter.getter = true;
|
@@ -699,7 +709,12 @@ You must set an initial value before calling a property signal's getter.
|
|
699
709
|
setFromProp = false;
|
700
710
|
}
|
701
711
|
});
|
702
|
-
|
712
|
+
const publicSignal = [getter, setter];
|
713
|
+
publicSignal.init = (value) => {
|
714
|
+
_setter(value);
|
715
|
+
return [getter, setter];
|
716
|
+
};
|
717
|
+
return publicSignal;
|
703
718
|
},
|
704
719
|
set: () => {
|
705
720
|
console.error("Signals must be assigned via setters.");
|
@@ -753,7 +768,16 @@ You must set an initial value before calling a property signal's getter.
|
|
753
768
|
return observedAttributes;
|
754
769
|
}
|
755
770
|
constructor() {
|
756
|
-
|
771
|
+
try {
|
772
|
+
super();
|
773
|
+
} catch (error) {
|
774
|
+
const _error = new Error(
|
775
|
+
"Error instantiating element:\nThis usually occurs if you have errors in the function body of your component. Check prior logs for possible causes.\n",
|
776
|
+
{ cause: error }
|
777
|
+
);
|
778
|
+
console.error(_error);
|
779
|
+
throw _error;
|
780
|
+
}
|
757
781
|
if (!Object.prototype.hasOwnProperty.call(this, "__customCallbackFns")) {
|
758
782
|
this.__customCallbackFns = /* @__PURE__ */ new Map();
|
759
783
|
}
|
@@ -935,7 +959,9 @@ var createRegistry = (args) => {
|
|
935
959
|
getAllTagNames: () => Array.from(customElementTags),
|
936
960
|
eject: () => {
|
937
961
|
if (nativeRegistry === void 0) {
|
938
|
-
|
962
|
+
const error = new Error("Cannot eject a registry on the server.");
|
963
|
+
console.error(error);
|
964
|
+
throw error;
|
939
965
|
}
|
940
966
|
return nativeRegistry;
|
941
967
|
},
|