@logixjs/react 0.1.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/README.md +64 -0
- package/dist/Hooks.cjs +2194 -0
- package/dist/Hooks.d.cts +77 -0
- package/dist/Hooks.d.ts +77 -0
- package/dist/Hooks.js +27 -0
- package/dist/ModuleRef-wZSQ3Wwo.d.cts +73 -0
- package/dist/ModuleRef-wZSQ3Wwo.d.ts +73 -0
- package/dist/ModuleScope.cjs +2695 -0
- package/dist/ModuleScope.d.cts +62 -0
- package/dist/ModuleScope.d.ts +62 -0
- package/dist/ModuleScope.js +9 -0
- package/dist/Platform.cjs +60 -0
- package/dist/Platform.d.cts +6 -0
- package/dist/Platform.d.ts +6 -0
- package/dist/Platform.js +6 -0
- package/dist/ReactPlatform.cjs +2813 -0
- package/dist/ReactPlatform.d.cts +40 -0
- package/dist/ReactPlatform.d.ts +40 -0
- package/dist/ReactPlatform.js +11 -0
- package/dist/RuntimeProvider.cjs +1618 -0
- package/dist/RuntimeProvider.d.cts +66 -0
- package/dist/RuntimeProvider.d.ts +66 -0
- package/dist/RuntimeProvider.js +8 -0
- package/dist/chunk-2WFULYPJ.js +856 -0
- package/dist/chunk-4G7H66OY.js +54 -0
- package/dist/chunk-G5MRIFKK.js +95 -0
- package/dist/chunk-JXAJTWSZ.js +773 -0
- package/dist/chunk-PYWHL7TA.js +351 -0
- package/dist/chunk-UFFCJGSZ.js +981 -0
- package/dist/chunk-VFWWMK67.js +0 -0
- package/dist/chunk-ZANGOPUQ.js +34 -0
- package/dist/global.d.cjs +1 -0
- package/dist/global.d.d.cts +9 -0
- package/dist/global.d.d.ts +9 -0
- package/dist/global.d.js +0 -0
- package/dist/index.cjs +3118 -0
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +44 -0
- package/dist/useDispatch-BnzYVkRE.d.ts +81 -0
- package/dist/useDispatch-CnO5-66H.d.cts +81 -0
- package/package.json +58 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import * as Logix from '@logixjs/core';
|
|
3
|
+
import { c as ModuleRef, b as ModuleDispatchersOfShape } from './ModuleRef-wZSQ3Wwo.cjs';
|
|
4
|
+
|
|
5
|
+
type ModuleScopeOptions = {
|
|
6
|
+
readonly deps?: React.DependencyList;
|
|
7
|
+
/**
|
|
8
|
+
* scopeId: stable identifier for this Scope (domain boundary id).
|
|
9
|
+
*
|
|
10
|
+
* Typical: route:${routeId} / route:${routeId}:tab:${tabId}
|
|
11
|
+
*
|
|
12
|
+
* - Same scopeId reuses the same Host instance (and its imported child modules).
|
|
13
|
+
* - Changing scopeId creates a new isolated instance.
|
|
14
|
+
*/
|
|
15
|
+
readonly scopeId?: string;
|
|
16
|
+
readonly suspend?: false | undefined;
|
|
17
|
+
readonly initTimeoutMs?: number;
|
|
18
|
+
readonly gcTime?: number;
|
|
19
|
+
readonly label?: string;
|
|
20
|
+
} | {
|
|
21
|
+
readonly deps?: React.DependencyList;
|
|
22
|
+
readonly scopeId: string;
|
|
23
|
+
readonly suspend: true;
|
|
24
|
+
readonly initTimeoutMs?: number;
|
|
25
|
+
readonly gcTime?: number;
|
|
26
|
+
readonly label?: string;
|
|
27
|
+
};
|
|
28
|
+
type ModuleScope<Ref> = {
|
|
29
|
+
readonly Provider: React.FC<{
|
|
30
|
+
readonly children: React.ReactNode;
|
|
31
|
+
readonly options?: ModuleScopeOptions;
|
|
32
|
+
}>;
|
|
33
|
+
readonly use: () => Ref;
|
|
34
|
+
/**
|
|
35
|
+
* useImported: sugar for the route Host(imports) use case.
|
|
36
|
+
*
|
|
37
|
+
* Equivalent to:
|
|
38
|
+
* - const host = scope.use()
|
|
39
|
+
* - const child = host.imports.get(Child.tag)
|
|
40
|
+
*/
|
|
41
|
+
readonly useImported: <Id extends string, Sh extends Logix.AnyModuleShape>(module: Logix.ModuleTagType<Id, Sh>) => ModuleRef<Logix.StateOf<Sh>, Logix.ActionOf<Sh>, keyof Sh['actionMap'] & string, Logix.ModuleTagType<Id, Sh>, ModuleDispatchersOfShape<Sh>>;
|
|
42
|
+
readonly Context: React.Context<Ref | null>;
|
|
43
|
+
/**
|
|
44
|
+
* Bridge: reuse the same scope across React subtrees / separate roots.
|
|
45
|
+
*
|
|
46
|
+
* - Precondition: within the same runtime tree, some Provider (typically a route/page boundary)
|
|
47
|
+
* has already registered the scope with a stable scopeId.
|
|
48
|
+
* - Behavior: retrieves the registered runtime + module runtime from ScopeRegistry and re-provides them in this subtree.
|
|
49
|
+
*/
|
|
50
|
+
readonly Bridge: React.FC<{
|
|
51
|
+
readonly scopeId: string;
|
|
52
|
+
readonly children: React.ReactNode;
|
|
53
|
+
}>;
|
|
54
|
+
};
|
|
55
|
+
declare const ModuleScope: {
|
|
56
|
+
readonly make: {
|
|
57
|
+
<Id extends string, Sh extends Logix.AnyModuleShape, R = never>(handle: Logix.ModuleImpl<Id, Sh, R>, defaults?: ModuleScopeOptions): ModuleScope<ModuleRef<Logix.StateOf<Sh>, Logix.ActionOf<Sh>>>;
|
|
58
|
+
<Id extends string, Sh extends Logix.AnyModuleShape, Ext extends object, R = never>(handle: Logix.Module.Module<Id, Sh, Ext, R>, defaults?: ModuleScopeOptions): ModuleScope<ModuleRef<Logix.StateOf<Sh>, Logix.ActionOf<Sh>> & Ext>;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export { ModuleScope, type ModuleScopeOptions };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import * as Logix from '@logixjs/core';
|
|
3
|
+
import { c as ModuleRef, b as ModuleDispatchersOfShape } from './ModuleRef-wZSQ3Wwo.js';
|
|
4
|
+
|
|
5
|
+
type ModuleScopeOptions = {
|
|
6
|
+
readonly deps?: React.DependencyList;
|
|
7
|
+
/**
|
|
8
|
+
* scopeId: stable identifier for this Scope (domain boundary id).
|
|
9
|
+
*
|
|
10
|
+
* Typical: route:${routeId} / route:${routeId}:tab:${tabId}
|
|
11
|
+
*
|
|
12
|
+
* - Same scopeId reuses the same Host instance (and its imported child modules).
|
|
13
|
+
* - Changing scopeId creates a new isolated instance.
|
|
14
|
+
*/
|
|
15
|
+
readonly scopeId?: string;
|
|
16
|
+
readonly suspend?: false | undefined;
|
|
17
|
+
readonly initTimeoutMs?: number;
|
|
18
|
+
readonly gcTime?: number;
|
|
19
|
+
readonly label?: string;
|
|
20
|
+
} | {
|
|
21
|
+
readonly deps?: React.DependencyList;
|
|
22
|
+
readonly scopeId: string;
|
|
23
|
+
readonly suspend: true;
|
|
24
|
+
readonly initTimeoutMs?: number;
|
|
25
|
+
readonly gcTime?: number;
|
|
26
|
+
readonly label?: string;
|
|
27
|
+
};
|
|
28
|
+
type ModuleScope<Ref> = {
|
|
29
|
+
readonly Provider: React.FC<{
|
|
30
|
+
readonly children: React.ReactNode;
|
|
31
|
+
readonly options?: ModuleScopeOptions;
|
|
32
|
+
}>;
|
|
33
|
+
readonly use: () => Ref;
|
|
34
|
+
/**
|
|
35
|
+
* useImported: sugar for the route Host(imports) use case.
|
|
36
|
+
*
|
|
37
|
+
* Equivalent to:
|
|
38
|
+
* - const host = scope.use()
|
|
39
|
+
* - const child = host.imports.get(Child.tag)
|
|
40
|
+
*/
|
|
41
|
+
readonly useImported: <Id extends string, Sh extends Logix.AnyModuleShape>(module: Logix.ModuleTagType<Id, Sh>) => ModuleRef<Logix.StateOf<Sh>, Logix.ActionOf<Sh>, keyof Sh['actionMap'] & string, Logix.ModuleTagType<Id, Sh>, ModuleDispatchersOfShape<Sh>>;
|
|
42
|
+
readonly Context: React.Context<Ref | null>;
|
|
43
|
+
/**
|
|
44
|
+
* Bridge: reuse the same scope across React subtrees / separate roots.
|
|
45
|
+
*
|
|
46
|
+
* - Precondition: within the same runtime tree, some Provider (typically a route/page boundary)
|
|
47
|
+
* has already registered the scope with a stable scopeId.
|
|
48
|
+
* - Behavior: retrieves the registered runtime + module runtime from ScopeRegistry and re-provides them in this subtree.
|
|
49
|
+
*/
|
|
50
|
+
readonly Bridge: React.FC<{
|
|
51
|
+
readonly scopeId: string;
|
|
52
|
+
readonly children: React.ReactNode;
|
|
53
|
+
}>;
|
|
54
|
+
};
|
|
55
|
+
declare const ModuleScope: {
|
|
56
|
+
readonly make: {
|
|
57
|
+
<Id extends string, Sh extends Logix.AnyModuleShape, R = never>(handle: Logix.ModuleImpl<Id, Sh, R>, defaults?: ModuleScopeOptions): ModuleScope<ModuleRef<Logix.StateOf<Sh>, Logix.ActionOf<Sh>>>;
|
|
58
|
+
<Id extends string, Sh extends Logix.AnyModuleShape, Ext extends object, R = never>(handle: Logix.Module.Module<Id, Sh, Ext, R>, defaults?: ModuleScopeOptions): ModuleScope<ModuleRef<Logix.StateOf<Sh>, Logix.ActionOf<Sh>> & Ext>;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export { ModuleScope, type ModuleScopeOptions };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/Platform.ts
|
|
21
|
+
var Platform_exports = {};
|
|
22
|
+
__export(Platform_exports, {
|
|
23
|
+
ReactPlatformLayer: () => ReactPlatformLayer
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(Platform_exports);
|
|
26
|
+
|
|
27
|
+
// src/internal/platform/ReactPlatformLayer.ts
|
|
28
|
+
var import_effect = require("effect");
|
|
29
|
+
var import_core = require("@logixjs/core");
|
|
30
|
+
var ReactPlatformImpl = class {
|
|
31
|
+
constructor(suspendRef, resumeRef, resetRef) {
|
|
32
|
+
this.suspendRef = suspendRef;
|
|
33
|
+
this.resumeRef = resumeRef;
|
|
34
|
+
this.resetRef = resetRef;
|
|
35
|
+
this.lifecycle = {
|
|
36
|
+
onSuspend: (eff) => import_effect.Ref.update(this.suspendRef, (list) => [...list, eff]).pipe(import_effect.Effect.asVoid),
|
|
37
|
+
onResume: (eff) => import_effect.Ref.update(this.resumeRef, (list) => [...list, eff]).pipe(import_effect.Effect.asVoid),
|
|
38
|
+
onReset: (eff) => import_effect.Ref.update(this.resetRef, (list) => [...list, eff]).pipe(import_effect.Effect.asVoid)
|
|
39
|
+
};
|
|
40
|
+
// The emit* methods are not part of the official Logic.Platform interface; they are for host/test use only.
|
|
41
|
+
// After retrieving the instance via `Effect.service(Logic.Platform)`, call them via `any`.
|
|
42
|
+
this.emitSuspend = () => import_effect.Ref.get(this.suspendRef).pipe(import_effect.Effect.flatMap((effects) => import_effect.Effect.forEach(effects, (eff) => eff, { discard: true })));
|
|
43
|
+
this.emitResume = () => import_effect.Ref.get(this.resumeRef).pipe(import_effect.Effect.flatMap((effects) => import_effect.Effect.forEach(effects, (eff) => eff, { discard: true })));
|
|
44
|
+
this.emitReset = () => import_effect.Ref.get(this.resetRef).pipe(import_effect.Effect.flatMap((effects) => import_effect.Effect.forEach(effects, (eff) => eff, { discard: true })));
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var makeReactPlatform = import_effect.Effect.gen(function* () {
|
|
48
|
+
const suspendRef = yield* import_effect.Ref.make([]);
|
|
49
|
+
const resumeRef = yield* import_effect.Ref.make([]);
|
|
50
|
+
const resetRef = yield* import_effect.Ref.make([]);
|
|
51
|
+
return new ReactPlatformImpl(suspendRef, resumeRef, resetRef);
|
|
52
|
+
});
|
|
53
|
+
var ReactPlatformLayer = import_effect.Layer.scoped(
|
|
54
|
+
import_core.Platform.tag,
|
|
55
|
+
makeReactPlatform
|
|
56
|
+
);
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
ReactPlatformLayer
|
|
60
|
+
});
|