sinho 0.1.4 → 0.2.1
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/bundle.d.ts +2 -1
- package/dist/bundle.js +49 -32
- package/dist/bundle.min.js +1 -1
- package/dist/dom.js +1 -7
- package/dist/dom.js.map +1 -1
- package/dist/mod.d.ts +1 -1
- package/dist/mod.js +1 -1
- package/dist/mod.js.map +1 -1
- package/dist/scope.d.ts +1 -0
- package/dist/scope.js +47 -25
- package/dist/scope.js.map +1 -1
- package/package.json +1 -1
- package/src/dom.ts +1 -5
- package/src/mod.ts +3 -2
- package/src/scope.ts +59 -26
- package/dist/intrinsic/Dynamic.d.ts +0 -33
- package/dist/intrinsic/Dynamic.js +0 -53
- package/dist/intrinsic/Dynamic.js.map +0 -1
- package/dist/intrinsic/ErrorBoundary.d.ts +0 -14
- package/dist/intrinsic/ErrorBoundary.js +0 -36
- package/dist/intrinsic/ErrorBoundary.js.map +0 -1
- package/web/dist/shingo.min.d.ts +0 -1131
- package/web/dist/shingo.min.js +0 -1
- package/web/static/dist/bundle.d.ts +0 -1126
- package/web/static/dist/bundle.min.js +0 -1
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { useScope, useSignal } from "../scope.js";
|
|
2
|
-
import { createTemplate } from "../template.js";
|
|
3
|
-
import { Fragment } from "./Fragment.js";
|
|
4
|
-
import { createContext, provideContext, useContext } from "../context.js";
|
|
5
|
-
import { If } from "./If.js";
|
|
6
|
-
const ErrorContext = createContext([
|
|
7
|
-
(err) => {
|
|
8
|
-
throw err;
|
|
9
|
-
},
|
|
10
|
-
() => { },
|
|
11
|
-
]);
|
|
12
|
-
/**
|
|
13
|
-
* `ErrorBoundary` is a component that can be used to catch errors in the
|
|
14
|
-
* component tree.
|
|
15
|
-
*/
|
|
16
|
-
export const ErrorBoundary = ({ fallback, children }) => {
|
|
17
|
-
let error;
|
|
18
|
-
const [showError, setShowError] = useSignal(false);
|
|
19
|
-
const show = (err) => {
|
|
20
|
-
error = err;
|
|
21
|
-
setShowError(true);
|
|
22
|
-
};
|
|
23
|
-
const reset = () => setShowError(false);
|
|
24
|
-
return If({
|
|
25
|
-
condition: showError,
|
|
26
|
-
then: createTemplate(() => fallback?.({ error, reset }) ?? []),
|
|
27
|
-
else: createTemplate(() => {
|
|
28
|
-
provideContext(ErrorContext, () => [show, reset]);
|
|
29
|
-
const s = useScope();
|
|
30
|
-
s._onError = show;
|
|
31
|
-
return Fragment({ children });
|
|
32
|
-
}),
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
export const useErrorBoundary = () => useContext(ErrorContext)();
|
|
36
|
-
//# sourceMappingURL=ErrorBoundary.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorBoundary.js","sourceRoot":"","sources":["../../src/intrinsic/ErrorBoundary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAY,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAE7B,MAAM,YAAY,GAAG,aAAa,CAAC;IACjC,CAAC,GAAY,EAAQ,EAAE;QACrB,MAAM,GAAG,CAAC;IACZ,CAAC;IACD,GAAS,EAAE,GAAE,CAAC;CACN,CAAC,CAAC;AAEZ;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAMrB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC9B,IAAI,KAAc,CAAC;IACnB,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IAEnD,MAAM,IAAI,GAAG,CAAC,GAAY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