@blac/react 0.0.15 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blac-react.esm.js +4 -13
- package/dist/blac-react.esm.js.map +1 -1
- package/dist/blac-react.js +4 -13
- package/dist/blac-react.js.map +1 -1
- package/package.json +7 -11
- package/readme.md +4 -4
package/dist/blac-react.esm.js
CHANGED
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import { Blac } from 'blac';
|
|
2
2
|
import React, { createContext, useMemo, useContext, useSyncExternalStore } from 'react';
|
|
3
3
|
|
|
4
|
-
// import { BlocConstructor } from "blac";
|
|
5
|
-
// export interface ProviderItem {
|
|
6
|
-
// id: string;
|
|
7
|
-
// parent?: string;
|
|
8
|
-
// bloc: BlocBase<any>;
|
|
9
|
-
// }
|
|
10
|
-
// interface ProviderOptions<B> {
|
|
11
|
-
// bloc: BlocConstructor<B>;
|
|
12
|
-
// debug?: boolean;
|
|
13
|
-
// }
|
|
14
4
|
class BlacReact {
|
|
15
5
|
static pluginKey = "blacReact";
|
|
16
6
|
blac;
|
|
@@ -26,9 +16,10 @@ class BlacReact {
|
|
|
26
16
|
}
|
|
27
17
|
}
|
|
28
18
|
static getInstance(throwError = true) {
|
|
29
|
-
const blac = globalThis.blac;
|
|
19
|
+
// const blac = (globalThis as any).blac;
|
|
20
|
+
const blac = BlacContext._currentValue;
|
|
30
21
|
if (!blac) {
|
|
31
|
-
throw new Error("BlacReact: blac instance not found");
|
|
22
|
+
throw new Error("BlacReact: blac instance not found, the <BlacApp> provider component might be missing");
|
|
32
23
|
}
|
|
33
24
|
const blacReact = blac.getPluginKey(BlacReact.pluginKey);
|
|
34
25
|
if (!blacReact) {
|
|
@@ -37,7 +28,7 @@ class BlacReact {
|
|
|
37
28
|
return blacReact;
|
|
38
29
|
}
|
|
39
30
|
setup() {
|
|
40
|
-
globalThis.blac = this.blac;
|
|
31
|
+
// (globalThis as any).blac = this.blac;
|
|
41
32
|
this.blac.addPluginKey(BlacReact.pluginKey, this);
|
|
42
33
|
}
|
|
43
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blac-react.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"blac-react.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/blac-react.js
CHANGED
|
@@ -3,16 +3,6 @@
|
|
|
3
3
|
var blac = require('blac');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
|
|
6
|
-
// import { BlocConstructor } from "blac";
|
|
7
|
-
// export interface ProviderItem {
|
|
8
|
-
// id: string;
|
|
9
|
-
// parent?: string;
|
|
10
|
-
// bloc: BlocBase<any>;
|
|
11
|
-
// }
|
|
12
|
-
// interface ProviderOptions<B> {
|
|
13
|
-
// bloc: BlocConstructor<B>;
|
|
14
|
-
// debug?: boolean;
|
|
15
|
-
// }
|
|
16
6
|
class BlacReact {
|
|
17
7
|
static pluginKey = "blacReact";
|
|
18
8
|
blac;
|
|
@@ -28,9 +18,10 @@ class BlacReact {
|
|
|
28
18
|
}
|
|
29
19
|
}
|
|
30
20
|
static getInstance(throwError = true) {
|
|
31
|
-
const blac = globalThis.blac;
|
|
21
|
+
// const blac = (globalThis as any).blac;
|
|
22
|
+
const blac = BlacContext._currentValue;
|
|
32
23
|
if (!blac) {
|
|
33
|
-
throw new Error("BlacReact: blac instance not found");
|
|
24
|
+
throw new Error("BlacReact: blac instance not found, the <BlacApp> provider component might be missing");
|
|
34
25
|
}
|
|
35
26
|
const blacReact = blac.getPluginKey(BlacReact.pluginKey);
|
|
36
27
|
if (!blacReact) {
|
|
@@ -39,7 +30,7 @@ class BlacReact {
|
|
|
39
30
|
return blacReact;
|
|
40
31
|
}
|
|
41
32
|
setup() {
|
|
42
|
-
globalThis.blac = this.blac;
|
|
33
|
+
// (globalThis as any).blac = this.blac;
|
|
43
34
|
this.blac.addPluginKey(BlacReact.pluginKey, this);
|
|
44
35
|
}
|
|
45
36
|
}
|
package/dist/blac-react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blac-react.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"blac-react.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blac/react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/blac-react.js",
|
|
6
6
|
"module": "dist/blac-react.esm.js",
|
|
7
7
|
"typings": "dist/blac-react.d.ts",
|
|
8
|
-
"type": "module",
|
|
9
8
|
"keywords": [
|
|
10
9
|
"react",
|
|
11
10
|
"typescript",
|
|
@@ -17,26 +16,23 @@
|
|
|
17
16
|
"bloc-pattern"
|
|
18
17
|
],
|
|
19
18
|
"scripts": {
|
|
20
|
-
"dev": "vite",
|
|
21
|
-
"build:demo": "vite build",
|
|
22
19
|
"build": "rollup -c rollup.config.lib.js",
|
|
23
20
|
"prettier": "prettier --write ./src",
|
|
24
|
-
"test": "vitest run"
|
|
25
|
-
"test:watch": "vitest --watch",
|
|
26
|
-
"coverage": "vitest run --coverage"
|
|
21
|
+
"test": "vitest run"
|
|
27
22
|
},
|
|
28
23
|
"dependencies": {
|
|
29
24
|
"blac": "*"
|
|
30
25
|
},
|
|
31
26
|
"devDependencies": {
|
|
32
|
-
"@types/react": "^18.2.
|
|
27
|
+
"@types/react": "^18.2.18",
|
|
33
28
|
"@types/react-dom": "^18.2.7",
|
|
34
29
|
"@types/react-highlight": "^0.12.5",
|
|
35
|
-
"@vitejs/plugin-react": "^4.0.
|
|
30
|
+
"@vitejs/plugin-react": "^4.0.4",
|
|
31
|
+
"highlight.js": "^11.8.0",
|
|
36
32
|
"react": "^18.2.0",
|
|
37
33
|
"react-dom": "^18.2.0",
|
|
38
34
|
"react-highlight": "^0.15.0",
|
|
39
|
-
"vite": "^4.4.
|
|
40
|
-
"vitest": "^0.
|
|
35
|
+
"vite": "^4.4.8",
|
|
36
|
+
"vitest": "^0.34.1"
|
|
41
37
|
}
|
|
42
38
|
}
|
package/readme.md
CHANGED
|
@@ -10,7 +10,7 @@ npm install blac-react
|
|
|
10
10
|
|
|
11
11
|
## Examples
|
|
12
12
|
|
|
13
|
-
- [Counter with Bloc](ui/examples/CounterWithBloc.tsx)
|
|
14
|
-
- [Counter with Cubit](ui/examples/CounterWithCubit.tsx)
|
|
15
|
-
- [Counter with Global State](ui/examples/CounterWithCubitGlobal.tsx)
|
|
16
|
-
- [Counters with Local State](ui/examples/CounterLocalDemo.tsx)
|
|
13
|
+
- [Counter with Bloc](../../apps/react-demo/ui/examples/CounterWithBloc.tsx)
|
|
14
|
+
- [Counter with Cubit](../../apps/react-demo/ui/examples/CounterWithCubit.tsx)
|
|
15
|
+
- [Counter with Global State](../../apps/react-demo/ui/examples/CounterWithCubitGlobal.tsx)
|
|
16
|
+
- [Counters with Local State](../../apps/react-demo/ui/examples/CounterLocalDemo.tsx)
|