react-state-basis 0.3.0 → 0.3.2

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,21 +1,29 @@
1
- // src/production.ts
1
+ // src/production-hooks.ts
2
2
  import * as React from "react";
3
+ var BasisProvider = ({ children }) => {
4
+ return React.createElement(React.Fragment, null, children);
5
+ };
3
6
  var useState2 = (initialState, _label) => React.useState(initialState);
4
7
  var useEffect2 = (effect, deps, _label) => React.useEffect(effect, deps);
5
8
  var useMemo2 = (factory, deps, _label) => React.useMemo(factory, deps);
6
9
  var useCallback2 = (callback, deps, _label) => React.useCallback(callback, deps);
7
- var useReducer2 = (reducer, initialArg, init, _label) => React.useReducer(reducer, initialArg, init);
10
+ var useReducer2 = (reducer, initArg, init, _label) => React.useReducer(reducer, initArg, init);
8
11
  var useRef2 = (initialValue, _label) => React.useRef(initialValue);
9
12
  var useLayoutEffect2 = (effect, deps, _label) => React.useLayoutEffect(effect, deps);
10
- var useContext2 = React.useContext;
11
- var createContext2 = React.createContext;
12
- var useId2 = React.useId;
13
+ var useTransition2 = (_label) => React.useTransition();
14
+ var useDeferredValue2 = (value, _label) => React.useDeferredValue(value);
15
+ var useOptimistic2 = (passthrough, reducer, _label) => React.useOptimistic(passthrough, reducer);
16
+ var useActionState2 = (action, initialState, permalink, _label) => React.useActionState(action, initialState, permalink);
17
+ var useId2 = (_label) => React.useId();
13
18
  var useDebugValue2 = React.useDebugValue;
14
19
  var useImperativeHandle2 = React.useImperativeHandle;
15
20
  var useInsertionEffect2 = React.useInsertionEffect;
16
21
  var useSyncExternalStore2 = React.useSyncExternalStore;
17
- var useTransition2 = React.useTransition;
18
- var useDeferredValue2 = React.useDeferredValue;
22
+ var use2 = React.use;
23
+ var createContext2 = React.createContext;
24
+ var useContext2 = React.useContext;
25
+
26
+ // src/production.ts
19
27
  var registerVariable = () => {
20
28
  };
