rask-ui 0.20.5 → 0.22.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.
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,EACL,SAAS,EACT,KAAK,EACL,WAAW,EACZ,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAsB,QAAQ,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAIrE,MAAM,MAAM,8BAA8B,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,IAC3D,CAAC,MAAM,KAAK,CAAC,GACb,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,KAAK,CAAC,CAAC;AAE1B,qBAAa,sBAAuB,SAAQ,SAAS;IAC3C,QAAQ,EAAE,8BAA8B,CAAC,GAAG,CAAC,CAAC;IACtD,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,aAAa,CAAS;IAC9B,QAAQ,WAML;IACH,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM;IAC1C,OAAO,CAAC,aAAa,CAAc;IAEnC,qBAAqB,IAAI,OAAO;IAMhC,kBAAkB,IAAI,IAAI;IAG1B,yBAAyB,CAAC,SAAS,EAAE,GAAG,GAAG,IAAI;IAe/C,MAAM;CAoBP;AAID,wBAAgB,mBAAmB,2CAElC;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,IAAI,QAM5C;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,IAAI,QAMxC;AAED,MAAM,MAAM,6BAA6B,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,IAC1D,CAAC,MAAM,MAAM,KAAK,CAAC,GACnB,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,KAAK,CAAC,CAAC;AAEhC,qBAAa,qBAAqB,CAAC,CAAC,SAAS,K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AAI,CAAA;KAAE,CAAC,CAAM;IAC3D,QAAQ,gBAAa;IACrB,eAAe;IAcf,QAAQ,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAM;IACjC,UAAU,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAM;IAEnC,iBAAiB,IAAI,IAAI;IAGzB,oBAAoB,IAAI,IAAI;IAI5B,yBAAyB,CACvB,SAAS,EAAE,QAAQ,CAAC;QAAE,QAAQ,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,CAAC,CAAC,GAClD,IAAI;IAcP,qBAAqB,IAAI,OAAO;IAMhC,MAAM;CA6CP;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,SAO9D"}
package/dist/component.js CHANGED
@@ -112,7 +112,10 @@ export class RaskStatefulComponent extends Component {
112
112
  effects = [];
113
113
  contexts = new Map();
114
114
  getChildContext() {
115
- const parentGetContext = this.context.getContext;
115
+ const parentGetContext = this.context.getContext ||
116
+ (() => {
117
+ throw new Error("No context available");
118
+ });
116
119
  return {
117
120
  ...this.context,
118
121
  getContext: (context) => {
@@ -1,33 +1,32 @@
1
1
  /**
2
- * Creates a context object for providing and consuming values across component trees.
2
+ * Creates a context by wrapping a hook function that will be used as a context identifier.
3
3
  *
4
- * @warning **Do not destructure context values returned by context.get()!** The returned
5
- * value may be a reactive object, and destructuring breaks reactivity.
4
+ * @warning **Do not destructure context values!** The returned value may be a reactive
5
+ * object, and destructuring breaks reactivity.
6
6
  *
7
7
  * @example
8
- * // Bad - destructuring context value
9
- * const ThemeContext = createContext<{ color: string }>();
8
+ * // Create a context hook
9
+ * const useTheme = createContext(() => {
10
+ * return useState({ color: "blue" });
11
+ * });
10
12
  *
11
- * function Consumer() {
12
- * const theme = ThemeContext.get();
13
- * const { color } = theme; // Don't do this!
14
- * return () => <div style={{ color }}>Text</div>; // Won't update!
13
+ * // Provider component
14
+ * function App() {
15
+ * const theme = useInjectContext(useTheme);
16
+ * // theme is now available to all children
17
+ * return () => <Child />;
15
18
  * }
16
19
  *
17
- * // Good - access properties directly
18
- * function Consumer() {
19
- * const theme = ThemeContext.get();
20
+ * // Consumer component
21
+ * function Child() {
22
+ * const theme = useContext(useTheme);
20
23
  * return () => <div style={{ color: theme.color }}>Text</div>;
21
24
  * }
22
25
  *
23
- * @returns Context object with inject() and get() methods
26
+ * @param hook - A function that will be used as the context identifier
27
+ * @returns The same hook function, to be used with useContext() and useInjectContext()
24
28
  */
25
- declare const Type: unique symbol;
26
- export type Context<T> = symbol & {
27
- readonly [Type]: T;
28
- };
29
- export declare function createContext<T>(): Context<T>;
30
- export declare function useContext<T>(context: Context<T>): T;
31
- export declare function useInjectContext<T>(context: Context<T>): (value: T) => void;
32
- export {};
29
+ export declare function createContext<T, P extends any[]>(hook: (...params: P) => T): (...params: P) => T;
30
+ export declare function useContext<T, P extends any[]>(hook: (...params: P) => T): T;
31
+ export declare function useInjectContext<T, P extends any[]>(hook: (...params: P) => T, ...params: P): T;
33
32
  //# sourceMappingURL=createContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createContext.d.ts","sourceRoot":"","sources":["../src/createContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,OAAO,CAAC,MAAM,IAAI,EAAE,OAAO,MAAM,CAAC;AAElC,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,MAAM,GAAG;IAChC,QAAQ,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;CACpB,CAAC;AAEF,wBAAgB,aAAa,CAAC,CAAC,KACV,OAAO,CAAC,CAAC,CAAC,CAC9B;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAkBpD;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,IAC7C,OAAO,CAAC,UASjB"}
1
+ {"version":3,"file":"createContext.d.ts","sourceRoot":"","sources":["../src/createContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAIH,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,SAAS,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,eAAP,CAAC,KAAK,CAAC,CAE1E;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,SAAS,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAkB3E;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,CAAC,SAAS,GAAG,EAAE,EACjD,IAAI,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,EACzB,GAAG,MAAM,EAAE,CAAC,KAab"}
@@ -1,32 +1,36 @@
1
1
  /**
2
- * Creates a context object for providing and consuming values across component trees.
2
+ * Creates a context by wrapping a hook function that will be used as a context identifier.
3
3
  *
4
- * @warning **Do not destructure context values returned by context.get()!** The returned
5
- * value may be a reactive object, and destructuring breaks reactivity.
4
+ * @warning **Do not destructure context values!** The returned value may be a reactive
5
+ * object, and destructuring breaks reactivity.
6
6
  *
7
7
  * @example
8
- * // Bad - destructuring context value
9
- * const ThemeContext = createContext<{ color: string }>();
8
+ * // Create a context hook
9
+ * const useTheme = createContext(() => {
10
+ * return useState({ color: "blue" });
11
+ * });
10
12
  *
11
- * function Consumer() {
12
- * const theme = ThemeContext.get();
13
- * const { color } = theme; // Don't do this!
14
- * return () => <div style={{ color }}>Text</div>; // Won't update!
13
+ * // Provider component
14
+ * function App() {
15
+ * const theme = useInjectContext(useTheme);
16
+ * // theme is now available to all children
17
+ * return () => <Child />;
15
18
  * }
16
19
  *
17
- * // Good - access properties directly
18
- * function Consumer() {
19
- * const theme = ThemeContext.get();
20
+ * // Consumer component
21
+ * function Child() {
22
+ * const theme = useContext(useTheme);
20
23
  * return () => <div style={{ color: theme.color }}>Text</div>;
21
24
  * }
22
25
  *
23
- * @returns Context object with inject() and get() methods
26
+ * @param hook - A function that will be used as the context identifier
27
+ * @returns The same hook function, to be used with useContext() and useInjectContext()
24
28
  */
25
29
  import { getCurrentComponent } from "./component";
26
- export function createContext() {
27
- return Symbol();
30
+ export function createContext(hook) {
31
+ return hook;
28
32
  }
29
- export function useContext(context) {
33
+ export function useContext(hook) {
30
34
  let currentComponent = getCurrentComponent();
31
35
  if (!currentComponent) {
32
36
  throw new Error("Only use useContext in component setup");
@@ -34,18 +38,18 @@ export function useContext(context) {
34
38
  if (typeof currentComponent.context.getContext !== "function") {
35
39
  throw new Error("There is no parent context");
36
40
  }
37
- const contextValue = currentComponent.context.getContext(context);
41
+ const contextValue = currentComponent.context.getContext(hook);
38
42
  if (!contextValue) {
39
43
  throw new Error("There is a parent context, but not the one you are using");
40
44
  }
41
45
  return contextValue;
42
46
  }
43
- export function useInjectContext(context) {
44
- return (value) => {
45
- const currentComponent = getCurrentComponent();
46
- if (!currentComponent) {
47
- throw new Error("Only use useInjectContext in component setup");
48
- }
49
- currentComponent.contexts.set(context, value);
50
- };
47
+ export function useInjectContext(hook, ...params) {
48
+ const currentComponent = getCurrentComponent();
49
+ if (!currentComponent) {
50
+ throw new Error("Only use useInjectContext in component setup");
51
+ }
52
+ const value = hook(...params);
53
+ currentComponent.contexts.set(hook, value);
54
+ return value;
51
55
  }
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
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";
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, Inferno } from "inferno";
2
2
  declare global {
3
3
  namespace Rask {
4
4
  type MouseEvent<T = Element> = InfernoMouseEvent<T>;
@@ -14,6 +14,7 @@ declare global {
14
14
  type FocusEvent<T = Element> = InfernoFocusEvent<T>;
15
15
  type FormEvent<T = Element> = InfernoFormEvent<T>;
16
16
  type CompositionEvent<T = Element> = InfernoCompositionEvent<T>;
17
+ type ElementProps<T extends keyof JSX.IntrinsicElements> = Omit<JSX.IntrinsicElements[T], keyof Inferno.Attributes>;
17
18
  }
18
19
  }
19
20
  export {};
@@ -1 +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,CA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AAC,CAAC,EACxB,MAAM,OAAO,CAAC,UAAU,CACzB,CAAC;KACH;CACF;AAGD,OAAO,EAAE,CAAC"}
@@ -1,4 +1,6 @@
1
- export declare const CatchErrorContext: import("./createContext").Context<(error: unknown) => void>;
1
+ export declare const CatchErrorContext: (state: {
2
+ error: unknown;
3
+ }) => (error: unknown) => unknown;
2
4
  export declare function useCatchError(): {
3
5
  error: unknown;
4
6
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useCatchError.d.ts","sourceRoot":"","sources":["../src/useCatchError.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB,4CAAyB,OAAO,KAAK,IAAI,CAAG,CAAC;AAE3E,wBAAgB,aAAa;WAQK,OAAO;EAOxC"}
1
+ {"version":3,"file":"useCatchError.d.ts","sourceRoot":"","sources":["../src/useCatchError.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB;WAAkC,OAAO;cACtD,OAAO,YACtB,CAAC;AAEH,wBAAgB,aAAa;WAMK,OAAO;EAOxC"}
@@ -1,16 +1,17 @@
1
1
  import { useState } from "./useState";
2
2
  import { createContext, useInjectContext } from "./createContext";
3
3
  import { getCurrentComponent } from "./component";
4
- export const CatchErrorContext = createContext();
4
+ export const CatchErrorContext = createContext((state) => {
5
+ return (error) => (state.error = error);
6
+ });
5
7
  export function useCatchError() {
6
8
  const currentComponent = getCurrentComponent();
7
9
  if (!currentComponent || currentComponent.isRendering) {
8
10
  throw new Error("Only use the useCatchError hook in setup");
9
11
  }
10
- const inject = useInjectContext(CatchErrorContext);
11
12
  const state = useState({
12
13
  error: null,
13
14
  });
14
- inject((error) => (state.error = error));
15
+ useInjectContext(CatchErrorContext, state);
15
16
  return state;
16
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rask-ui",
3
- "version": "0.20.5",
3
+ "version": "0.22.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -33,7 +33,7 @@
33
33
  "README.md"
34
34
  ],
35
35
  "scripts": {
36
- "build": "npm run build:plugin && tsc --project tsconfig.build.json && cp ../../README.md . && cp ../../logo.png .",
36
+ "build": "npm run build:plugin && tsc --project tsconfig.build.json && cpx ../../README.md . && cpx ../../logo.png .",
37
37
  "build:plugin": "cd swc-plugin && cargo build --release --target wasm32-wasip1",
38
38
  "dev": "tsc --watch",
39
39
  "test": "vitest",