@biglogic/rgs 3.1.0 → 3.2.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.
Files changed (77) hide show
  1. package/README.md +14 -0
  2. package/advanced.js +1 -1
  3. package/index.js +1 -1
  4. package/package.json +8 -3
  5. package/rgs-extension.vsix +0 -0
  6. package/core/advanced.js +0 -4
  7. package/core/async.js +0 -40
  8. package/core/hooks.js +0 -52
  9. package/core/security.js +0 -124
  10. package/core/store.js +0 -595
  11. package/core/types.js +0 -5
  12. package/core/utils.js +0 -72
  13. package/examples/README.md +0 -41
  14. package/examples/async-data-fetch/UserLoader.d.ts +0 -12
  15. package/examples/async-data-fetch/UserLoader.js +0 -10
  16. package/examples/async-data-fetch/UserLoader.ts +0 -30
  17. package/examples/basic-counter/CounterComponent.d.ts +0 -2
  18. package/examples/basic-counter/CounterComponent.js +0 -7
  19. package/examples/basic-counter/CounterComponent.tsx +0 -22
  20. package/examples/basic-counter/CounterStore.d.ts +0 -7
  21. package/examples/basic-counter/CounterStore.js +0 -13
  22. package/examples/basic-counter/CounterStore.ts +0 -25
  23. package/examples/big-data-indexeddb/BigDataStore.d.ts +0 -10
  24. package/examples/big-data-indexeddb/BigDataStore.js +0 -32
  25. package/examples/big-data-indexeddb/BigDataStore.ts +0 -60
  26. package/examples/global-theme/ThemeManager.d.ts +0 -7
  27. package/examples/global-theme/ThemeManager.js +0 -13
  28. package/examples/global-theme/ThemeManager.ts +0 -32
  29. package/examples/hybrid-cloud-sync/HybridStore.d.ts +0 -19
  30. package/examples/hybrid-cloud-sync/HybridStore.js +0 -44
  31. package/examples/hybrid-cloud-sync/HybridStore.ts +0 -78
  32. package/examples/persistent-cart/CartStore.d.ts +0 -13
  33. package/examples/persistent-cart/CartStore.js +0 -23
  34. package/examples/persistent-cart/CartStore.ts +0 -41
  35. package/examples/rbac-dashboard/DashboardStore.d.ts +0 -47
  36. package/examples/rbac-dashboard/DashboardStore.js +0 -31
  37. package/examples/rbac-dashboard/DashboardStore.ts +0 -46
  38. package/examples/secure-auth/AuthStore.d.ts +0 -14
  39. package/examples/secure-auth/AuthStore.js +0 -20
  40. package/examples/secure-auth/AuthStore.ts +0 -36
  41. package/examples/security-best-practices/SecurityStore.d.ts +0 -22
  42. package/examples/security-best-practices/SecurityStore.js +0 -30
  43. package/examples/security-best-practices/SecurityStore.ts +0 -75
  44. package/examples/stress-tests/StressStore.d.ts +0 -41
  45. package/examples/stress-tests/StressStore.js +0 -41
  46. package/examples/stress-tests/StressStore.ts +0 -61
  47. package/examples/super-easy/EasyStore.d.ts +0 -44
  48. package/examples/super-easy/EasyStore.js +0 -24
  49. package/examples/super-easy/EasyStore.ts +0 -61
  50. package/examples/undo-redo-editor/EditorStore.d.ts +0 -9
  51. package/examples/undo-redo-editor/EditorStore.js +0 -13
  52. package/examples/undo-redo-editor/EditorStore.ts +0 -28
  53. package/markdown/SUMMARY.md +0 -59
  54. package/markdown/api.md +0 -381
  55. package/markdown/chapters/01-philosophy.md +0 -54
  56. package/markdown/chapters/02-getting-started.md +0 -68
  57. package/markdown/chapters/03-the-magnetar-way.md +0 -69
  58. package/markdown/chapters/04-persistence-and-safety.md +0 -125
  59. package/markdown/chapters/05-plugin-sdk.md +0 -290
  60. package/markdown/chapters/05-plugins-and-extensibility.md +0 -190
  61. package/markdown/chapters/06-case-studies.md +0 -69
  62. package/markdown/chapters/07-faq.md +0 -53
  63. package/markdown/chapters/08-migration-guide.md +0 -253
  64. package/markdown/chapters/09-security-architecture.md +0 -40
  65. package/plugins/index.js +0 -34
  66. package/plugins/official/analytics.plugin.js +0 -19
  67. package/plugins/official/cloud-sync.plugin.js +0 -117
  68. package/plugins/official/debug.plugin.js +0 -62
  69. package/plugins/official/devtools.plugin.js +0 -28
  70. package/plugins/official/guard.plugin.js +0 -15
  71. package/plugins/official/immer.plugin.js +0 -10
  72. package/plugins/official/indexeddb.plugin.js +0 -102
  73. package/plugins/official/schema.plugin.js +0 -16
  74. package/plugins/official/snapshot.plugin.js +0 -27
  75. package/plugins/official/sync.plugin.js +0 -37
  76. package/plugins/official/undo-redo.plugin.js +0 -61
  77. package/tsconfig.tsbuildinfo +0 -1
