rask-ui 0.20.1 → 0.20.3
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/asyncState.d.ts +16 -0
- package/dist/asyncState.d.ts.map +1 -0
- package/dist/asyncState.js +24 -0
- package/dist/compiler.d.ts +2 -0
- package/dist/compiler.d.ts.map +1 -0
- package/dist/compiler.js +1 -0
- package/dist/component.d.ts +1 -1
- package/dist/component.d.ts.map +1 -1
- package/dist/component.js +15 -2
- package/dist/context.d.ts +5 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +29 -0
- package/dist/createAsync.test.d.ts +2 -0
- package/dist/createAsync.test.d.ts.map +1 -0
- package/dist/createAsync.test.js +110 -0
- package/dist/createMutation.test.d.ts +2 -0
- package/dist/createMutation.test.d.ts.map +1 -0
- package/dist/createMutation.test.js +168 -0
- package/dist/createQuery.test.d.ts +2 -0
- package/dist/createQuery.test.d.ts.map +1 -0
- package/dist/createQuery.test.js +156 -0
- package/dist/createRef.d.ts +6 -0
- package/dist/createRef.d.ts.map +1 -0
- package/dist/createRef.js +8 -0
- package/dist/createState.d.ts +0 -2
- package/dist/createState.d.ts.map +1 -1
- package/dist/createState.js +5 -40
- package/dist/createState.test.d.ts.map +1 -0
- package/dist/createState.test.js +111 -0
- package/dist/createView.d.ts +44 -18
- package/dist/createView.d.ts.map +1 -1
- package/dist/createView.js +48 -57
- package/dist/createView.test.d.ts.map +1 -0
- package/dist/{tests/createView.test.js → createView.test.js} +40 -40
- package/dist/error.d.ts +14 -3
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +15 -14
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/jsx.d.ts +256 -10
- package/dist/observation.test.d.ts.map +1 -0
- package/dist/observation.test.js +150 -0
- package/dist/plugin.js +1 -1
- package/dist/suspense.d.ts +25 -0
- package/dist/suspense.d.ts.map +1 -0
- package/dist/suspense.js +97 -0
- package/dist/test-setup.d.ts +16 -0
- package/dist/test-setup.d.ts.map +1 -0
- package/dist/test-setup.js +40 -0
- package/dist/test.d.ts +2 -0
- package/dist/test.d.ts.map +1 -0
- package/dist/test.js +24 -0
- package/dist/types.d.ts +20 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/package.json +5 -1
- package/swc-plugin/target/wasm32-wasip1/release/swc_plugin_rask_component.wasm +0 -0
- package/dist/createComputed.d.ts +0 -4
- package/dist/createComputed.d.ts.map +0 -1
- package/dist/createComputed.js +0 -69
- package/dist/createEffect.d.ts +0 -2
- package/dist/createEffect.d.ts.map +0 -1
- package/dist/createEffect.js +0 -29
- package/dist/createRouter.d.ts +0 -8
- package/dist/createRouter.d.ts.map +0 -1
- package/dist/createRouter.js +0 -27
- package/dist/createTask.d.ts +0 -31
- package/dist/createTask.d.ts.map +0 -1
- package/dist/createTask.js +0 -79
- package/dist/patchInferno.d.ts +0 -6
- package/dist/patchInferno.d.ts.map +0 -1
- package/dist/patchInferno.js +0 -53
- package/dist/scheduler.d.ts +0 -4
- package/dist/scheduler.d.ts.map +0 -1
- package/dist/scheduler.js +0 -107
- package/dist/tests/batch.test.d.ts +0 -2
- package/dist/tests/batch.test.d.ts.map +0 -1
- package/dist/tests/batch.test.js +0 -244
- package/dist/tests/createComputed.test.d.ts +0 -2
- package/dist/tests/createComputed.test.d.ts.map +0 -1
- package/dist/tests/createComputed.test.js +0 -257
- package/dist/tests/createContext.test.d.ts +0 -2
- package/dist/tests/createContext.test.d.ts.map +0 -1
- package/dist/tests/createContext.test.js +0 -136
- package/dist/tests/createEffect.test.d.ts +0 -2
- package/dist/tests/createEffect.test.d.ts.map +0 -1
- package/dist/tests/createEffect.test.js +0 -467
- package/dist/tests/createState.test.d.ts.map +0 -1
- package/dist/tests/createState.test.js +0 -144
- package/dist/tests/createTask.test.d.ts +0 -2
- package/dist/tests/createTask.test.d.ts.map +0 -1
- package/dist/tests/createTask.test.js +0 -322
- package/dist/tests/createView.test.d.ts.map +0 -1
- package/dist/tests/error.test.d.ts +0 -2
- package/dist/tests/error.test.d.ts.map +0 -1
- package/dist/tests/error.test.js +0 -168
- package/dist/tests/observation.test.d.ts.map +0 -1
- package/dist/tests/observation.test.js +0 -341
- package/dist/useComputed.d.ts +0 -5
- package/dist/useComputed.d.ts.map +0 -1
- package/dist/useComputed.js +0 -69
- package/dist/useQuery.d.ts +0 -25
- package/dist/useQuery.d.ts.map +0 -1
- package/dist/useQuery.js +0 -25
- package/dist/useSuspendAsync.d.ts +0 -18
- package/dist/useSuspendAsync.d.ts.map +0 -1
- package/dist/useSuspendAsync.js +0 -37
- package/dist/useTask.d.ts +0 -25
- package/dist/useTask.d.ts.map +0 -1
- package/dist/useTask.js +0 -70
- /package/dist/{tests/createState.test.d.ts → createState.test.d.ts} +0 -0
- /package/dist/{tests/createView.test.d.ts → createView.test.d.ts} +0 -0
- /package/dist/{tests/observation.test.d.ts → observation.test.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"AAiBA,wBAAgB,IAAI,CAAC,SAAS,EAAE,GAAG,QA4BlC"}
|
package/dist/test.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { init, classModule, propsModule, styleModule, eventListenersModule, h, } from "snabbdom";
|
|
2
|
+
const patch = init([
|
|
3
|
+
// Init patch function with chosen modules
|
|
4
|
+
classModule, // makes it easy to toggle classes
|
|
5
|
+
propsModule, // for setting properties on DOM elements
|
|
6
|
+
styleModule, // handles styling on elements with support for animations
|
|
7
|
+
eventListenersModule, // attaches event listeners
|
|
8
|
+
]);
|
|
9
|
+
export function test(container) {
|
|
10
|
+
const vnode = h("div#container.two.classes", { on: { click: () => console.log("div clicked") } }, [
|
|
11
|
+
h("span", { style: { fontWeight: "bold" } }, "This is bold"),
|
|
12
|
+
" and this is just normal text",
|
|
13
|
+
h("a", { props: { href: "/foo" } }, "I'll take you places!"),
|
|
14
|
+
]);
|
|
15
|
+
// Patch into empty DOM element – this modifies the DOM as a side effect
|
|
16
|
+
patch(container, vnode);
|
|
17
|
+
const newVnode = h("div#container.two.classes", { on: { click: () => console.log("updated div clicked") } }, [
|
|
18
|
+
h("span", { style: { fontWeight: "normal", fontStyle: "italic" } }, "This is now italic type"),
|
|
19
|
+
" and this is still just normal text",
|
|
20
|
+
h("a", { props: { href: "/bar" } }, "I'll take you places!"),
|
|
21
|
+
]);
|
|
22
|
+
// Second `patch` invocation
|
|
23
|
+
patch(vnode, newVnode); // Snabbdom efficiently updates the old view to the new state
|
|
24
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ClipboardEvent as InfernoClipboardEvent, ChangeEvent as InfernoChangeEvent, DragEvent as InfernoDragEvent, FocusEvent as InfernoFocusEvent, FormEvent as InfernoFormEvent, InfernoMouseEvent, InfernoAnimationEvent, InfernoKeyboardEvent, InfernoPointerEvent, InfernoTouchEvent, InfernoWheelEvent, InfernoTransitionEvent, CompositionEvent as InfernoCompositionEvent } from "inferno";
|
|
2
|
+
declare global {
|
|
3
|
+
namespace Rask {
|
|
4
|
+
type MouseEvent<T = Element> = InfernoMouseEvent<T>;
|
|
5
|
+
type AnimationEvent<T = Element> = InfernoAnimationEvent<T>;
|
|
6
|
+
type KeyboardEvent<T = Element> = InfernoKeyboardEvent<T>;
|
|
7
|
+
type PointerEvent<T = Element> = InfernoPointerEvent<T>;
|
|
8
|
+
type TouchEvent<T = Element> = InfernoTouchEvent<T>;
|
|
9
|
+
type WheelEvent<T = Element> = InfernoWheelEvent<T>;
|
|
10
|
+
type TransitionEvent<T = Element> = InfernoTransitionEvent<T>;
|
|
11
|
+
type ClipboardEvent<T = Element> = InfernoClipboardEvent<T>;
|
|
12
|
+
type ChangeEvent<T = Element> = InfernoChangeEvent<T>;
|
|
13
|
+
type DragEvent<T = Element> = InfernoDragEvent<T>;
|
|
14
|
+
type FocusEvent<T = Element> = InfernoFocusEvent<T>;
|
|
15
|
+
type FormEvent<T = Element> = InfernoFormEvent<T>;
|
|
16
|
+
type CompositionEvent<T = Element> = InfernoCompositionEvent<T>;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,IAAI,qBAAqB,EACvC,WAAW,IAAI,kBAAkB,EACjC,SAAS,IAAI,gBAAgB,EAC7B,UAAU,IAAI,iBAAiB,EAC/B,SAAS,IAAI,gBAAgB,EAC7B,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,IAAI,uBAAuB,EAC5C,MAAM,SAAS,CAAC;AAEjB,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,IAAI,CAAC;QAEb,KAAY,UAAU,CAAC,CAAC,GAAG,OAAO,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAC3D,KAAY,cAAc,CAAC,CAAC,GAAG,OAAO,IAAI,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACnE,KAAY,aAAa,CAAC,CAAC,GAAG,OAAO,IAAI,oBAAoB,CAAC,CAAC,CAAC,CAAC;QACjE,KAAY,YAAY,CAAC,CAAC,GAAG,OAAO,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAAC;QAC/D,KAAY,UAAU,CAAC,CAAC,GAAG,OAAO,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAC3D,KAAY,UAAU,CAAC,CAAC,GAAG,OAAO,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAC3D,KAAY,eAAe,CAAC,CAAC,GAAG,OAAO,IAAI,sBAAsB,CAAC,CAAC,CAAC,CAAC;QACrE,KAAY,cAAc,CAAC,CAAC,GAAG,OAAO,IAAI,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACnE,KAAY,WAAW,CAAC,CAAC,GAAG,OAAO,IAAI,kBAAkB,CAAC,CAAC,CAAC,CAAC;QAC7D,KAAY,SAAS,CAAC,CAAC,GAAG,OAAO,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAC;QACzD,KAAY,UAAU,CAAC,CAAC,GAAG,OAAO,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAC3D,KAAY,SAAS,CAAC,CAAC,GAAG,OAAO,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAC;QACzD,KAAY,gBAAgB,CAAC,CAAC,GAAG,OAAO,IAAI,uBAAuB,CAAC,CAAC,CAAC,CAAC;KACxE;CACF;AAGD,OAAO,EAAE,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rask-ui",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -20,6 +20,10 @@
|
|
|
20
20
|
"./plugin": {
|
|
21
21
|
"types": "./dist/plugin.d.ts",
|
|
22
22
|
"import": "./dist/plugin.js"
|
|
23
|
+
},
|
|
24
|
+
"./compiler": {
|
|
25
|
+
"types": "./dist/compiler.d.ts",
|
|
26
|
+
"import": "./dist/compiler.js"
|
|
23
27
|
}
|
|
24
28
|
},
|
|
25
29
|
"files": [
|
|
Binary file
|
package/dist/createComputed.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createComputed.d.ts","sourceRoot":"","sources":["../src/createComputed.ts"],"names":[],"mappings":"AAIA,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,EAChE,QAAQ,EAAE,CAAC,GACV;KACA,CAAC,IAAI,MAAM,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACjC,CA0EA"}
|
package/dist/createComputed.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { getCurrentComponent, createCleanup } from "./component";
|
|
2
|
-
import { INSPECT_MARKER, INSPECTOR_ENABLED } from "./inspect";
|
|
3
|
-
import { getCurrentObserver, Observer, Signal } from "./observation";
|
|
4
|
-
export function createComputed(computed) {
|
|
5
|
-
const currentComponent = getCurrentComponent();
|
|
6
|
-
const proxy = {};
|
|
7
|
-
let notifyInspectorRef = {};
|
|
8
|
-
for (const prop in computed) {
|
|
9
|
-
let isDirty = true;
|
|
10
|
-
let value;
|
|
11
|
-
const signal = new Signal();
|
|
12
|
-
const computedObserver = new Observer(() => {
|
|
13
|
-
isDirty = true;
|
|
14
|
-
signal.notify();
|
|
15
|
-
if (INSPECTOR_ENABLED) {
|
|
16
|
-
notifyInspectorRef.current?.notify({
|
|
17
|
-
type: "computed",
|
|
18
|
-
path: notifyInspectorRef.current.path.concat(prop),
|
|
19
|
-
isDirty: true,
|
|
20
|
-
value,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
createCleanup(() => computedObserver.dispose());
|
|
25
|
-
Object.defineProperty(proxy, prop, {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
configurable: true,
|
|
28
|
-
get() {
|
|
29
|
-
const currentObserver = getCurrentObserver();
|
|
30
|
-
if (currentObserver) {
|
|
31
|
-
currentObserver.subscribeSignal(signal);
|
|
32
|
-
}
|
|
33
|
-
if (isDirty) {
|
|
34
|
-
const stopObserving = computedObserver.observe();
|
|
35
|
-
value = computed[prop]();
|
|
36
|
-
stopObserving();
|
|
37
|
-
isDirty = false;
|
|
38
|
-
if (INSPECTOR_ENABLED) {
|
|
39
|
-
notifyInspectorRef.current?.notify({
|
|
40
|
-
type: "computed",
|
|
41
|
-
path: notifyInspectorRef.current.path.concat(prop),
|
|
42
|
-
isDirty: false,
|
|
43
|
-
value,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
return value;
|
|
47
|
-
}
|
|
48
|
-
return value;
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
if (INSPECTOR_ENABLED) {
|
|
53
|
-
Object.defineProperty(proxy, INSPECT_MARKER, {
|
|
54
|
-
enumerable: false,
|
|
55
|
-
configurable: false,
|
|
56
|
-
get() {
|
|
57
|
-
return !notifyInspectorRef.current;
|
|
58
|
-
},
|
|
59
|
-
set: (value) => {
|
|
60
|
-
Object.defineProperty(notifyInspectorRef, "current", {
|
|
61
|
-
get() {
|
|
62
|
-
return value.current;
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
return proxy;
|
|
69
|
-
}
|
package/dist/createEffect.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createEffect.d.ts","sourceRoot":"","sources":["../src/createEffect.ts"],"names":[],"mappings":"AAIA,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,QA2BzD"}
|
package/dist/createEffect.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { syncBatch } from "./batch";
|
|
2
|
-
import { createCleanup, getCurrentComponent } from "./component";
|
|
3
|
-
import { Observer } from "./observation";
|
|
4
|
-
export function createEffect(cb) {
|
|
5
|
-
const component = getCurrentComponent();
|
|
6
|
-
if (!component || component.isRendering) {
|
|
7
|
-
throw new Error("Only use createEffect in component setup");
|
|
8
|
-
}
|
|
9
|
-
let disposer;
|
|
10
|
-
const observer = new Observer(() => {
|
|
11
|
-
syncBatch(runEffect);
|
|
12
|
-
});
|
|
13
|
-
const runEffect = () => {
|
|
14
|
-
try {
|
|
15
|
-
disposer?.();
|
|
16
|
-
}
|
|
17
|
-
catch (error) {
|
|
18
|
-
console.error("Error in effect dispose function:", error);
|
|
19
|
-
}
|
|
20
|
-
const stopObserving = observer.observe();
|
|
21
|
-
disposer = cb();
|
|
22
|
-
stopObserving();
|
|
23
|
-
};
|
|
24
|
-
createCleanup(() => {
|
|
25
|
-
observer.dispose();
|
|
26
|
-
disposer?.();
|
|
27
|
-
});
|
|
28
|
-
runEffect();
|
|
29
|
-
}
|
package/dist/createRouter.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { RoutesConfig, TRouter, TRoutes } from "typed-client-router";
|
|
2
|
-
export type Router<T extends RoutesConfig> = Omit<TRouter<T>, "current" | "listen" | "pathname"> & {
|
|
3
|
-
route?: TRoutes<T>;
|
|
4
|
-
};
|
|
5
|
-
export declare function createRouter<const T extends RoutesConfig>(config: T, options?: {
|
|
6
|
-
base?: string;
|
|
7
|
-
}): Router<T>;
|
|
8
|
-
//# sourceMappingURL=createRouter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createRouter.d.ts","sourceRoot":"","sources":["../src/createRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EACZ,OAAO,EACP,OAAO,EACR,MAAM,qBAAqB,CAAC;AAI7B,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,YAAY,IAAI,IAAI,CAC/C,OAAO,CAAC,CAAC,CAAC,EACV,SAAS,GAAG,QAAQ,GAAG,UAAU,CAClC,GAAG;IACF,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACpB,CAAC;AAEF,wBAAgB,YAAY,CAAC,KAAK,CAAC,CAAC,SAAS,YAAY,EACvD,MAAM,EAAE,CAAC,EACT,OAAO,CAAC,EAAE;IACR,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GACA,MAAM,CAAC,CAAC,CAAC,CA4BX"}
|
package/dist/createRouter.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { createRouter as internalCreateRouter, } from "typed-client-router";
|
|
2
|
-
import { getCurrentObserver, Signal } from "./observation";
|
|
3
|
-
import { createCleanup, getCurrentComponent } from "./component";
|
|
4
|
-
export function createRouter(config, options) {
|
|
5
|
-
if (!getCurrentComponent()) {
|
|
6
|
-
throw new Error("Only use createRouter in component setup");
|
|
7
|
-
}
|
|
8
|
-
const router = internalCreateRouter(config, options);
|
|
9
|
-
const signal = new Signal();
|
|
10
|
-
createCleanup(router.listen(() => signal.notify()));
|
|
11
|
-
return {
|
|
12
|
-
get route() {
|
|
13
|
-
const observer = getCurrentObserver();
|
|
14
|
-
if (observer) {
|
|
15
|
-
observer.subscribeSignal(signal);
|
|
16
|
-
}
|
|
17
|
-
return router.current;
|
|
18
|
-
},
|
|
19
|
-
get queries() {
|
|
20
|
-
return router.queries;
|
|
21
|
-
},
|
|
22
|
-
setQuery: router.setQuery,
|
|
23
|
-
push: router.push,
|
|
24
|
-
replace: router.replace,
|
|
25
|
-
url: router.url,
|
|
26
|
-
};
|
|
27
|
-
}
|
package/dist/createTask.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export type TaskState<P, T> = {
|
|
2
|
-
isRunning: false;
|
|
3
|
-
params: null;
|
|
4
|
-
result: null;
|
|
5
|
-
error: null;
|
|
6
|
-
} | {
|
|
7
|
-
isRunning: true;
|
|
8
|
-
result: T | null;
|
|
9
|
-
params: P;
|
|
10
|
-
error: null;
|
|
11
|
-
} | {
|
|
12
|
-
isRunning: false;
|
|
13
|
-
params: null;
|
|
14
|
-
result: T;
|
|
15
|
-
error: null;
|
|
16
|
-
} | {
|
|
17
|
-
isRunning: false;
|
|
18
|
-
params: null;
|
|
19
|
-
result: null;
|
|
20
|
-
error: string;
|
|
21
|
-
};
|
|
22
|
-
export type Task<A, B = never> = [B] extends [never] ? TaskState<null, A> & {
|
|
23
|
-
run(): Promise<A>;
|
|
24
|
-
rerun(): Promise<A>;
|
|
25
|
-
} : TaskState<A, B> & {
|
|
26
|
-
run(params: A): Promise<B>;
|
|
27
|
-
rerun(params: A): Promise<B>;
|
|
28
|
-
};
|
|
29
|
-
export declare function createTask<T>(task: (params: undefined, signal: AbortSignal) => Promise<T>): Task<T>;
|
|
30
|
-
export declare function createTask<P, T>(task: (params: P, signal: AbortSignal) => Promise<T>): Task<P, T>;
|
|
31
|
-
//# sourceMappingURL=createTask.d.ts.map
|
package/dist/createTask.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createTask.d.ts","sourceRoot":"","sources":["../src/createTask.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,IACtB;IACE,SAAS,EAAE,KAAK,CAAC;IACjB,MAAM,EAAE,IAAI,CAAC;IACb,MAAM,EAAE,IAAI,CAAC;IACb,KAAK,EAAE,IAAI,CAAC;CACb,GACD;IACE,SAAS,EAAE,IAAI,CAAC;IAChB,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC;IACjB,MAAM,EAAE,CAAC,CAAC;IACV,KAAK,EAAE,IAAI,CAAC;CACb,GACD;IACE,SAAS,EAAE,KAAK,CAAC;IACjB,MAAM,EAAE,IAAI,CAAC;IACb,MAAM,EAAE,CAAC,CAAC;IACV,KAAK,EAAE,IAAI,CAAC;CACb,GACD;IACE,SAAS,EAAE,KAAK,CAAC;IACjB,MAAM,EAAE,IAAI,CAAC;IACb,MAAM,EAAE,IAAI,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEN,MAAM,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAChD,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG;IACnB,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;IAClB,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;CACrB,GACD,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;IAChB,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAC9B,CAAC;AAEN,wBAAgB,UAAU,CAAC,CAAC,EAC1B,IAAI,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,GAC3D,IAAI,CAAC,CAAC,CAAC,CAAC;AACX,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAC7B,IAAI,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,GACnD,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
|
package/dist/createTask.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { createCleanup, getCurrentComponent } from "./component";
|
|
2
|
-
import { assignState, createState } from "./createState";
|
|
3
|
-
export function createTask(task) {
|
|
4
|
-
const currentComponent = getCurrentComponent();
|
|
5
|
-
if (!currentComponent || currentComponent.isRendering) {
|
|
6
|
-
throw new Error("Only use createTask in component setup");
|
|
7
|
-
}
|
|
8
|
-
const state = createState({
|
|
9
|
-
isRunning: false,
|
|
10
|
-
result: null,
|
|
11
|
-
error: null,
|
|
12
|
-
params: null,
|
|
13
|
-
});
|
|
14
|
-
let currentAbortController;
|
|
15
|
-
const fetch = (params) => {
|
|
16
|
-
currentAbortController?.abort();
|
|
17
|
-
const abortController = (currentAbortController = new AbortController());
|
|
18
|
-
const promise = task(params, abortController.signal);
|
|
19
|
-
promise
|
|
20
|
-
.then((result) => {
|
|
21
|
-
if (abortController.signal.aborted) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
assignState(state, {
|
|
25
|
-
isRunning: false,
|
|
26
|
-
result,
|
|
27
|
-
error: null,
|
|
28
|
-
params: null,
|
|
29
|
-
});
|
|
30
|
-
})
|
|
31
|
-
.catch((error) => {
|
|
32
|
-
if (abortController.signal.aborted) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
assignState(state, {
|
|
36
|
-
isRunning: false,
|
|
37
|
-
result: null,
|
|
38
|
-
error: String(error),
|
|
39
|
-
params: null,
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
return promise;
|
|
43
|
-
};
|
|
44
|
-
createCleanup(() => currentAbortController?.abort());
|
|
45
|
-
return {
|
|
46
|
-
get isRunning() {
|
|
47
|
-
return state.isRunning;
|
|
48
|
-
},
|
|
49
|
-
get result() {
|
|
50
|
-
return state.result;
|
|
51
|
-
},
|
|
52
|
-
get error() {
|
|
53
|
-
return state.error;
|
|
54
|
-
},
|
|
55
|
-
get params() {
|
|
56
|
-
return state.params;
|
|
57
|
-
},
|
|
58
|
-
run(params) {
|
|
59
|
-
const promise = fetch(params);
|
|
60
|
-
assignState(state, {
|
|
61
|
-
isRunning: true,
|
|
62
|
-
result: null,
|
|
63
|
-
error: null,
|
|
64
|
-
params: (params || null),
|
|
65
|
-
});
|
|
66
|
-
return promise;
|
|
67
|
-
},
|
|
68
|
-
rerun(params) {
|
|
69
|
-
const promise = fetch(params);
|
|
70
|
-
assignState(state, {
|
|
71
|
-
isRunning: true,
|
|
72
|
-
result: state.result,
|
|
73
|
-
error: null,
|
|
74
|
-
params: (params || null),
|
|
75
|
-
});
|
|
76
|
-
return promise;
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
}
|
package/dist/patchInferno.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Temporarily patches document.addEventListener during render to capture
|
|
3
|
-
* and wrap Inferno's delegated event listeners with syncBatch
|
|
4
|
-
*/
|
|
5
|
-
export declare function patchInfernoEventHandling(renderFn: () => void): void;
|
|
6
|
-
//# sourceMappingURL=patchInferno.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"patchInferno.d.ts","sourceRoot":"","sources":["../src/patchInferno.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,IAAI,QA0D7D"}
|
package/dist/patchInferno.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { syncBatch } from "./batch";
|
|
2
|
-
/**
|
|
3
|
-
* Temporarily patches document.addEventListener during render to capture
|
|
4
|
-
* and wrap Inferno's delegated event listeners with syncBatch
|
|
5
|
-
*/
|
|
6
|
-
export function patchInfernoEventHandling(renderFn) {
|
|
7
|
-
const originalAddEventListener = document.addEventListener.bind(document);
|
|
8
|
-
const patchedEvents = new Set();
|
|
9
|
-
// Inferno's delegated events
|
|
10
|
-
const INFERNO_EVENTS = [
|
|
11
|
-
"click",
|
|
12
|
-
"dblclick",
|
|
13
|
-
"focusin",
|
|
14
|
-
"focusout",
|
|
15
|
-
"keydown",
|
|
16
|
-
"keypress",
|
|
17
|
-
"keyup",
|
|
18
|
-
"mousedown",
|
|
19
|
-
"mousemove",
|
|
20
|
-
"mouseup",
|
|
21
|
-
"touchend",
|
|
22
|
-
"touchmove",
|
|
23
|
-
"touchstart",
|
|
24
|
-
"change",
|
|
25
|
-
"input",
|
|
26
|
-
"submit",
|
|
27
|
-
];
|
|
28
|
-
// Temporarily replace addEventListener
|
|
29
|
-
document.addEventListener = function (type, listener, options) {
|
|
30
|
-
// Only wrap Inferno's delegated event listeners
|
|
31
|
-
if (INFERNO_EVENTS.includes(type) &&
|
|
32
|
-
typeof listener === "function" &&
|
|
33
|
-
!patchedEvents.has(type)) {
|
|
34
|
-
patchedEvents.add(type);
|
|
35
|
-
const wrappedListener = function (event) {
|
|
36
|
-
syncBatch(() => {
|
|
37
|
-
listener.call(this, event);
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
return originalAddEventListener(type, wrappedListener, options);
|
|
41
|
-
}
|
|
42
|
-
// @ts-ignore
|
|
43
|
-
return originalAddEventListener(type, listener, options);
|
|
44
|
-
};
|
|
45
|
-
try {
|
|
46
|
-
// Call render - Inferno will synchronously attach its listeners
|
|
47
|
-
renderFn();
|
|
48
|
-
}
|
|
49
|
-
finally {
|
|
50
|
-
// Restore original addEventListener
|
|
51
|
-
document.addEventListener = originalAddEventListener;
|
|
52
|
-
}
|
|
53
|
-
}
|
package/dist/scheduler.d.ts
DELETED
package/dist/scheduler.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":"AAIA,wBAAgB,SAAS,SAExB;AAeD,wBAAgB,uBAAuB,SAWtC;AAmED,wBAAgB,qBAAqB,CAAC,MAAM,GAAE,WAAoB,cAoBjE"}
|
package/dist/scheduler.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
let depth = 0; // batching scope nesting
|
|
2
|
-
let dirty = false; // has any state update been enqueued?
|
|
3
|
-
let scheduled = false; // async flush scheduled?
|
|
4
|
-
export function markDirty() {
|
|
5
|
-
dirty = true;
|
|
6
|
-
}
|
|
7
|
-
function performWork() {
|
|
8
|
-
// TODO: call your Inferno render/commit once.
|
|
9
|
-
// infernoRender(vnode, container);
|
|
10
|
-
}
|
|
11
|
-
function flushNow() {
|
|
12
|
-
scheduled = false;
|
|
13
|
-
if (!dirty)
|
|
14
|
-
return;
|
|
15
|
-
dirty = false;
|
|
16
|
-
performWork();
|
|
17
|
-
}
|
|
18
|
-
// Called by setters after enqueueing their state change
|
|
19
|
-
export function enqueueUpdateFromSetter() {
|
|
20
|
-
dirty = true;
|
|
21
|
-
if (depth > 0) {
|
|
22
|
-
// We're inside a batched input event; we'll flush on exit (same frame).
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
if (!scheduled) {
|
|
26
|
-
scheduled = true;
|
|
27
|
-
queueMicrotask(flushNow); // one flush per task
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
// Batch-scope control used by the global capture listeners
|
|
31
|
-
function enter() {
|
|
32
|
-
depth++;
|
|
33
|
-
}
|
|
34
|
-
function exit() {
|
|
35
|
-
if (--depth === 0) {
|
|
36
|
-
// End of the event propagation; commit now (before next paint).
|
|
37
|
-
flushNow();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
// eventBatching.ts
|
|
41
|
-
const INTERACTIVE_EVENTS = [
|
|
42
|
-
// Pointer + mouse
|
|
43
|
-
"click",
|
|
44
|
-
"dblclick",
|
|
45
|
-
"contextmenu",
|
|
46
|
-
"mousedown",
|
|
47
|
-
"mouseup",
|
|
48
|
-
"mousemove",
|
|
49
|
-
"pointerdown",
|
|
50
|
-
"pointerup",
|
|
51
|
-
"pointermove",
|
|
52
|
-
"touchstart",
|
|
53
|
-
"touchmove",
|
|
54
|
-
"touchend",
|
|
55
|
-
"touchcancel",
|
|
56
|
-
"dragstart",
|
|
57
|
-
"drag",
|
|
58
|
-
"dragend",
|
|
59
|
-
"dragenter",
|
|
60
|
-
"dragleave",
|
|
61
|
-
"dragover",
|
|
62
|
-
"drop",
|
|
63
|
-
"wheel",
|
|
64
|
-
// Keyboard
|
|
65
|
-
"keydown",
|
|
66
|
-
"keypress",
|
|
67
|
-
"keyup",
|
|
68
|
-
// Focus & input
|
|
69
|
-
"focus",
|
|
70
|
-
"blur",
|
|
71
|
-
"focusin",
|
|
72
|
-
"focusout",
|
|
73
|
-
"input",
|
|
74
|
-
"beforeinput",
|
|
75
|
-
"change",
|
|
76
|
-
"compositionstart",
|
|
77
|
-
"compositionupdate",
|
|
78
|
-
"compositionend",
|
|
79
|
-
// Forms
|
|
80
|
-
"submit",
|
|
81
|
-
"reset",
|
|
82
|
-
// Selection / clipboard
|
|
83
|
-
"select",
|
|
84
|
-
"selectionchange",
|
|
85
|
-
"copy",
|
|
86
|
-
"cut",
|
|
87
|
-
"paste",
|
|
88
|
-
];
|
|
89
|
-
export function installGlobalBatching(target = window) {
|
|
90
|
-
const handlers = [];
|
|
91
|
-
INTERACTIVE_EVENTS.forEach((type) => {
|
|
92
|
-
const onCapture = () => {
|
|
93
|
-
enter();
|
|
94
|
-
// Close the scope after all handlers (capture→target→bubble) have run.
|
|
95
|
-
queueMicrotask(exit);
|
|
96
|
-
};
|
|
97
|
-
target.addEventListener(type, onCapture, { capture: true });
|
|
98
|
-
handlers.push([onCapture, { capture: true }]);
|
|
99
|
-
});
|
|
100
|
-
// Return a disposer so you can remove on unmount
|
|
101
|
-
return () => {
|
|
102
|
-
INTERACTIVE_EVENTS.forEach((type, i) => {
|
|
103
|
-
const [fn, opts] = handlers[i];
|
|
104
|
-
target.removeEventListener(type, fn, opts);
|
|
105
|
-
});
|
|
106
|
-
};
|
|
107
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"batch.test.d.ts","sourceRoot":"","sources":["../../src/tests/batch.test.ts"],"names":[],"mappings":""}
|