21
29
  var unregisterVariable = () => {
@@ -27,18 +35,20 @@ var endEffectTracking = () => {
27
35
  };
28
36
  var printBasisHealthReport = () => {
29
37
  };
30
- var BasisProvider = ({ children }) => {
31
- return React.createElement(React.Fragment, null, children);
38
+ var configureBasis = () => {
32
39
  };
33
40
  export {
34
41
  BasisProvider,
35
42
  beginEffectTracking,
43
+ configureBasis,
36
44
  createContext2 as createContext,
37
45
  endEffectTracking,
38
46
  printBasisHealthReport,
39
47
  recordUpdate,
40
48
  registerVariable,
41
49
  unregisterVariable,
50
+ use2 as use,
51
+ useActionState2 as useActionState,
42
52
  useCallback2 as useCallback,
43
53
  useContext2 as useContext,
44
54
  useDebugValue2 as useDebugValue,
@@ -49,6 +59,7 @@ export {
49
59
  useInsertionEffect2 as useInsertionEffect,
50
60
  useLayoutEffect2 as useLayoutEffect,
51
61
  useMemo2 as useMemo,
62
+ useOptimistic2 as useOptimistic,
52
63
  useReducer2 as useReducer,
53
64
  useRef2 as useRef,
54
65
  useState2 as useState,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/production.ts"],"sourcesContent":["// src/production.ts\n\nimport * as React from 'react';\nimport type { \n DependencyList, \n EffectCallback, \n FC, \n ReactNode, \n Context, \n Reducer, \n Dispatch, \n SetStateAction \n} from 'react';\n\nexport type { DependencyList, EffectCallback, FC, ReactNode, Context, Reducer, Dispatch, SetStateAction };\n\nexport const useState = <T>(initialState: T | (() => T), _label?: string) => \n React.useState(initialState);\n\nexport const useEffect = (effect: EffectCallback, deps?: DependencyList, _label?: string) => \n React.useEffect(effect, deps as DependencyList);\n\nexport const useMemo = <T>(factory: () => T, deps?: DependencyList, _label?: string) => \n React.useMemo(factory, deps as DependencyList);\n\nexport const useCallback = <T extends (...args: any[]) => any>(callback: T, deps: DependencyList, _label?: string) => \n React.useCallback(callback, deps);\n\nexport const useReducer = (reducer: any, initialArg: any, init?: any, _label?: string) => \n React.useReducer(reducer, initialArg, init);\n\nexport const useRef = <T>(initialValue: T, _label?: string) => \n React.useRef(initialValue);\n\nexport const useLayoutEffect = (effect: EffectCallback, deps?: DependencyList, _label?: string) => \n React.useLayoutEffect(effect, deps as DependencyList);\n\nexport const useContext = React.useContext;\nexport const createContext = React.createContext;\nexport const useId = React.useId;\nexport const useDebugValue = React.useDebugValue;\nexport const useImperativeHandle = React.useImperativeHandle;\nexport const useInsertionEffect = React.useInsertionEffect;\nexport const useSyncExternalStore = React.useSyncExternalStore;\nexport const useTransition = React.useTransition;\nexport const useDeferredValue = React.useDeferredValue;\n\nexport const registerVariable = () => {};\nexport const unregisterVariable = () => {};\nexport const recordUpdate = () => true;\nexport const beginEffectTracking = () => {};\nexport const endEffectTracking = () => {};\nexport const printBasisHealthReport = () => {};\n\nexport const BasisProvider: FC<{ children: ReactNode; debug?: boolean }> = ({ children }) => {\n return React.createElement(React.Fragment, null, children);\n};"],"mappings":";AAEA,YAAY,WAAW;AAchB,IAAMA,YAAW,CAAI,cAA6B,WACjD,eAAS,YAAY;AAEtB,IAAMC,aAAY,CAAC,QAAwB,MAAuB,WACjE,gBAAU,QAAQ,IAAsB;AAEzC,IAAMC,WAAU,CAAI,SAAkB,MAAuB,WAC5D,cAAQ,SAAS,IAAsB;AAExC,IAAMC,eAAc,CAAoC,UAAa,MAAsB,WAC1F,kBAAY,UAAU,IAAI;AAE3B,IAAMC,cAAa,CAAC,SAAc,YAAiB,MAAY,WAC9D,iBAAW,SAAS,YAAY,IAAI;AAErC,IAAMC,UAAS,CAAI,cAAiB,WACnC,aAAO,YAAY;AAEpB,IAAMC,mBAAkB,CAAC,QAAwB,MAAuB,WACvE,sBAAgB,QAAQ,IAAsB;AAE/C,IAAMC,cAAmB;AACzB,IAAMC,iBAAsB;AAC5B,IAAMC,SAAc;AACpB,IAAMC,iBAAsB;AAC5B,IAAMC,uBAA4B;AAClC,IAAMC,sBAA2B;AACjC,IAAMC,wBAA6B;AACnC,IAAMC,iBAAsB;AAC5B,IAAMC,oBAAyB;AAE/B,IAAM,mBAAmB,MAAM;AAAC;AAChC,IAAM,qBAAqB,MAAM;AAAC;AAClC,IAAM,eAAe,MAAM;AAC3B,IAAM,sBAAsB,MAAM;AAAC;AACnC,IAAM,oBAAoB,MAAM;AAAC;AACjC,IAAM,yBAAyB,MAAM;AAAC;AAEtC,IAAM,gBAA8D,CAAC,EAAE,SAAS,MAAM;AAC3F,SAAa,oBAAoB,gBAAU,MAAM,QAAQ;AAC3D;","names":["useState","useEffect","useMemo","useCallback","useReducer","useRef","useLayoutEffect","useContext","createContext","useId","useDebugValue","useImperativeHandle","useInsertionEffect","useSyncExternalStore","useTransition","useDeferredValue"]}
1
+ {"version":3,"sources":["../src/production-hooks.ts","../src/production.ts"],"sourcesContent":["// src/production-hooks.ts\n\nimport * as React from 'react';\nimport type { FC, ReactNode, DependencyList, EffectCallback } from 'react';\n\nexport const BasisProvider: FC<{ children: ReactNode; debug?: boolean }> = ({ children }) => {\n return React.createElement(React.Fragment, null, children);\n};\n\nexport const useState = <T>(initialState: T | (() => T), _label?: string) => React.useState(initialState);\nexport const useEffect = (effect: EffectCallback, deps?: DependencyList, _label?: string) => React.useEffect(effect, deps as DependencyList);\nexport const useMemo = <T>(factory: () => T, deps?: DependencyList, _label?: string) => React.useMemo(factory, deps as DependencyList);\nexport const useCallback = <T extends (...args: any[]) => any>(callback: T, deps?: DependencyList, _label?: string) => React.useCallback(callback, deps as DependencyList);\nexport const useReducer = (reducer: any, initArg: any, init?: any, _label?: string) => React.useReducer(reducer, initArg, init);\nexport const useRef = <T>(initialValue: T, _label?: string) => React.useRef(initialValue);\nexport const useLayoutEffect = (effect: EffectCallback, deps?: DependencyList, _label?: string) => React.useLayoutEffect(effect, deps as DependencyList);\nexport const useTransition = (_label?: string) => React.useTransition();\nexport const useDeferredValue = <T>(value: T, _label?: string) => React.useDeferredValue(value);\nexport const useOptimistic = <S, P>(passthrough: S, reducer?: (state: S, payload: P) => S, _label?: string) => (React as any).useOptimistic(passthrough, reducer);\nexport const useActionState = <State, Payload>(action: (state: State, payload: Payload) => Promise<State> | State, initialState: State, permalink?: string, _label?: string) => (React as any).useActionState(action, initialState, permalink);\n\nexport const useId = (_label?: string) => React.useId();\nexport const useDebugValue = React.useDebugValue;\nexport const useImperativeHandle = React.useImperativeHandle;\nexport const useInsertionEffect = React.useInsertionEffect;\nexport const useSyncExternalStore = React.useSyncExternalStore;\nexport const use = (React as any).use;\nexport const createContext = React.createContext;\nexport const useContext = React.useContext;","// src/production.ts\n\nexport * from './production-hooks';\n\nexport const registerVariable = () => { };\nexport const unregisterVariable = () => { };\nexport const recordUpdate = () => true;\nexport const beginEffectTracking = () => { };\nexport const endEffectTracking = () => { };\nexport const printBasisHealthReport = () => { };\nexport const configureBasis = () => { };\n\nexport type { ReactNode, FC } from 'react';"],"mappings":";AAEA,YAAY,WAAW;AAGhB,IAAM,gBAA8D,CAAC,EAAE,SAAS,MAAM;AACzF,SAAa,oBAAoB,gBAAU,MAAM,QAAQ;AAC7D;AAEO,IAAMA,YAAW,CAAI,cAA6B,WAA0B,eAAS,YAAY;AACjG,IAAMC,aAAY,CAAC,QAAwB,MAAuB,WAA0B,gBAAU,QAAQ,IAAsB;AACpI,IAAMC,WAAU,CAAI,SAAkB,MAAuB,WAA0B,cAAQ,SAAS,IAAsB;AAC9H,IAAMC,eAAc,CAAoC,UAAa,MAAuB,WAA0B,kBAAY,UAAU,IAAsB;AAClK,IAAMC,cAAa,CAAC,SAAc,SAAc,MAAY,WAA0B,iBAAW,SAAS,SAAS,IAAI;AACvH,IAAMC,UAAS,CAAI,cAAiB,WAA0B,aAAO,YAAY;AACjF,IAAMC,mBAAkB,CAAC,QAAwB,MAAuB,WAA0B,sBAAgB,QAAQ,IAAsB;AAChJ,IAAMC,iBAAgB,CAAC,WAA0B,oBAAc;AAC/D,IAAMC,oBAAmB,CAAI,OAAU,WAA0B,uBAAiB,KAAK;AACvF,IAAMC,iBAAgB,CAAO,aAAgB,SAAuC,WAAmC,oBAAc,aAAa,OAAO;AACzJ,IAAMC,kBAAiB,CAAiB,QAAoE,cAAqB,WAAoB,WAAmC,qBAAe,QAAQ,cAAc,SAAS;AAEtO,IAAMC,SAAQ,CAAC,WAA0B,YAAM;AAC/C,IAAMC,iBAAsB;AAC5B,IAAMC,uBAA4B;AAClC,IAAMC,sBAA2B;AACjC,IAAMC,wBAA6B;AACnC,IAAMC,OAAqB;AAC3B,IAAMC,iBAAsB;AAC5B,IAAMC,cAAmB;;;ACxBzB,IAAM,mBAAmB,MAAM;AAAE;AACjC,IAAM,qBAAqB,MAAM;AAAE;AACnC,IAAM,eAAe,MAAM;AAC3B,IAAM,sBAAsB,MAAM;AAAE;AACpC,IAAM,oBAAoB,MAAM;AAAE;AAClC,IAAM,yBAAyB,MAAM;AAAE;AACvC,IAAM,iBAAiB,MAAM;AAAE;","names":["useState","useEffect","useMemo","useCallback","useReducer","useRef","useLayoutEffect","useTransition","useDeferredValue","useOptimistic","useActionState","useId","useDebugValue","useImperativeHandle","useInsertionEffect","useSyncExternalStore","use","createContext","useContext"]}
@@ -26,22 +26,12 @@ module.exports = __toCommonJS(vite_plugin_exports);
26
26
  function basis() {
27
27
  return {
28
28
  name: "vite-plugin-react-state-basis",
29
- enforce: "pre",
30
- resolveId(source, importer) {
31
- if (source === "react" || source === "react-dom" || source === "react-dom/client") {
32
- const isLibraryCore = importer && ((importer.includes("react-state-basis/src") || importer.includes("react-state-basis/dist")) && !importer.includes("react-state-basis/example"));
33
- const isYalc = importer && importer.includes(".yalc");
34
- if (isLibraryCore || isYalc) {
35
- return null;
29
+ config() {
30
+ return {
31
+ optimizeDeps: {
32
+ exclude: ["react-state-basis"]
36
33
  }
37
- const mapping = {
38
- "react": "react-state-basis",
39
- "react-dom": "react-state-basis",
40
- "react-dom/client": "react-state-basis/client"
41
- };
42
- return this.resolve(mapping[source], importer, { skipSelf: true });
43
- }
44
- return null;
34
+ };
45
35
  }
46
36
  };
47
37
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/vite-plugin.ts"],"sourcesContent":["// src/vite-plugin.ts\n\nimport type { Plugin } from 'vite';\n\nexport function basis(): Plugin {\n return {\n name: 'vite-plugin-react-state-basis',\n enforce: 'pre',\n\n resolveId(source, importer) {\n if (source === 'react' || source === 'react-dom' || source === 'react-dom/client') {\n \n const isLibraryCore = importer && (\n (importer.includes('react-state-basis/src') || importer.includes('react-state-basis/dist')) &&\n !importer.includes('react-state-basis/example')\n );\n\n const isYalc = importer && importer.includes('.yalc');\n\n if (isLibraryCore || isYalc) {\n return null;\n }\n\n const mapping: Record<string, string> = {\n 'react': 'react-state-basis',\n 'react-dom': 'react-state-basis',\n 'react-dom/client': 'react-state-basis/client'\n };\n\n return this.resolve(mapping[source], importer, { skipSelf: true });\n }\n return null;\n }\n };\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,SAAS,QAAgB;AAC9B,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IAET,UAAU,QAAQ,UAAU;AAC1B,UAAI,WAAW,WAAW,WAAW,eAAe,WAAW,oBAAoB;AAEjF,cAAM,gBAAgB,cACnB,SAAS,SAAS,uBAAuB,KAAK,SAAS,SAAS,wBAAwB,MACzF,CAAC,SAAS,SAAS,2BAA2B;AAGhD,cAAM,SAAS,YAAY,SAAS,SAAS,OAAO;AAEpD,YAAI,iBAAiB,QAAQ;AAC3B,iBAAO;AAAA,QACT;AAEA,cAAM,UAAkC;AAAA,UACtC,SAAS;AAAA,UACT,aAAa;AAAA,UACb,oBAAoB;AAAA,QACtB;AAEA,eAAO,KAAK,QAAQ,QAAQ,MAAM,GAAG,UAAU,EAAE,UAAU,KAAK,CAAC;AAAA,MACnE;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/vite-plugin.ts"],"sourcesContent":["import type { Plugin } from 'vite';\nexport function basis(): Plugin {\n return {\n name: 'vite-plugin-react-state-basis',\n config() {\n return {\n optimizeDeps: {\n exclude: ['react-state-basis']\n }\n };\n }\n };\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACO,SAAS,QAAgB;AAC9B,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AACP,aAAO;AAAA,QACL,cAAc;AAAA,UACZ,SAAS,CAAC,mBAAmB;AAAA,QAC/B;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  basis
3
- } from "./chunk-GEHMQPV4.mjs";
3
+ } from "./chunk-I5ZFRXQP.mjs";
4
4
  export {
5
5
  basis
6
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-state-basis",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "A linear algebra-powered React architectural tool that detects redundant state and synchronization anti-patterns by modeling state transitions as vectors in a basis.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -1,28 +0,0 @@
1
- // src/vite-plugin.ts
2
- function basis() {
3
- return {
4
- name: "vite-plugin-react-state-basis",
5
- enforce: "pre",
6
- resolveId(source, importer) {
7
- if (source === "react" || source === "react-dom" || source === "react-dom/client") {
8
- const isLibraryCore = importer && ((importer.includes("react-state-basis/src") || importer.includes("react-state-basis/dist")) && !importer.includes("react-state-basis/example"));
9
- const isYalc = importer && importer.includes(".yalc");
10
- if (isLibraryCore || isYalc) {
11
- return null;
12
- }
13
- const mapping = {
14
- "react": "react-state-basis",
15
- "react-dom": "react-state-basis",
16
- "react-dom/client": "react-state-basis/client"
17
- };
18
- return this.resolve(mapping[source], importer, { skipSelf: true });
19
- }
20
- return null;
21
- }
22
- };
23
- }
24
-
25
- export {
26
- basis
27
- };
28
- //# sourceMappingURL=chunk-GEHMQPV4.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/vite-plugin.ts"],"sourcesContent":["// src/vite-plugin.ts\n\nimport type { Plugin } from 'vite';\n\nexport function basis(): Plugin {\n return {\n name: 'vite-plugin-react-state-basis',\n enforce: 'pre',\n\n resolveId(source, importer) {\n if (source === 'react' || source === 'react-dom' || source === 'react-dom/client') {\n \n const isLibraryCore = importer && (\n (importer.includes('react-state-basis/src') || importer.includes('react-state-basis/dist')) &&\n !importer.includes('react-state-basis/example')\n );\n\n const isYalc = importer && importer.includes('.yalc');\n\n if (isLibraryCore || isYalc) {\n return null;\n }\n\n const mapping: Record<string, string> = {\n 'react': 'react-state-basis',\n 'react-dom': 'react-state-basis',\n 'react-dom/client': 'react-state-basis/client'\n };\n\n return this.resolve(mapping[source], importer, { skipSelf: true });\n }\n return null;\n }\n };\n}"],"mappings":";AAIO,SAAS,QAAgB;AAC9B,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IAET,UAAU,QAAQ,UAAU;AAC1B,UAAI,WAAW,WAAW,WAAW,eAAe,WAAW,oBAAoB;AAEjF,cAAM,gBAAgB,cACnB,SAAS,SAAS,uBAAuB,KAAK,SAAS,SAAS,wBAAwB,MACzF,CAAC,SAAS,SAAS,2BAA2B;AAGhD,cAAM,SAAS,YAAY,SAAS,SAAS,OAAO;AAEpD,YAAI,iBAAiB,QAAQ;AAC3B,iBAAO;AAAA,QACT;AAEA,cAAM,UAAkC;AAAA,UACtC,SAAS;AAAA,UACT,aAAa;AAAA,UACb,oBAAoB;AAAA,QACtB;AAEA,eAAO,KAAK,QAAQ,QAAQ,MAAM,GAAG,UAAU,EAAE,UAAU,KAAK,CAAC;AAAA,MACnE;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}