@slux/inferno 0.0.0-stage → 0.1.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/LICENSE +21 -0
  3. package/README.md +280 -2
  4. package/dist/atom.cjs +2 -0
  5. package/dist/atom.cjs.map +1 -0
  6. package/dist/atom.d.cts +33 -0
  7. package/dist/atom.d.ts +33 -0
  8. package/dist/atom.js +2 -0
  9. package/dist/atom.js.map +1 -0
  10. package/dist/flux.cjs +2 -0
  11. package/dist/flux.cjs.map +1 -0
  12. package/dist/flux.d.cts +45 -0
  13. package/dist/flux.d.ts +45 -0
  14. package/dist/flux.js +2 -0
  15. package/dist/flux.js.map +1 -0
  16. package/dist/index.cjs +2 -0
  17. package/dist/index.cjs.map +1 -0
  18. package/dist/index.d.cts +53 -0
  19. package/dist/index.d.ts +53 -0
  20. package/dist/index.js +2 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/proxy.cjs +2 -0
  23. package/dist/proxy.cjs.map +1 -0
  24. package/dist/proxy.d.cts +30 -0
  25. package/dist/proxy.d.ts +30 -0
  26. package/dist/proxy.js +2 -0
  27. package/dist/proxy.js.map +1 -0
  28. package/dist/rxjs.cjs +2 -0
  29. package/dist/rxjs.cjs.map +1 -0
  30. package/dist/rxjs.d.cts +41 -0
  31. package/dist/rxjs.d.ts +41 -0
  32. package/dist/rxjs.js +2 -0
  33. package/dist/rxjs.js.map +1 -0
  34. package/dist/state-machine.cjs +2 -0
  35. package/dist/state-machine.cjs.map +1 -0
  36. package/dist/state-machine.d.cts +46 -0
  37. package/dist/state-machine.d.ts +46 -0
  38. package/dist/state-machine.js +2 -0
  39. package/dist/state-machine.js.map +1 -0
  40. package/dist/store.cjs +2 -0
  41. package/dist/store.cjs.map +1 -0
  42. package/dist/store.d.cts +36 -0
  43. package/dist/store.d.ts +36 -0
  44. package/dist/store.js +2 -0
  45. package/dist/store.js.map +1 -0
  46. package/dist/z~0.js +2 -0
  47. package/dist/z~0.js.map +1 -0
  48. package/package.json +161 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/auto-import-api.ts","webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../src/observer.ts","../src/index.ts"],"sourcesContent":["import { generateBatchAutoImports } from \"@slux/shared\";\n\nconst allImportApis: string[] = [\"ScopeProvider\", \"SignalValue\", \"getScope\"];\n\nexport const createAutoImportApis = (prefix: string = \"\") => {\n return generateBatchAutoImports([\n {\n prefix,\n fromName: \"@slux/inferno\",\n imports: allImportApis,\n },\n ]);\n};\n","__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { Component } from \"inferno\";\nimport type { InfernoNode } from \"inferno\";\n\nexport abstract class Observer<Props, Value> extends Component<Props> {\n #unsubscribe: (() => void) | undefined;\n #value!: Value;\n protected abstract read(): Value;\n protected abstract subscribe(notify: () => void): () => void;\n protected abstract source(props: Props): unknown;\n protected abstract view(value: Value): InfernoNode;\n protected equal(previous: Value, next: Value): boolean {\n return Object.is(previous, next);\n }\n #check = () => {\n const next = this.read();\n if (!this.equal(this.#value, next)) {\n this.#value = next;\n this.forceUpdate();\n }\n };\n #connect() {\n this.#unsubscribe = this.subscribe(this.#check);\n this.#check();\n }\n override componentDidMount() {\n this.#connect();\n }\n override componentDidUpdate(previous: Props) {\n if (this.source(previous) !== this.source(this.props)) {\n this.#unsubscribe?.();\n this.#connect();\n }\n }\n override componentWillUnmount() {\n this.#unsubscribe?.();\n }\n override render(): InfernoNode {\n this.#value = this.read();\n return this.view(this.#value);\n }\n}\n","import { Component } from \"inferno\";\nimport type { InfernoNode } from \"inferno\";\nimport { effect } from \"@slux/core\";\nimport type { Scope, Subscribable } from \"@slux/core\";\nimport { Observer } from \"./observer.js\";\n\nexport type ScopeContext = { sluxScope?: Scope };\nexport type ScopeProviderProps = { scope: Scope; children?: InfernoNode };\nexport class ScopeProvider extends Component<ScopeProviderProps> {\n override getChildContext(): ScopeContext {\n return { sluxScope: this.props.scope };\n }\n override render(): InfernoNode {\n return this.props.children;\n }\n}\nexport function getScope(context: ScopeContext): Scope | undefined {\n return context.sluxScope;\n}\nexport type SignalValueProps<T> = {\n source: Subscribable<T>;\n children: (value: T) => InfernoNode;\n};\nexport class SignalValue<T, Props extends SignalValueProps<T> = SignalValueProps<T>> extends Observer<Props, T> {\n #mounted = false;\n override componentDidMount() {\n this.#mounted = true;\n super.componentDidMount();\n }\n protected override source(props: Props) {\n return props.source;\n }\n protected override read(): T {\n const scope = getScope(this.context as ScopeContext);\n return !this.#mounted && scope ? scope.get(this.props.source) : this.props.source.get();\n }\n protected override view(value: T): InfernoNode {\n return (this.props.children as (value: T) => InfernoNode)(value);\n }\n protected override subscribe(notify: () => void): () => void {\n const source = this.props.source;\n const unsubscribe = source.subscribe(notify);\n const dispose = effect(() => {\n source.get();\n });\n return () => {\n unsubscribe();\n dispose();\n };\n }\n}\nexport { createAutoImportApis } from \"./auto-import-api.js\";\n"],"names":["allImportApis","createAutoImportApis","prefix","generateBatchAutoImports","__webpack_require__","e","Object","Symbol","Observer","Component","previous","next","ScopeProvider","getScope","context","SignalValue","props","scope","value","notify","source","unsubscribe","dispose","effect"],"mappings":"+SAEMA,EAA0B,CAA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UC,AAAAA,GAAAA,EAAAA,MAAAA,AAAAA,EAAO,KACrBH,EAAO,GAAG,EACZ,GACA,MAAO,KACLC,IACAC,GACF,CACF,CACF,C"}