@@ -1,16 +0,0 @@
1
- export const schemaPlugin = (schemas) => ({
2
- name: 'gstate-schema',
3
- hooks: {
4
- onSet: ({ key, value }) => {
5
- if (!key)
6
- return;
7
- const validator = schemas[key];
8
- if (validator) {
9
- const result = validator(value);
10
- if (result !== true) {
11
- throw new Error(`[Schema Error] Validation failed for key "${key}": ${result === false ? 'Invalid type' : result}`);
12
- }
13
- }
14
- }
15
- }
16
- });
@@ -1,27 +0,0 @@
1
- export const snapshotPlugin = () => {
2
- const _snapshots = new Map();
3
- return {
4
- name: 'gstate-snapshot',
5
- hooks: {
6
- onInstall: ({ store }) => {
7
- store._registerMethod('snapshot', 'takeSnapshot', ((name) => {
8
- _snapshots.set(name, store.list());
9
- }));
10
- store._registerMethod('snapshot', 'restoreSnapshot', ((name) => {
11
- const snap = _snapshots.get(name);
12
- if (!snap)
13
- return false;
14
- store.transaction(() => {
15
- Object.entries(snap).forEach(([k, v]) => {
16
- store.set(k, v);
17
- });
18
- });
19
- return true;
20
- }));
21
- store._registerMethod('snapshot', 'listSnapshots', (() => Array.from(_snapshots.keys())));
22
- store._registerMethod('snapshot', 'deleteSnapshot', ((name) => _snapshots.delete(name)));
23
- store._registerMethod('snapshot', 'clearSnapshots', (() => _snapshots.clear()));
24
- }
25
- }
26
- };
27
- };
@@ -1,37 +0,0 @@
1
- export const syncPlugin = (options) => {
2
- const _channel = new BroadcastChannel(options?.channelName || 'gstate_sync');
3
- let _isSyncing = false;
4
- return {
5
- name: 'gstate-sync',
6
- hooks: {
7
- onInstall: ({ store }) => {
8
- _channel.onmessage = (event) => {
9
- const { key, value, action } = event.data;
10
- if (!key)
11
- return;
12
- _isSyncing = true;
13
- if (action === 'REMOVE') {
14
- store.remove(key);
15
- }
16
- else {
17
- store.set(key, value);
18
- }
19
- _isSyncing = false;
20
- };
21
- },
22
- onSet: ({ key, value }) => {
23
- if (!key || _isSyncing)
24
- return;
25
- _channel.postMessage({ key, value, action: 'SET' });
26
- },
27
- onRemove: ({ key }) => {
28
- if (!key || _isSyncing)
29
- return;
30
- _channel.postMessage({ key, action: 'REMOVE' });
31
- },
32
- onDestroy: () => {
33
- _channel.close();
34
- }
35
- }
36
- };
37
- };
@@ -1,61 +0,0 @@
1
- export const undoRedoPlugin = (options) => {
2
- let _history = [];
3
- let _cursor = -1;
4
- let _isRestoring = false;
5
- const _limit = options?.limit || 50;
6
- return {
7
- name: 'gstate-undo-redo',
8
- hooks: {
9
- onInstall: ({ store }) => {
10
- _history.push(store.list());
11
- _cursor = 0;
12
- store._registerMethod('undoRedo', 'undo', () => {
13
- if (_cursor > 0) {
14
- _isRestoring = true;
15
- _cursor--;
16
- const snapshot = _history[_cursor];
17
- if (!snapshot)
18
- return false;
19
- Object.entries(snapshot).forEach(([k, v]) => {
20
- store._setSilently(k, v);
21
- });
22
- _isRestoring = false;
23
- return true;
24
- }
25
- return false;
26
- });
27
- store._registerMethod('undoRedo', 'redo', () => {
28
- if (_cursor < _history.length - 1) {
29
- _isRestoring = true;
30
- _cursor++;
31
- const snapshot = _history[_cursor];
32
- if (!snapshot)
33
- return false;
34
- Object.entries(snapshot).forEach(([k, v]) => {
35
- store._setSilently(k, v);
36
- });
37
- _isRestoring = false;
38
- return true;
39
- }
40
- return false;
41
- });
42
- store._registerMethod('undoRedo', 'canUndo', () => _cursor > 0);
43
- store._registerMethod('undoRedo', 'canRedo', () => _cursor < _history.length - 1);
44
- },
45
- onSet: ({ store }) => {
46
- if (_isRestoring)
47
- return;
48
- if (_cursor < _history.length - 1) {
49
- _history = _history.slice(0, _cursor + 1);
50
- }
51
- _history.push(store.list());
52
- if (_history.length > _limit) {
53
- _history.shift();
54
- }
55
- else {
56
- _cursor++;
57
- }
58
- }
59
- }
60
- };
61
- };
@@ -1 +0,0 @@
1
- {"root":["../advanced.ts","../index.ts","../core/advanced.ts","../core/async.ts","../core/hooks.ts","../core/security.ts","../core/store.ts","../core/types.ts","../core/utils.ts","../examples/async-data-fetch/userloader.ts","../examples/basic-counter/counterstore.ts","../examples/big-data-indexeddb/bigdatastore.ts","../examples/global-theme/thememanager.ts","../examples/hybrid-cloud-sync/hybridstore.ts","../examples/persistent-cart/cartstore.ts","../examples/rbac-dashboard/dashboardstore.ts","../examples/secure-auth/authstore.ts","../examples/security-best-practices/securitystore.ts","../examples/stress-tests/stressstore.ts","../examples/super-easy/easystore.ts","../examples/undo-redo-editor/editorstore.ts","../plugins/index.ts","../plugins/official/analytics.plugin.ts","../plugins/official/cloud-sync.plugin.ts","../plugins/official/debug.plugin.ts","../plugins/official/devtools.plugin.ts","../plugins/official/guard.plugin.ts","../plugins/official/immer.plugin.ts","../plugins/official/indexeddb.plugin.ts","../plugins/official/schema.plugin.ts","../plugins/official/snapshot.plugin.ts","../plugins/official/sync.plugin.ts","../plugins/official/undo-redo.plugin.ts","../examples/basic-counter/countercomponent.tsx"],"version":"5.9.3"}