react-hooks-global-states 15.0.18 → 16.0.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.
package/uniqueId.mjs ADDED
@@ -0,0 +1,51 @@
1
+ // src/uniqueId.ts
2
+ var uniqueId = (() => {
3
+ let $counter = 0;
4
+ const counter = () => {
5
+ if ($counter === Number.MAX_SAFE_INTEGER) $counter = 0;
6
+ return $counter++;
7
+ };
8
+ const getBrandedId = (prefix, base) => {
9
+ var _a;
10
+ if ((_a = globalThis.crypto) == null ? void 0 : _a.randomUUID)
11
+ return (prefix != null ? prefix : "") + globalThis.crypto.randomUUID();
12
+ return (prefix != null ? prefix : "") + Date.now().toString(36) + base.toString(36);
13
+ };
14
+ const $uniqueId = (prefix) => {
15
+ return getBrandedId(prefix, counter());
16
+ };
17
+ $uniqueId.for = (prefix) => {
18
+ const generateBrandedId = () => {
19
+ return getBrandedId(prefix, counter());
20
+ };
21
+ generateBrandedId.is = (value) => {
22
+ return typeof value === "string" && value.startsWith(prefix);
23
+ };
24
+ generateBrandedId.assert = function(value) {
25
+ if (!generateBrandedId.is(value)) {
26
+ throw new Error(
27
+ `The value "${String(value)}" does not match the expected prefix "${String(prefix)}"`
28
+ );
29
+ }
30
+ };
31
+ generateBrandedId.strict = () => {
32
+ const strictBrandGenerator = generateBrandedId;
33
+ return strictBrandGenerator;
34
+ };
35
+ return generateBrandedId;
36
+ };
37
+ $uniqueId.of = () => {
38
+ const generateBrandedId = $uniqueId.for("");
39
+ return generateBrandedId;
40
+ };
41
+ $uniqueId.strict = () => {
42
+ const strictBrandGenerator = $uniqueId;
43
+ return strictBrandGenerator;
44
+ };
45
+ return $uniqueId;
46
+ })();
47
+ var uniqueId_default = uniqueId;
48
+ export {
49
+ uniqueId_default as default,
50
+ uniqueId
51
+ };
package/webpack.config.js DELETED
@@ -1,103 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-require-imports */
2
- const path = require('path');
3
- const TerserPlugin = require('terser-webpack-plugin');
4
-
5
- const individualEntries = {
6
- createContext: './src/createContext.ts',
7
- GlobalStore: './src/GlobalStore.ts',
8
- createGlobalState: './src/createGlobalState.ts',
9
- types: './src/types.ts',
10
- isRecord: './src/isRecord.ts',
11
- shallowCompare: './src/shallowCompare.ts',
12
- throwWrongKeyOnActionCollectionConfig: './src/throwWrongKeyOnActionCollectionConfig.ts',
13
- uniqueId: './src/uniqueId.ts',
14
- actions: './src/actions.ts',
15
- };
16
-
17
- const generateExternalEntryMappings = () => {
18
- const keys = Object.keys(individualEntries);
19
- return keys.reduce((acc, key) => {
20
- acc[`./${key}`] = `./${key}.js`;
21
- return acc;
22
- }, {});
23
- };
24
-
25
- module.exports = {
26
- mode: 'production',
27
- entry: {
28
- bundle: './src/index.ts',
29
- ...individualEntries,
30
- },
31
- externals: {
32
- react: {
33
- commonjs: 'react',
34
- commonjs2: 'react',
35
- amd: 'react',
36
- root: 'React',
37
- },
38
-
39
- 'json-storage-formatter': 'json-storage-formatter',
40
- 'json-storage-formatter/isNil': 'json-storage-formatter/isNil',
41
- 'json-storage-formatter/isNumber': 'json-storage-formatter/isNumber',
42
- 'json-storage-formatter/isBoolean': 'json-storage-formatter/isBoolean',
43
- 'json-storage-formatter/isString': 'json-storage-formatter/isString',
44
- 'json-storage-formatter/isDate': 'json-storage-formatter/isDate',
45
- 'json-storage-formatter/isRegex': 'json-storage-formatter/isRegex',
46
- 'json-storage-formatter/isFunction': 'json-storage-formatter/isFunction',
47
- 'json-storage-formatter/isPrimitive': 'json-storage-formatter/isPrimitive',
48
- 'json-storage-formatter/types': 'json-storage-formatter/types',
49
- 'json-storage-formatter/formatFromStore': 'json-storage-formatter/formatFromStore',
50
- 'json-storage-formatter/formatToStore': 'json-storage-formatter/formatToStore',
51
-
52
- ...generateExternalEntryMappings(),
53
- },
54
- output: {
55
- path: path.resolve(__dirname),
56
- filename: ({ chunk: { name } }) => {
57
- return `${name}.js`;
58
- },
59
- libraryTarget: 'umd',
60
- library: 'react-hooks-global-states',
61
- globalObject: 'this',
62
- },
63
- resolve: {
64
- extensions: ['.ts', '.js'],
65
- },
66
- module: {
67
- rules: [
68
- {
69
- test: /\.ts$/,
70
- use: 'ts-loader',
71
- exclude: /node_modules/,
72
- },
73
- ],
74
- },
75
- optimization: {
76
- minimize: true,
77
- minimizer: [
78
- new TerserPlugin({
79
- extractComments: false,
80
- terserOptions: {
81
- compress: {
82
- passes: 5,
83
- drop_console: true,
84
- drop_debugger: true,
85
- keep_fargs: false,
86
- keep_infinity: true,
87
- reduce_funcs: true,
88
- reduce_vars: true,
89
- keep_fnames: false,
90
- toplevel: true,
91
- },
92
- mangle: {
93
- toplevel: true,
94
- properties: false,
95
- },
96
- format: {
97
- comments: false,
98
- },
99
- },
100
- }),
101
- ],
102
- },
103
- };