@@ -0,0 +1,53 @@
1
+ import { Component } from 'inferno';
2
+ import type { InfernoNode } from 'inferno';
3
+ import type { Scope } from '@slux/core';
4
+ import type { Subscribable } from '@slux/core';
5
+
6
+ export declare const createAutoImportApis: (prefix?: string) => {
7
+ [x: string]: (string | [string, string])[];
8
+ };
9
+
10
+ export declare function getScope(context: ScopeContext): Scope | undefined;
11
+
12
+ declare abstract class Observer<Props, Value> extends Component<Props> {
13
+ #private;
14
+ protected abstract read(): Value;
15
+ protected abstract subscribe(notify: () => void): () => void;
16
+ protected abstract source(props: Props): unknown;
17
+ protected abstract view(value: Value): InfernoNode;
18
+ protected equal(previous: Value, next: Value): boolean;
19
+ componentDidMount(): void;
20
+ componentDidUpdate(previous: Props): void;
21
+ componentWillUnmount(): void;
22
+ render(): InfernoNode;
23
+ }
24
+
25
+ export declare type ScopeContext = {
26
+ sluxScope?: Scope;
27
+ };
28
+
29
+ export declare class ScopeProvider extends Component<ScopeProviderProps> {
30
+ getChildContext(): ScopeContext;
31
+ render(): InfernoNode;
32
+ }
33
+
34
+ export declare type ScopeProviderProps = {
35
+ scope: Scope;
36
+ children?: InfernoNode;
37
+ };
38
+
39
+ export declare class SignalValue<T, Props extends SignalValueProps<T> = SignalValueProps<T>> extends Observer<Props, T> {
40
+ #private;
41
+ componentDidMount(): void;
42
+ protected source(props: Props): Subscribable<T>;
43
+ protected read(): T;
44
+ protected view(value: T): InfernoNode;
45
+ protected subscribe(notify: () => void): () => void;
46
+ }
47
+
48
+ export declare type SignalValueProps<T> = {
49
+ source: Subscribable<T>;
50
+ children: (value: T) => InfernoNode;
51
+ };
52
+
53
+ export { }
@@ -0,0 +1,53 @@
1
+ import { Component } from 'inferno';
2
+ import type { InfernoNode } from 'inferno';
3
+ import type { Scope } from '@slux/core';
4
+ import type { Subscribable } from '@slux/core';
5
+
6
+ export declare const createAutoImportApis: (prefix?: string) => {
7
+ [x: string]: (string | [string, string])[];
8
+ };
9
+
10
+ export declare function getScope(context: ScopeContext): Scope | undefined;
11
+
12
+ declare abstract class Observer<Props, Value> extends Component<Props> {
13
+ #private;
14
+ protected abstract read(): Value;
15
+ protected abstract subscribe(notify: () => void): () => void;
16
+ protected abstract source(props: Props): unknown;
17
+ protected abstract view(value: Value): InfernoNode;
18
+ protected equal(previous: Value, next: Value): boolean;
19
+ componentDidMount(): void;
20
+ componentDidUpdate(previous: Props): void;
21
+ componentWillUnmount(): void;
22
+ render(): InfernoNode;
23
+ }
24
+
25
+ export declare type ScopeContext = {
26
+ sluxScope?: Scope;
27
+ };
28
+
29
+ export declare class ScopeProvider extends Component<ScopeProviderProps> {
30
+ getChildContext(): ScopeContext;
31
+ render(): InfernoNode;
32
+ }
33
+
34
+ export declare type ScopeProviderProps = {
35
+ scope: Scope;
36
+ children?: InfernoNode;
37
+ };
38
+
39
+ export declare class SignalValue<T, Props extends SignalValueProps<T> = SignalValueProps<T>> extends Observer<Props, T> {
40
+ #private;
41
+ componentDidMount(): void;
42
+ protected source(props: Props): Subscribable<T>;
43
+ protected read(): T;
44
+ protected view(value: T): InfernoNode;
45
+ protected subscribe(notify: () => void): () => void;
46
+ }
47
+
48
+ export declare type SignalValueProps<T> = {
49
+ source: Subscribable<T>;
50
+ children: (value: T) => InfernoNode;
51
+ };
52
+
53
+ export { }
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import{Component as e}from"inferno";import{effect as r}from"@slux/core";import{generateBatchAutoImports as o}from"@slux/shared";import{Observer as t}from"./z~0.js";let s=["ScopeProvider","SignalValue","getScope"],n=(e="")=>o([{prefix:e,fromName:"@slux/inferno",imports:s}]);class i extends e{getChildContext(){return{sluxScope:this.props.scope}}render(){return this.props.children}}function p(e){return e.sluxScope}class u extends t{#e=!1;componentDidMount(){this.#e=!0,super.componentDidMount()}source(e){return e.source}read(){let e=p(this.context);return!this.#e&&e?e.get(this.props.source):this.props.source.get()}view(e){return this.props.children(e)}subscribe(e){let o=this.props.source,t=o.subscribe(e),s=r(()=>{o.get()});return()=>{t(),s()}}}export{i as ScopeProvider,u as SignalValue,n as createAutoImportApis,p as getScope};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/auto-import-api.ts","../src/index.ts"],"sourcesContent":["import { generateBatchAutoImports } from \"@slux/shared\";\n\nconst allImportApis: string[] = [\"ScopeProvider\", \"SignalValue\", \"getScope\"];\n\nexport const createAutoImportApis = (prefix: string = \"\") => {\n return generateBatchAutoImports([\n {\n prefix,\n fromName: \"@slux/inferno\",\n imports: allImportApis,\n },\n ]);\n};\n","import { Component } from \"inferno\";\nimport type { InfernoNode } from \"inferno\";\nimport { effect } from \"@slux/core\";\nimport type { Scope, Subscribable } from \"@slux/core\";\nimport { Observer } from \"./observer.js\";\n\nexport type ScopeContext = { sluxScope?: Scope };\nexport type ScopeProviderProps = { scope: Scope; children?: InfernoNode };\nexport class ScopeProvider extends Component<ScopeProviderProps> {\n override getChildContext(): ScopeContext {\n return { sluxScope: this.props.scope };\n }\n override render(): InfernoNode {\n return this.props.children;\n }\n}\nexport function getScope(context: ScopeContext): Scope | undefined {\n return context.sluxScope;\n}\nexport type SignalValueProps<T> = {\n source: Subscribable<T>;\n children: (value: T) => InfernoNode;\n};\nexport class SignalValue<T, Props extends SignalValueProps<T> = SignalValueProps<T>> extends Observer<Props, T> {\n #mounted = false;\n override componentDidMount() {\n this.#mounted = true;\n super.componentDidMount();\n }\n protected override source(props: Props) {\n return props.source;\n }\n protected override read(): T {\n const scope = getScope(this.context as ScopeContext);\n return !this.#mounted && scope ? scope.get(this.props.source) : this.props.source.get();\n }\n protected override view(value: T): InfernoNode {\n return (this.props.children as (value: T) => InfernoNode)(value);\n }\n protected override subscribe(notify: () => void): () => void {\n const source = this.props.source;\n const unsubscribe = source.subscribe(notify);\n const dispose = effect(() => {\n source.get();\n });\n return () => {\n unsubscribe();\n dispose();\n };\n }\n}\nexport { createAutoImportApis } from \"./auto-import-api.js\";\n"],"names":["allImportApis","createAutoImportApis","prefix","generateBatchAutoImports","ScopeProvider","Component","getScope","context","SignalValue","Observer","props","scope","value","notify","source","unsubscribe","dispose","effect"],"mappings":"gLAEA,IAAMA,EAA0B,CAAC,gBAAiB,cAAe,WAAW,CAE/DC,EAAuB,CAACC,EAAiB,EAAE,GAC/CC,EAAyB,CAC9B,CACED,OAAAA,EACA,SAAU,gBACV,QAASF,CACX,EACD,CCHI,OAAMI,UAAsBC,EACxB,iBAAgC,CACvC,MAAO,CAAE,UAAW,IAAI,CAAC,KAAK,CAAC,KAAK,AAAC,CACvC,CACS,QAAsB,CAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,AAC5B,CACF,CACO,SAASC,EAASC,CAAqB,EAC5C,OAAOA,EAAQ,SAAS,AAC1B,CAKO,MAAMC,UAAgFC,EAC3F,EAAQ,CAAG,EAAM,AACR,oBAAoB,CAC3B,IAAI,CAAC,EAAQ,CAAG,GAChB,KAAK,CAAC,mBACR,CACmB,OAAOC,CAAY,CAAE,CACtC,OAAOA,EAAM,MAAM,AACrB,CACmB,MAAU,CAC3B,IAAMC,EAAQL,EAAS,IAAI,CAAC,OAAO,EACnC,MAAO,CAAC,IAAI,CAAC,EAAQ,EAAIK,EAAQA,EAAM,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,EACvF,CACmB,KAAKC,CAAQ,CAAe,CAC7C,OAAQ,IAAI,CAAC,KAAK,CAAC,QAAQ,CAA+BA,EAC5D,CACmB,UAAUC,CAAkB,CAAc,CAC3D,IAAMC,EAAS,IAAI,CAAC,KAAK,CAAC,MAAM,CAC1BC,EAAcD,EAAO,SAAS,CAACD,GAC/BG,EAAUC,EAAO,KACrBH,EAAO,GAAG,EACZ,GACA,MAAO,KACLC,IACAC,GACF,CACF,CACF,Q"}
package/dist/proxy.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,r,_)=>{var t=(r,_)=>{for(var t in r)__webpack_require__.o(r,t)&&!__webpack_require__.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,[_]:r[t]})};t(r,"get"),t(_,"value")},__webpack_require__.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),__webpack_require__.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{ProxyValue:()=>ProxyValue});const proxy_namespaceObject=require("@slux/proxy"),external_inferno_namespaceObject=require("inferno");class Observer extends external_inferno_namespaceObject.Component{#e;#r;equal(e,r){return Object.is(e,r)}#_=()=>{let e=this.read();this.equal(this.#r,e)||(this.#r=e,this.forceUpdate())};#t(){this.#e=this.subscribe(this.#_),this.#_()}componentDidMount(){this.#t()}componentDidUpdate(e){this.source(e)!==this.source(this.props)&&(this.#e?.(),this.#t())}componentWillUnmount(){this.#e?.()}render(){return this.#r=this.read(),this.view(this.#r)}}class ProxyValue extends Observer{source(e){return e.proxy}read(){return(0,proxy_namespaceObject.snapshot)(this.props.proxy)}view(e){return this.props.children(e)}subscribe(e){return(0,proxy_namespaceObject.subscribe)(this.props.proxy,e)}}for(var __rspack_i in exports.ProxyValue=__webpack_exports__.ProxyValue,__webpack_exports__)-1===["ProxyValue"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
2
+ //# sourceMappingURL=proxy.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../src/observer.ts","../src/proxy.ts"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { Component } from \"inferno\";\nimport type { InfernoNode } from \"inferno\";\n\nexport abstract class Observer<Props, Value> extends Component<Props> {\n #unsubscribe: (() => void) | undefined;\n #value!: Value;\n protected abstract read(): Value;\n protected abstract subscribe(notify: () => void): () => void;\n protected abstract source(props: Props): unknown;\n protected abstract view(value: Value): InfernoNode;\n protected equal(previous: Value, next: Value): boolean {\n return Object.is(previous, next);\n }\n #check = () => {\n const next = this.read();\n if (!this.equal(this.#value, next)) {\n this.#value = next;\n this.forceUpdate();\n }\n };\n #connect() {\n this.#unsubscribe = this.subscribe(this.#check);\n this.#check();\n }\n override componentDidMount() {\n this.#connect();\n }\n override componentDidUpdate(previous: Props) {\n if (this.source(previous) !== this.source(this.props)) {\n this.#unsubscribe?.();\n this.#connect();\n }\n }\n override componentWillUnmount() {\n this.#unsubscribe?.();\n }\n override render(): InfernoNode {\n this.#value = this.read();\n return this.view(this.#value);\n }\n}\n","import type { InfernoNode } from \"inferno\";\nimport { snapshot, subscribe } from \"@slux/proxy\";\nimport type { Snapshot } from \"@slux/proxy\";\nimport { Observer } from \"./observer.js\";\n\nexport type ProxyValueProps<T extends object> = {\n proxy: T;\n children: (value: Snapshot<T>) => InfernoNode;\n};\nexport class ProxyValue<T extends object> extends Observer<ProxyValueProps<T>, Snapshot<T>> {\n protected override source(props: ProxyValueProps<T>) {\n return props.proxy;\n }\n protected override read(): Snapshot<T> {\n return snapshot(this.props.proxy);\n }\n protected override view(value: Snapshot<T>): InfernoNode {\n return this.props.children(value);\n }\n protected override subscribe(notify: () => void): () => void {\n return subscribe(this.props.proxy, notify);\n }\n}\n"],"names":["__webpack_require__","e","Object","Symbol","Observer","Component","previous","next","ProxyValue","props","snapshot","value","notify","subscribe"],"mappings":"wPAAAA,CAAAA,oBAAoB,CAAC,CAAG,CAACC,EAAS,EAAS,KAC1C,IAAI,EAAS,CAAC,EAAM,KACnB,IAAI,IAAI,KAAO,EACXD,oBAAoB,CAAC,CAAC,EAAM,IAAQ,CAACA,oBAAoB,CAAC,CAACC,EAAS,IACtEC,OAAO,cAAc,CAACD,EAAS,EAAK,CAAE,WAAY,GAAM,CAAC,EAAK,CAAE,CAAI,CAAC,EAAI,AAAC,EAG7E,EACA,EAAO,EAAS,OAChB,EAAO,EAAQ,QAChB,ECVAD,oBAAoB,CAAC,CAAG,CAAC,EAAK,IAAUE,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,EAAK,GCClFF,oBAAoB,CAAC,CAAG,AAACC,IACrB,AAAkB,IAAlB,OAAOE,QAA0BA,OAAO,WAAW,EACrDD,OAAO,cAAc,CAACD,EAASE,OAAO,WAAW,CAAE,CAAE,MAAO,QAAS,GAEtED,OAAO,cAAc,CAACD,EAAS,aAAc,CAAE,MAAO,EAAK,EAC5D,E,mPCHO,OAAeG,iBAA+BC,iCAAAA,SAASA,CAC5D,EAAY,AAA2B,AACvC,GAAM,AAAS,AAKL,OAAMC,CAAe,CAAEC,CAAW,CAAW,CACrD,OAAOL,OAAO,EAAE,CAACI,EAAUC,EAC7B,CACA,EAAM,CAAG,KACP,IAAMA,EAAO,IAAI,CAAC,IAAI,GACjB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAM,CAAEA,KAC3B,IAAI,CAAC,EAAM,CAAGA,EACd,IAAI,CAAC,WAAW,GAEpB,CAAE,AACF,GAAQ,GACN,IAAI,CAAC,EAAY,CAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAM,EAC9C,IAAI,CAAC,EAAM,EACb,CACS,mBAAoB,CAC3B,IAAI,CAAC,EAAQ,EACf,CACS,mBAAmBD,CAAe,CAAE,CACvC,IAAI,CAAC,MAAM,CAACA,KAAc,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,IAClD,IAAI,CAAC,EAAY,KACjB,IAAI,CAAC,EAAQ,GAEjB,CACS,sBAAuB,CAC9B,IAAI,CAAC,EAAY,IACnB,CACS,QAAsB,CAE7B,OADA,IAAI,CAAC,EAAM,CAAG,IAAI,CAAC,IAAI,GAChB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAM,CAC9B,CACF,CC/BO,MAAME,mBAAqCJ,SAC7B,OAAOK,CAAyB,CAAE,CACnD,OAAOA,EAAM,KAAK,AACpB,CACmB,MAAoB,CACrC,MAAOC,AAAAA,GAAAA,sBAAAA,QAAAA,AAAAA,EAAS,IAAI,CAAC,KAAK,CAAC,KAAK,CAClC,CACmB,KAAKC,CAAkB,CAAe,CACvD,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAACA,EAC7B,CACmB,UAAUC,CAAkB,CAAc,CAC3D,MAAOC,AAAAA,GAAAA,sBAAAA,SAAAA,AAAAA,EAAU,IAAI,CAAC,KAAK,CAAC,KAAK,CAAED,EACrC,CACF,C"}
@@ -0,0 +1,30 @@
1
+ import { Component } from 'inferno';
2
+ import type { InfernoNode } from 'inferno';
3
+ import type { Snapshot } from '@slux/proxy';
4
+
5
+ declare abstract class Observer<Props, Value> extends Component<Props> {
6
+ #private;
7
+ protected abstract read(): Value;
8
+ protected abstract subscribe(notify: () => void): () => void;
9
+ protected abstract source(props: Props): unknown;
10
+ protected abstract view(value: Value): InfernoNode;
11
+ protected equal(previous: Value, next: Value): boolean;
12
+ componentDidMount(): void;
13
+ componentDidUpdate(previous: Props): void;
14
+ componentWillUnmount(): void;
15
+ render(): InfernoNode;
16
+ }
17
+
18
+ export declare class ProxyValue<T extends object> extends Observer<ProxyValueProps<T>, Snapshot<T>> {
19
+ protected source(props: ProxyValueProps<T>): T;
20
+ protected read(): Snapshot<T>;
21
+ protected view(value: Snapshot<T>): InfernoNode;
22
+ protected subscribe(notify: () => void): () => void;
23
+ }
24
+
25
+ export declare type ProxyValueProps<T extends object> = {
26
+ proxy: T;
27
+ children: (value: Snapshot<T>) => InfernoNode;
28
+ };
29
+
30
+ export { }
@@ -0,0 +1,30 @@
1
+ import { Component } from 'inferno';
2
+ import type { InfernoNode } from 'inferno';
3
+ import type { Snapshot } from '@slux/proxy';
4
+
5
+ declare abstract class Observer<Props, Value> extends Component<Props> {
6
+ #private;
7
+ protected abstract read(): Value;
8
+ protected abstract subscribe(notify: () => void): () => void;
9
+ protected abstract source(props: Props): unknown;
10
+ protected abstract view(value: Value): InfernoNode;
11
+ protected equal(previous: Value, next: Value): boolean;
12
+ componentDidMount(): void;
13
+ componentDidUpdate(previous: Props): void;
14
+ componentWillUnmount(): void;
15
+ render(): InfernoNode;
16
+ }
17
+
18
+ export declare class ProxyValue<T extends object> extends Observer<ProxyValueProps<T>, Snapshot<T>> {
19
+ protected source(props: ProxyValueProps<T>): T;
20
+ protected read(): Snapshot<T>;
21
+ protected view(value: Snapshot<T>): InfernoNode;
22
+ protected subscribe(notify: () => void): () => void;
23
+ }
24
+
25
+ export declare type ProxyValueProps<T extends object> = {
26
+ proxy: T;
27
+ children: (value: Snapshot<T>) => InfernoNode;
28
+ };
29
+
30
+ export { }
package/dist/proxy.js ADDED
@@ -0,0 +1,2 @@
1
+ import{snapshot as r,subscribe as o}from"@slux/proxy";import{Observer as e}from"./z~0.js";class p extends e{source(r){return r.proxy}read(){return r(this.props.proxy)}view(r){return this.props.children(r)}subscribe(r){return o(this.props.proxy,r)}}export{p as ProxyValue};
2
+ //# sourceMappingURL=proxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy.js","sources":["../src/proxy.ts"],"sourcesContent":["import type { InfernoNode } from \"inferno\";\nimport { snapshot, subscribe } from \"@slux/proxy\";\nimport type { Snapshot } from \"@slux/proxy\";\nimport { Observer } from \"./observer.js\";\n\nexport type ProxyValueProps<T extends object> = {\n proxy: T;\n children: (value: Snapshot<T>) => InfernoNode;\n};\nexport class ProxyValue<T extends object> extends Observer<ProxyValueProps<T>, Snapshot<T>> {\n protected override source(props: ProxyValueProps<T>) {\n return props.proxy;\n }\n protected override read(): Snapshot<T> {\n return snapshot(this.props.proxy);\n }\n protected override view(value: Snapshot<T>): InfernoNode {\n return this.props.children(value);\n }\n protected override subscribe(notify: () => void): () => void {\n return subscribe(this.props.proxy, notify);\n }\n}\n"],"names":["ProxyValue","Observer","props","snapshot","value","notify","subscribe"],"mappings":"qGASO,OAAMA,UAAqCC,EAC7B,OAAOC,CAAyB,CAAE,CACnD,OAAOA,EAAM,KAAK,AACpB,CACmB,MAAoB,CACrC,OAAOC,EAAS,IAAI,CAAC,KAAK,CAAC,KAAK,CAClC,CACmB,KAAKC,CAAkB,CAAe,CACvD,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAACA,EAC7B,CACmB,UAAUC,CAAkB,CAAc,CAC3D,OAAOC,EAAU,IAAI,CAAC,KAAK,CAAC,KAAK,CAAED,EACrC,CACF,Q"}
package/dist/rxjs.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_modules__={q(e,r,_){_.d(r,{SignalValue:()=>o});let t=require("inferno"),s=require("@slux/core");class c extends t.Component{#e;#r;equal(e,r){return Object.is(e,r)}#_=()=>{let e=this.read();this.equal(this.#r,e)||(this.#r=e,this.forceUpdate())};#t(){this.#e=this.subscribe(this.#_),this.#_()}componentDidMount(){this.#t()}componentDidUpdate(e){this.source(e)!==this.source(this.props)&&(this.#e?.(),this.#t())}componentWillUnmount(){this.#e?.()}render(){return this.#r=this.read(),this.view(this.#r)}}class o extends c{#s=!1;componentDidMount(){this.#s=!0,super.componentDidMount()}source(e){return e.source}read(){let e=this.context.sluxScope;return!this.#s&&e?e.get(this.props.source):this.props.source.get()}view(e){return this.props.children(e)}subscribe(e){let r=this.props.source,_=r.subscribe(e),t=(0,s.effect)(()=>{r.get()});return()=>{_(),t()}}}}},__webpack_module_cache__={};function __webpack_require__(e){var r=__webpack_module_cache__[e];if(void 0!==r)return r.exports;var _=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](_,_.exports,__webpack_require__),_.exports}__webpack_require__.d=(e,r,_)=>{var t=(r,_)=>{for(var t in r)__webpack_require__.o(r,t)&&!__webpack_require__.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,[_]:r[t]})};t(r,"get"),t(_,"value")},__webpack_require__.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),__webpack_require__.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};for(var __rspack_i in(()=>{__webpack_require__.r(__webpack_exports__);var e=__webpack_require__("q");class r extends e.SignalValue{}__webpack_require__.d(__webpack_exports__,{},{ObservableValue:r})})(),exports.ObservableValue=__webpack_exports__.ObservableValue,__webpack_exports__)-1===["ObservableValue"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
2
+ //# sourceMappingURL=rxjs.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rxjs.cjs","sources":["../src/observer.ts","../src/index.ts","webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../src/rxjs.ts"],"sourcesContent":["import { Component } from \"inferno\";\nimport type { InfernoNode } from \"inferno\";\n\nexport abstract class Observer<Props, Value> extends Component<Props> {\n #unsubscribe: (() => void) | undefined;\n #value!: Value;\n protected abstract read(): Value;\n protected abstract subscribe(notify: () => void): () => void;\n protected abstract source(props: Props): unknown;\n protected abstract view(value: Value): InfernoNode;\n protected equal(previous: Value, next: Value): boolean {\n return Object.is(previous, next);\n }\n #check = () => {\n const next = this.read();\n if (!this.equal(this.#value, next)) {\n this.#value = next;\n this.forceUpdate();\n }\n };\n #connect() {\n this.#unsubscribe = this.subscribe(this.#check);\n this.#check();\n }\n override componentDidMount() {\n this.#connect();\n }\n override componentDidUpdate(previous: Props) {\n if (this.source(previous) !== this.source(this.props)) {\n this.#unsubscribe?.();\n this.#connect();\n }\n }\n override componentWillUnmount() {\n this.#unsubscribe?.();\n }\n override render(): InfernoNode {\n this.#value = this.read();\n return this.view(this.#value);\n }\n}\n","import { Component } from \"inferno\";\nimport type { InfernoNode } from \"inferno\";\nimport { effect } from \"@slux/core\";\nimport type { Scope, Subscribable } from \"@slux/core\";\nimport { Observer } from \"./observer.js\";\n\nexport type ScopeContext = { sluxScope?: Scope };\nexport type ScopeProviderProps = { scope: Scope; children?: InfernoNode };\nexport class ScopeProvider extends Component<ScopeProviderProps> {\n override getChildContext(): ScopeContext {\n return { sluxScope: this.props.scope };\n }\n override render(): InfernoNode {\n return this.props.children;\n }\n}\nexport function getScope(context: ScopeContext): Scope | undefined {\n return context.sluxScope;\n}\nexport type SignalValueProps<T> = {\n source: Subscribable<T>;\n children: (value: T) => InfernoNode;\n};\nexport class SignalValue<T, Props extends SignalValueProps<T> = SignalValueProps<T>> extends Observer<Props, T> {\n #mounted = false;\n override componentDidMount() {\n this.#mounted = true;\n super.componentDidMount();\n }\n protected override source(props: Props) {\n return props.source;\n }\n protected override read(): T {\n const scope = getScope(this.context as ScopeContext);\n return !this.#mounted && scope ? scope.get(this.props.source) : this.props.source.get();\n }\n protected override view(value: T): InfernoNode {\n return (this.props.children as (value: T) => InfernoNode)(value);\n }\n protected override subscribe(notify: () => void): () => void {\n const source = this.props.source;\n const unsubscribe = source.subscribe(notify);\n const dispose = effect(() => {\n source.get();\n });\n return () => {\n unsubscribe();\n dispose();\n };\n }\n}\nexport { createAutoImportApis } from \"./auto-import-api.js\";\n","__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { ObservableState } from \"@slux/rxjs\";\nimport type { InfernoNode } from \"inferno\";\nimport { SignalValue } from \"./index.js\";\n\nexport type ObservableValueProps<T> = {\n source: ObservableState<T>;\n children: (value: T) => InfernoNode;\n};\n\nexport class ObservableValue<T> extends SignalValue<T, ObservableValueProps<T>> {}\n"],"names":["Observer","Component","previous","next","Object","SignalValue","props","scope","context","value","notify","source","unsubscribe","dispose","effect","__webpack_require__","e","Symbol","ObservableValue"],"mappings":"2UAGO,OAAeA,UAA+BC,EAAAA,SAASA,CAC5D,EAAY,AAA2B,AACvC,GAAM,AAAS,AAKL,OAAMC,CAAe,CAAEC,CAAW,CAAW,CACrD,OAAOC,OAAO,EAAE,CAACF,EAAUC,EAC7B,CACA,EAAM,CAAG,KACP,IAAMA,EAAO,IAAI,CAAC,IAAI,GACj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AAAA,GAAAA,EAAAA,MAAAA,AAAAA,EAAO,KACrBH,EAAO,GAAG,EACZ,GACA,MAAO,KACLC,IACAC,GACF,CACF,CACF,C,wPClDAE,oBAAoB,CAAC,CAAG,CAACC,EAAS,EAAS,KAC1C,IAAI,EAAS,CAAC,EAAM,KACnB,IAAI,IAAI,KAAO,EACXD,oBAAoB,CAAC,CAAC,EAAM,IAAQ,CAACA,oBAAoB,CAAC,CAACC,EAAS,IACtEZ,OAAO,cAAc,CAACY,EAAS,EAAK,CAAE,WAAY,GAAM,CAAC,EAAK,CAAE,CAAI,CAAC,EAAI,AAAC,EAG7E,EACA,EAAO,EAAS,OAChB,EAAO,EAAQ,QAChB,ECVAD,oBAAoB,CAAC,CAAG,CAAC,EAAK,IAAUX,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,EAAK,GCClFW,oBAAoB,CAAC,CAAG,AAACC,IACrB,AAAkB,IAAlB,OAAOC,QAA0BA,OAAO,WAAW,EACrDb,OAAO,cAAc,CAACY,EAASC,OAAO,WAAW,CAAE,CAAE,MAAO,QAAS,GAEtEb,OAAO,cAAc,CAACY,EAAS,aAAc,CAAE,MAAO,EAAK,EAC5D,E,+HCGO,OAAME,UAA2Bb,EAAAA,WAAWA,CAA8B,C"}
@@ -0,0 +1,41 @@
1
+ import { Component } from 'inferno';
2
+ import type { InfernoNode } from 'inferno';
3
+ import type { ObservableState } from '@slux/rxjs';
4
+ import type { Subscribable } from '@slux/core';
5
+
6
+ export declare class ObservableValue<T> extends SignalValue<T, ObservableValueProps<T>> {
7
+ }
8
+
9
+ export declare type ObservableValueProps<T> = {
10
+ source: ObservableState<T>;
11
+ children: (value: T) => InfernoNode;
12
+ };
13
+
14
+ declare abstract class Observer<Props, Value> extends Component<Props> {
15
+ #private;
16
+ protected abstract read(): Value;
17
+ protected abstract subscribe(notify: () => void): () => void;
18
+ protected abstract source(props: Props): unknown;
19
+ protected abstract view(value: Value): InfernoNode;
20
+ protected equal(previous: Value, next: Value): boolean;
21
+ componentDidMount(): void;
22
+ componentDidUpdate(previous: Props): void;
23
+ componentWillUnmount(): void;
24
+ render(): InfernoNode;
25
+ }
26
+
27
+ declare class SignalValue<T, Props extends SignalValueProps<T> = SignalValueProps<T>> extends Observer<Props, T> {
28
+ #private;
29
+ componentDidMount(): void;
30
+ protected source(props: Props): Subscribable<T>;
31
+ protected read(): T;
32
+ protected view(value: T): InfernoNode;
33
+ protected subscribe(notify: () => void): () => void;
34
+ }
35
+
36
+ declare type SignalValueProps<T> = {
37
+ source: Subscribable<T>;
38
+ children: (value: T) => InfernoNode;
39
+ };
40
+
41
+ export { }
package/dist/rxjs.d.ts ADDED
@@ -0,0 +1,41 @@
1
+ import { Component } from 'inferno';
2
+ import type { InfernoNode } from 'inferno';
3
+ import type { ObservableState } from '@slux/rxjs';
4
+ import type { Subscribable } from '@slux/core';
5
+
6
+ export declare class ObservableValue<T> extends SignalValue<T, ObservableValueProps<T>> {
7
+ }
8
+
9
+ export declare type ObservableValueProps<T> = {
10
+ source: ObservableState<T>;
11
+ children: (value: T) => InfernoNode;
12
+ };
13
+
14
+ declare abstract class Observer<Props, Value> extends Component<Props> {
15
+ #private;
16
+ protected abstract read(): Value;
17
+ protected abstract subscribe(notify: () => void): () => void;
18
+ protected abstract source(props: Props): unknown;
19
+ protected abstract view(value: Value): InfernoNode;
20
+ protected equal(previous: Value, next: Value): boolean;
21
+ componentDidMount(): void;
22
+ componentDidUpdate(previous: Props): void;
23
+ componentWillUnmount(): void;
24
+ render(): InfernoNode;
25
+ }
26
+
27
+ declare class SignalValue<T, Props extends SignalValueProps<T> = SignalValueProps<T>> extends Observer<Props, T> {
28
+ #private;
29
+ componentDidMount(): void;
30
+ protected source(props: Props): Subscribable<T>;
31
+ protected read(): T;
32
+ protected view(value: T): InfernoNode;
33
+ protected subscribe(notify: () => void): () => void;
34
+ }
35
+
36
+ declare type SignalValueProps<T> = {
37
+ source: Subscribable<T>;
38
+ children: (value: T) => InfernoNode;
39
+ };
40
+
41
+ export { }
package/dist/rxjs.js ADDED
@@ -0,0 +1,2 @@
1
+ import{SignalValue as e}from"./index.js";class _ extends e{}export{_ as ObservableValue};
2
+ //# sourceMappingURL=rxjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rxjs.js","sources":["../src/rxjs.ts"],"sourcesContent":["import type { ObservableState } from \"@slux/rxjs\";\nimport type { InfernoNode } from \"inferno\";\nimport { SignalValue } from \"./index.js\";\n\nexport type ObservableValueProps<T> = {\n source: ObservableState<T>;\n children: (value: T) => InfernoNode;\n};\n\nexport class ObservableValue<T> extends SignalValue<T, ObservableValueProps<T>> {}\n"],"names":["ObservableValue","SignalValue"],"mappings":"kDASO,OAAMA,UAA2BC,EAAyC,Q"}
@@ -0,0 +1,2 @@
1
+ "use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_modules__={q(e,_,r){r.d(_,{SignalValue:()=>i});let t=require("inferno"),c=require("@slux/core");class s extends t.Component{#e;#_;equal(e,_){return Object.is(e,_)}#r=()=>{let e=this.read();this.equal(this.#_,e)||(this.#_=e,this.forceUpdate())};#t(){this.#e=this.subscribe(this.#r),this.#r()}componentDidMount(){this.#t()}componentDidUpdate(e){this.source(e)!==this.source(this.props)&&(this.#e?.(),this.#t())}componentWillUnmount(){this.#e?.()}render(){return this.#_=this.read(),this.view(this.#_)}}class i extends s{#c=!1;componentDidMount(){this.#c=!0,super.componentDidMount()}source(e){return e.source}read(){let e=this.context.sluxScope;return!this.#c&&e?e.get(this.props.source):this.props.source.get()}view(e){return this.props.children(e)}subscribe(e){let _=this.props.source,r=_.subscribe(e),t=(0,c.effect)(()=>{_.get()});return()=>{r(),t()}}}}},__webpack_module_cache__={};function __webpack_require__(e){var _=__webpack_module_cache__[e];if(void 0!==_)return _.exports;var r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](r,r.exports,__webpack_require__),r.exports}__webpack_require__.d=(e,_,r)=>{var t=(_,r)=>{for(var t in _)__webpack_require__.o(_,t)&&!__webpack_require__.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,[r]:_[t]})};t(_,"get"),t(r,"value")},__webpack_require__.o=(e,_)=>Object.prototype.hasOwnProperty.call(e,_),__webpack_require__.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};for(var __rspack_i in(()=>{__webpack_require__.r(__webpack_exports__);var e=__webpack_require__("q");class _ extends e.SignalValue{}__webpack_require__.d(__webpack_exports__,{},{MachineValue:_})})(),exports.MachineValue=__webpack_exports__.MachineValue,__webpack_exports__)-1===["MachineValue"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
2
+ //# sourceMappingURL=state-machine.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-machine.cjs","sources":["../src/observer.ts","../src/index.ts","webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../src/state-machine.ts"],"sourcesContent":["import { Component } from \"inferno\";\nimport type { InfernoNode } from \"inferno\";\n\nexport abstract class Observer<Props, Value> extends Component<Props> {\n #unsubscribe: (() => void) | undefined;\n #value!: Value;\n protected abstract read(): Value;\n protected abstract subscribe(notify: () => void): () => void;\n protected abstract source(props: Props): unknown;\n protected abstract view(value: Value): InfernoNode;\n protected equal(previous: Value, next: Value): boolean {\n return Object.is(previous, next);\n }\n #check = () => {\n const next = this.read();\n if (!this.equal(this.#value, next)) {\n this.#value = next;\n this.forceUpdate();\n }\n };\n #connect() {\n this.#unsubscribe = this.subscribe(this.#check);\n this.#check();\n }\n override componentDidMount() {\n this.#connect();\n }\n override componentDidUpdate(previous: Props) {\n if (this.source(previous) !== this.source(this.props)) {\n this.#unsubscribe?.();\n this.#connect();\n }\n }\n override componentWillUnmount() {\n this.#unsubscribe?.();\n }\n override render(): InfernoNode {\n this.#value = this.read();\n return this.view(this.#value);\n }\n}\n","import { Component } from \"inferno\";\nimport type { InfernoNode } from \"inferno\";\nimport { effect } from \"@slux/core\";\nimport type { Scope, Subscribable } from \"@slux/core\";\nimport { Observer } from \"./observer.js\";\n\nexport type ScopeContext = { sluxScope?: Scope };\nexport type ScopeProviderProps = { scope: Scope; children?: InfernoNode };\nexport class ScopeProvider extends Component<ScopeProviderProps> {\n override getChildContext(): ScopeContext {\n return { sluxScope: this.props.scope };\n }\n override render(): InfernoNode {\n return this.props.children;\n }\n}\nexport function getScope(context: ScopeContext): Scope | undefined {\n return context.sluxScope;\n}\nexport type SignalValueProps<T> = {\n source: Subscribable<T>;\n children: (value: T) => InfernoNode;\n};\nexport class SignalValue<T, Props extends SignalValueProps<T> = SignalValueProps<T>> extends Observer<Props, T> {\n #mounted = false;\n override componentDidMount() {\n this.#mounted = true;\n super.componentDidMount();\n }\n protected override source(props: Props) {\n return props.source;\n }\n protected override read(): T {\n const scope = getScope(this.context as ScopeContext);\n return !this.#mounted && scope ? scope.get(this.props.source) : this.props.source.get();\n }\n protected override view(value: T): InfernoNode {\n return (this.props.children as (value: T) => InfernoNode)(value);\n }\n protected override subscribe(notify: () => void): () => void {\n const source = this.props.source;\n const unsubscribe = source.subscribe(notify);\n const dispose = effect(() => {\n source.get();\n });\n return () => {\n unsubscribe();\n dispose();\n };\n }\n}\nexport { createAutoImportApis } from \"./auto-import-api.js\";\n","__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { MachineSnapshot, StateMachine } from \"@slux/state-machine\";\nimport type { InfernoNode } from \"inferno\";\nimport { SignalValue } from \"./index.js\";\n\nexport type MachineValueProps<Context, Event extends { type: string }, State extends string> = {\n source: StateMachine<Context, Event, State>;\n children: (value: MachineSnapshot<Context, State>) => InfernoNode;\n};\n\nexport class MachineValue<Context, Event extends { type: string }, State extends string> extends SignalValue<\n MachineSnapshot<Context, State>,\n MachineValueProps<Context, Event, State>\n> {}\n"],"names":["Observer","Component","previous","next","Object","SignalValue","props","scope","context","value","notify","source","unsubscribe","dispose","effect","__webpack_require__","e","Symbol","MachineValue"],"mappings":"2UAGO,OAAeA,UAA+BC,EAAAA,SAASA,CAC5D,EAAY,AAA2B,AACvC,GAAM,AAAS,AAKL,OAAMC,CAAe,CAAEC,CAAW,CAAW,CACrD,OAAOC,OAAO,EAAE,CAACF,EAAUC,EAC7B,CACA,EAAM,CAAG,KACP,IAAMA,EAAO,IAAI,CAAC,IAAI,GACjB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAM,CAAEA,KAC3B,IAAI,CAAC,EAAM,CAAGA,EACd,IAAI,CAAC,WAAW,GAEpB,CAAE,AACF,GAAQ,GACN,IAAI,CAAC,EAAY,CAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAM,EAC9C,IAAI,CAAC,EAAM,EACb,CACS,mBAAoB,CAC3B,IAAI,CAAC,EAAQ,EACf,CACS,mBAAmBD,CAAe,CAAE,CACvC,IAAI,CAAC,MAAM,CAACA,KAAc,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,IAClD,IAAI,CAAC,EAAY,KACjB,IAAI,CAAC,EAAQ,GAEjB,CACS,sBAAuB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AAG,CAAC,EAAK,IAAUX,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,EAAK,GCClFW,oBAAoB,CAAC,CAAG,AAACC,IACrB,AAAkB,IAAlB,OAAOC,QAA0BA,OAAO,WAAW,EACrDb,OAAO,cAAc,CAACY,EAASC,OAAO,WAAW,CAAE,CAAE,MAAO,QAAS,GAEtEb,OAAO,cAAc,CAACY,EAAS,aAAc,CAAE,MAAO,EAAK,EAC5D,E,+HCGO,OAAME,UAAoFb,EAAAA,WAAWA,CAGzG,C"}
@@ -0,0 +1,46 @@
1
+ import { Component } from 'inferno';
2
+ import type { InfernoNode } from 'inferno';
3
+ import type { MachineSnapshot } from '@slux/state-machine';
4
+ import type { StateMachine } from '@slux/state-machine';
5
+ import type { Subscribable } from '@slux/core';
6
+
7
+ export declare class MachineValue<Context, Event extends {
8
+ type: string;
9
+ }, State extends string> extends SignalValue<MachineSnapshot<Context, State>, MachineValueProps<Context, Event, State>> {
10
+ }
11
+
12
+ export declare type MachineValueProps<Context, Event extends {
13
+ type: string;
14
+ }, State extends string> = {
15
+ source: StateMachine<Context, Event, State>;
16
+ children: (value: MachineSnapshot<Context, State>) => InfernoNode;
17
+ };
18
+
19
+ declare abstract class Observer<Props, Value> extends Component<Props> {
20
+ #private;
21
+ protected abstract read(): Value;
22
+ protected abstract subscribe(notify: () => void): () => void;
23
+ protected abstract source(props: Props): unknown;
24
+ protected abstract view(value: Value): InfernoNode;
25
+ protected equal(previous: Value, next: Value): boolean;
26
+ componentDidMount(): void;
27
+ componentDidUpdate(previous: Props): void;
28
+ componentWillUnmount(): void;
29
+ render(): InfernoNode;
30
+ }
31
+
32
+ declare class SignalValue<T, Props extends SignalValueProps<T> = SignalValueProps<T>> extends Observer<Props, T> {
33
+ #private;
34
+ componentDidMount(): void;
35
+ protected source(props: Props): Subscribable<T>;
36
+ protected read(): T;
37
+ protected view(value: T): InfernoNode;
38
+ protected subscribe(notify: () => void): () => void;
39
+ }
40
+
41
+ declare type SignalValueProps<T> = {
42
+ source: Subscribable<T>;
43
+ children: (value: T) => InfernoNode;
44
+ };
45
+
46
+ export { }
@@ -0,0 +1,46 @@
1
+ import { Component } from 'inferno';
2
+ import type { InfernoNode } from 'inferno';
3
+ import type { MachineSnapshot } from '@slux/state-machine';
4
+ import type { StateMachine } from '@slux/state-machine';
5
+ import type { Subscribable } from '@slux/core';
6
+
7
+ export declare class MachineValue<Context, Event extends {
8
+ type: string;
9
+ }, State extends string> extends SignalValue<MachineSnapshot<Context, State>, MachineValueProps<Context, Event, State>> {
10
+ }
11
+
12
+ export declare type MachineValueProps<Context, Event extends {
13
+ type: string;
14
+ }, State extends string> = {
15
+ source: StateMachine<Context, Event, State>;
16
+ children: (value: MachineSnapshot<Context, State>) => InfernoNode;
17
+ };
18
+
19
+ declare abstract class Observer<Props, Value> extends Component<Props> {
20
+ #private;
21
+ protected abstract read(): Value;
22
+ protected abstract subscribe(notify: () => void): () => void;
23
+ protected abstract source(props: Props): unknown;
24
+ protected abstract view(value: Value): InfernoNode;
25
+ protected equal(previous: Value, next: Value): boolean;
26
+ componentDidMount(): void;
27
+ componentDidUpdate(previous: Props): void;
28
+ componentWillUnmount(): void;
29
+ render(): InfernoNode;
30
+ }
31
+
32
+ declare class SignalValue<T, Props extends SignalValueProps<T> = SignalValueProps<T>> extends Observer<Props, T> {
33
+ #private;
34
+ componentDidMount(): void;
35
+ protected source(props: Props): Subscribable<T>;
36
+ protected read(): T;
37
+ protected view(value: T): InfernoNode;
38
+ protected subscribe(notify: () => void): () => void;
39
+ }
40
+
41
+ declare type SignalValueProps<T> = {
42
+ source: Subscribable<T>;
43
+ children: (value: T) => InfernoNode;
44
+ };
45
+
46
+ export { }
@@ -0,0 +1,2 @@
1
+ import{SignalValue as e}from"./index.js";class _ extends e{}export{_ as MachineValue};
2
+ //# sourceMappingURL=state-machine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-machine.js","sources":["../src/state-machine.ts"],"sourcesContent":["import type { MachineSnapshot, StateMachine } from \"@slux/state-machine\";\nimport type { InfernoNode } from \"inferno\";\nimport { SignalValue } from \"./index.js\";\n\nexport type MachineValueProps<Context, Event extends { type: string }, State extends string> = {\n source: StateMachine<Context, Event, State>;\n children: (value: MachineSnapshot<Context, State>) => InfernoNode;\n};\n\nexport class MachineValue<Context, Event extends { type: string }, State extends string> extends SignalValue<\n MachineSnapshot<Context, State>,\n MachineValueProps<Context, Event, State>\n> {}\n"],"names":["MachineValue","SignalValue"],"mappings":"kDASO,OAAMA,UAAoFC,EAG9F,Q"}
package/dist/store.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";const __rslib_import_meta_url__="u"<typeof document?new(require("url".replace("",""))).URL("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href;var __webpack_require__={};__webpack_require__.d=(e,r,t)=>{var _=(r,t)=>{for(var _ in r)__webpack_require__.o(r,_)&&!__webpack_require__.o(e,_)&&Object.defineProperty(e,_,{enumerable:!0,[t]:r[_]})};_(r,"get"),_(t,"value")},__webpack_require__.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),__webpack_require__.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{StoreValue:()=>StoreValue});const external_inferno_namespaceObject=require("inferno");class Observer extends external_inferno_namespaceObject.Component{#e;#r;equal(e,r){return Object.is(e,r)}#t=()=>{let e=this.read();this.equal(this.#r,e)||(this.#r=e,this.forceUpdate())};#_(){this.#e=this.subscribe(this.#t),this.#t()}componentDidMount(){this.#_()}componentDidUpdate(e){this.source(e)!==this.source(this.props)&&(this.#e?.(),this.#_())}componentWillUnmount(){this.#e?.()}render(){return this.#r=this.read(),this.view(this.#r)}}class StoreValue extends Observer{source(e){return e.store}read(){let{store:e,selector:r}=this.props;return r?r(e.getState()):e.getState()}equal(e,r){return(this.props.equalityFn??Object.is)(e,r)}view(e){return this.props.children(e)}subscribe(e){return this.props.store.subscribe(e)}}for(var __rspack_i in exports.StoreValue=__webpack_exports__.StoreValue,__webpack_exports__)-1===["StoreValue"].indexOf(__rspack_i)&&(exports[__rspack_i]=__webpack_exports__[__rspack_i]);Object.defineProperty(exports,"__esModule",{value:!0});
2
+ //# sourceMappingURL=store.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../src/observer.ts","../src/store.ts"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { Component } from \"inferno\";\nimport type { InfernoNode } from \"inferno\";\n\nexport abstract class Observer<Props, Value> extends Component<Props> {\n #unsubscribe: (() => void) | undefined;\n #value!: Value;\n protected abstract read(): Value;\n protected abstract subscribe(notify: () => void): () => void;\n protected abstract source(props: Props): unknown;\n protected abstract view(value: Value): InfernoNode;\n protected equal(previous: Value, next: Value): boolean {\n return Object.is(previous, next);\n }\n #check = () => {\n const next = this.read();\n if (!this.equal(this.#value, next)) {\n this.#value = next;\n this.forceUpdate();\n }\n };\n #connect() {\n this.#unsubscribe = this.subscribe(this.#check);\n this.#check();\n }\n override componentDidMount() {\n this.#connect();\n }\n override componentDidUpdate(previous: Props) {\n if (this.source(previous) !== this.source(this.props)) {\n this.#unsubscribe?.();\n this.#connect();\n }\n }\n override componentWillUnmount() {\n this.#unsubscribe?.();\n }\n override render(): InfernoNode {\n this.#value = this.read();\n return this.view(this.#value);\n }\n}\n","import type { InfernoNode } from \"inferno\";\nimport type { StoreApi } from \"@slux/store\";\nimport { Observer } from \"./observer.js\";\n\nexport type StoreValueProps<State extends object, Selection = State> = {\n store: StoreApi<State>;\n equalityFn?: (previous: Selection, next: Selection) => boolean;\n children: (value: Selection) => InfernoNode;\n} & ({ selector: (state: State) => Selection } | (State extends Selection ? { selector?: undefined } : never));\nexport class StoreValue<State extends object, Selection = State> extends Observer<StoreValueProps<State, Selection>, Selection> {\n protected override source(props: StoreValueProps<State, Selection>) {\n return props.store;\n }\n protected override read(): Selection {\n const { store, selector } = this.props;\n return selector ? selector(store.getState()) : (store.getState() as unknown as Selection);\n }\n protected override equal(previous: Selection, next: Selection): boolean {\n return (this.props.equalityFn ?? Object.is)(previous, next);\n }\n protected override view(value: Selection): InfernoNode {\n return (this.props.children as (value: Selection) => InfernoNode)(value);\n }\n protected override subscribe(notify: () => void): () => void {\n return this.props.store.subscribe(notify);\n }\n}\n"],"names":["__webpack_require__","e","Object","Symbol","Observer","Component","previous","next","StoreValue","props","store","selector","value","notify"],"mappings":"wPAAAA,CAAAA,oBAAoB,CAAC,CAAG,CAACC,EAAS,EAAS,KAC1C,IAAI,EAAS,CAAC,EAAM,KACnB,IAAI,IAAI,KAAO,EACXD,oBAAoB,CAAC,CAAC,EAAM,IAAQ,CAACA,oBAAoB,CAAC,CAACC,EAAS,IACtEC,OAAO,cAAc,CAACD,EAAS,EAAK,CAAE,WAAY,GAAM,CAAC,EAAK,CAAE,CAAI,CAAC,EAAI,AAAC,EAG7E,EACA,EAAO,EAAS,OAChB,EAAO,EAAQ,QAChB,ECVAD,oBAAoB,CAAC,CAAG,CAAC,EAAK,IAAU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A,CAAQ,CAAE,CAAG,IAAI,CAAC,KAAK,CACtC,OAAOA,EAAWA,EAASD,EAAM,QAAQ,IAAOA,EAAM,QAAQ,EAChE,CACmB,MAAMJ,CAAmB,CAAEC,CAAe,CAAW,CACtE,MAAQ,KAAI,CAAC,KAAK,CAAC,UAAU,EAAIL,OAAO,EAAC,EAAGI,EAAUC,EACxD,CACmB,KAAKK,CAAgB,CAAe,CACrD,OAAQ,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAuCA,EACpE,CACmB,UAAUC,CAAkB,CAAc,CAC3D,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAACA,EACpC,CACF,C"}
@@ -0,0 +1,36 @@
1
+ import { Component } from 'inferno';
2
+ import type { InfernoNode } from 'inferno';
3
+ import type { StoreApi } from '@slux/store';
4
+
5
+ declare abstract class Observer<Props, Value> extends Component<Props> {
6
+ #private;
7
+ protected abstract read(): Value;
8
+ protected abstract subscribe(notify: () => void): () => void;
9
+ protected abstract source(props: Props): unknown;
10
+ protected abstract view(value: Value): InfernoNode;
11
+ protected equal(previous: Value, next: Value): boolean;
12
+ componentDidMount(): void;
13
+ componentDidUpdate(previous: Props): void;
14
+ componentWillUnmount(): void;
15
+ render(): InfernoNode;
16
+ }
17
+
18
+ export declare class StoreValue<State extends object, Selection = State> extends Observer<StoreValueProps<State, Selection>, Selection> {
19
+ protected source(props: StoreValueProps<State, Selection>): StoreApi<State>;
20
+ protected read(): Selection;
21
+ protected equal(previous: Selection, next: Selection): boolean;
22
+ protected view(value: Selection): InfernoNode;
23
+ protected subscribe(notify: () => void): () => void;
24
+ }
25
+
26
+ export declare type StoreValueProps<State extends object, Selection = State> = {
27
+ store: StoreApi<State>;
28
+ equalityFn?: (previous: Selection, next: Selection) => boolean;
29
+ children: (value: Selection) => InfernoNode;
30
+ } & ({
31
+ selector: (state: State) => Selection;
32
+ } | (State extends Selection ? {
33
+ selector?: undefined;
34
+ } : never));
35
+
36
+ export { }
@@ -0,0 +1,36 @@
1
+ import { Component } from 'inferno';
2
+ import type { InfernoNode } from 'inferno';
3
+ import type { StoreApi } from '@slux/store';
4
+
5
+ declare abstract class Observer<Props, Value> extends Component<Props> {
6
+ #private;
7
+ protected abstract read(): Value;
8
+ protected abstract subscribe(notify: () => void): () => void;
9
+ protected abstract source(props: Props): unknown;
10
+ protected abstract view(value: Value): InfernoNode;
11
+ protected equal(previous: Value, next: Value): boolean;
12
+ componentDidMount(): void;
13
+ componentDidUpdate(previous: Props): void;
14
+ componentWillUnmount(): void;
15
+ render(): InfernoNode;
16
+ }
17
+
18
+ export declare class StoreValue<State extends object, Selection = State> extends Observer<StoreValueProps<State, Selection>, Selection> {
19
+ protected source(props: StoreValueProps<State, Selection>): StoreApi<State>;
20
+ protected read(): Selection;
21
+ protected equal(previous: Selection, next: Selection): boolean;
22
+ protected view(value: Selection): InfernoNode;
23
+ protected subscribe(notify: () => void): () => void;
24
+ }
25
+
26
+ export declare type StoreValueProps<State extends object, Selection = State> = {
27
+ store: StoreApi<State>;
28
+ equalityFn?: (previous: Selection, next: Selection) => boolean;
29
+ children: (value: Selection) => InfernoNode;
30
+ } & ({
31
+ selector: (state: State) => Selection;
32
+ } | (State extends Selection ? {
33
+ selector?: undefined;
34
+ } : never));
35
+
36
+ export { }
package/dist/store.js ADDED
@@ -0,0 +1,2 @@
1
+ import{Observer as e}from"./z~0.js";class r extends e{source(e){return e.store}read(){let{store:e,selector:r}=this.props;return r?r(e.getState()):e.getState()}equal(e,r){return(this.props.equalityFn??Object.is)(e,r)}view(e){return this.props.children(e)}subscribe(e){return this.props.store.subscribe(e)}}export{r as StoreValue};
2
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","sources":["../src/store.ts"],"sourcesContent":["import type { InfernoNode } from \"inferno\";\nimport type { StoreApi } from \"@slux/store\";\nimport { Observer } from \"./observer.js\";\n\nexport type StoreValueProps<State extends object, Selection = State> = {\n store: StoreApi<State>;\n equalityFn?: (previous: Selection, next: Selection) => boolean;\n children: (value: Selection) => InfernoNode;\n} & ({ selector: (state: State) => Selection } | (State extends Selection ? { selector?: undefined } : never));\nexport class StoreValue<State extends object, Selection = State> extends Observer<StoreValueProps<State, Selection>, Selection> {\n protected override source(props: StoreValueProps<State, Selection>) {\n return props.store;\n }\n protected override read(): Selection {\n const { store, selector } = this.props;\n return selector ? selector(store.getState()) : (store.getState() as unknown as Selection);\n }\n protected override equal(previous: Selection, next: Selection): boolean {\n return (this.props.equalityFn ?? Object.is)(previous, next);\n }\n protected override view(value: Selection): InfernoNode {\n return (this.props.children as (value: Selection) => InfernoNode)(value);\n }\n protected override subscribe(notify: () => void): () => void {\n return this.props.store.subscribe(notify);\n }\n}\n"],"names":["StoreValue","Observer","props","store","selector","previous","next","Object","value","notify"],"mappings":"+CASO,OAAMA,UAA4DC,EACpD,OAAOC,CAAwC,CAAE,CAClE,OAAOA,EAAM,KAAK,AACpB,CACmB,MAAkB,CACnC,GAAM,CAAEC,MAAAA,CAAK,CAAEC,SAAAA,CAAQ,CAAE,CAAG,IAAI,CAAC,KAAK,CACtC,OAAOA,EAAWA,EAASD,EAAM,QAAQ,IAAOA,EAAM,QAAQ,EAChE,CACmB,MAAME,CAAmB,CAAEC,CAAe,CAAW,CACtE,MAAQ,KAAI,CAAC,KAAK,CAAC,UAAU,EAAIC,OAAO,EAAC,EAAGF,EAAUC,EACxD,CACmB,KAAKE,CAAgB,CAAe,CACrD,OAAQ,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAuCA,EACpE,CACmB,UAAUC,CAAkB,CAAc,CAC3D,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAACA,EACpC,CACF,Q"}
package/dist/z~0.js ADDED
@@ -0,0 +1,2 @@
1
+ import{Component as e}from"inferno";class s extends e{#e;#s;equal(e,s){return Object.is(e,s)}#t=()=>{let e=this.read();this.equal(this.#s,e)||(this.#s=e,this.forceUpdate())};#i(){this.#e=this.subscribe(this.#t),this.#t()}componentDidMount(){this.#i()}componentDidUpdate(e){this.source(e)!==this.source(this.props)&&(this.#e?.(),this.#i())}componentWillUnmount(){this.#e?.()}render(){return this.#s=this.read(),this.view(this.#s)}}export{s as Observer};
2
+ //# sourceMappingURL=z~0.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"z~0.js","sources":["../src/observer.ts"],"sourcesContent":["import { Component } from \"inferno\";\nimport type { InfernoNode } from \"inferno\";\n\nexport abstract class Observer<Props, Value> extends Component<Props> {\n #unsubscribe: (() => void) | undefined;\n #value!: Value;\n protected abstract read(): Value;\n protected abstract subscribe(notify: () => void): () => void;\n protected abstract source(props: Props): unknown;\n protected abstract view(value: Value): InfernoNode;\n protected equal(previous: Value, next: Value): boolean {\n return Object.is(previous, next);\n }\n #check = () => {\n const next = this.read();\n if (!this.equal(this.#value, next)) {\n this.#value = next;\n this.forceUpdate();\n }\n };\n #connect() {\n this.#unsubscribe = this.subscribe(this.#check);\n this.#check();\n }\n override componentDidMount() {\n this.#connect();\n }\n override componentDidUpdate(previous: Props) {\n if (this.source(previous) !== this.source(this.props)) {\n this.#unsubscribe?.();\n this.#connect();\n }\n }\n override componentWillUnmount() {\n this.#unsubscribe?.();\n }\n override render(): InfernoNode {\n this.#value = this.read();\n return this.view(this.#value);\n }\n}\n"],"names":["Observer","Component","previous","next","Object"],"mappings":"mCAGO,OAAeA,UAA+BC,EACnD,EAAY,AAA2B,AACvC,GAAM,AAAS,AAKL,OAAMC,CAAe,CAAEC,CAAW,CAAW,CACrD,OAAOC,OAAO,EAAE,CAACF,EAAUC,EAC7B,CACA,EAAM,CAAG,KACP,IAAMA,EAAO,IAAI,CAAC,IAAI,GACjB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAM,CAAEA,KAC3B,IAAI,CAAC,EAAM,CAAGA,EACd,IAAI,CAAC,WAAW,GAEpB,CAAE,AACF,GAAQ,GACN,IAAI,CAAC,EAAY,CAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAM,EAC9C,IAAI,CAAC,EAAM,EACb,CACS,mBAAoB,CAC3B,IAAI,CAAC,EAAQ,EACf,CACS,mBAAmBD,CAAe,CAAE,CACvC,IAAI,CAAC,MAAM,CAACA,KAAc,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,IAClD,IAAI,CAAC,EAAY,KACjB,IAAI,CAAC,EAAQ,GAEjB,CACS,sBAAuB,CAC9B,IAAI,CAAC,EAAY,IACnB,CACS,QAAsB,CAE7B,OADA,IAAI,CAAC,EAAM,CAAG,IAAI,CAAC,IAAI,GAChB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAM,CAC9B,CACF,Q"}