@contractspec/lib.presentation-runtime-core 0.0.0-canary-20260113162409
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/LICENSE +21 -0
- package/README.md +67 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/package.json +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Chaman Ventures, SASU
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @contractspec/lib.presentation-runtime-core
|
|
2
|
+
|
|
3
|
+
Website: https://contractspec.io/
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
Core logic for ContractSpec presentation runtimes.
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
To provide the shared, framework-agnostic state management and logic for executing workflows and rendering presentations defined in ContractSpec.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @contractspec/lib.presentation-runtime-core
|
|
16
|
+
# or
|
|
17
|
+
bun add @contractspec/lib.presentation-runtime-core
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Key Concepts
|
|
21
|
+
|
|
22
|
+
- **Workflow State**: Manages the progression of steps in a `WorkflowSpec`.
|
|
23
|
+
- **Step Navigation**: Logic for next/previous/submit actions.
|
|
24
|
+
- **Validation**: Integration with Zod schemas for step validation.
|
|
25
|
+
|
|
26
|
+
## Exports
|
|
27
|
+
|
|
28
|
+
- Types and state machines for workflows.
|
|
29
|
+
- Validation helpers.
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
Typically used internally by `@contractspec/lib.presentation-runtime-react` or `@contractspec/lib.presentation-runtime-react-native`.
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/index.d.ts
|
|
2
|
+
interface ListState<TFilters extends Record<string, unknown>> {
|
|
3
|
+
q: string;
|
|
4
|
+
page: number;
|
|
5
|
+
limit: number;
|
|
6
|
+
sort?: string | null;
|
|
7
|
+
filters: TFilters;
|
|
8
|
+
}
|
|
9
|
+
type ListFetcher<TVars, TItem> = (vars: TVars) => Promise<{
|
|
10
|
+
items: TItem[];
|
|
11
|
+
totalItems?: number;
|
|
12
|
+
totalPages?: number;
|
|
13
|
+
}>;
|
|
14
|
+
interface NextAliasOptions {
|
|
15
|
+
uiKitWeb?: string;
|
|
16
|
+
uiKitNative?: string;
|
|
17
|
+
presentationReact?: string;
|
|
18
|
+
presentationNative?: string;
|
|
19
|
+
}
|
|
20
|
+
declare function withPresentationNextAliases(config: any, opts?: NextAliasOptions): any;
|
|
21
|
+
type MetroAliasOptions = NextAliasOptions & {
|
|
22
|
+
monorepoRoot?: string;
|
|
23
|
+
};
|
|
24
|
+
declare function withPresentationMetroAliases(config: any, opts?: MetroAliasOptions): any;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { ListFetcher, ListState, MetroAliasOptions, NextAliasOptions, withPresentationMetroAliases, withPresentationNextAliases };
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";UAAiB,2BAA2B;EAA3B,CAAA,EAAA,MAAA;EAQL,IAAA,EAAA,MAAA;EACJ,KAAA,EAAA,MAAA;EACc,IAAA,CAAA,EAAA,MAAA,GAAA,IAAA;EAAjB,OAAA,EALM,QAKN;;AAGY,KALL,WAKqB,CAAA,KAAA,EAAA,KAAA,CAAA,GAAA,CAAA,IAAA,EAJzB,KAIyB,EAAA,GAH5B,OAG4B,CAAA;EAOjB,KAAA,EAVM,KAUN,EAAA;EA6BJ,UAAA,CAAA,EAAA,MAAA;EAII,UAAA,CAAA,EAAA,MAAA;;UAxCC,gBAAA;;;;;;iBAOD,2BAAA,qBAGR;KA0BI,iBAAA,GAAoB;;;iBAIhB,4BAAA,qBAGR"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//#region src/index.ts
|
|
2
|
+
function withPresentationNextAliases(config, opts = {}) {
|
|
3
|
+
const uiWeb = opts.uiKitWeb ?? "@contractspec/lib.ui-kit-web";
|
|
4
|
+
const uiNative = opts.uiKitNative ?? "@contractspec/lib.ui-kit";
|
|
5
|
+
const presReact = opts.presentationReact ?? "@contractspec/lib.presentation-runtime-react";
|
|
6
|
+
const presNative = opts.presentationNative ?? "@contractspec/lib.presentation-runtime-react-native";
|
|
7
|
+
config.resolve ??= {};
|
|
8
|
+
config.resolve.alias = {
|
|
9
|
+
...config.resolve.alias || {},
|
|
10
|
+
[uiNative]: uiWeb,
|
|
11
|
+
[presNative]: presReact
|
|
12
|
+
};
|
|
13
|
+
config.resolve.extensions = [
|
|
14
|
+
".web.js",
|
|
15
|
+
".web.jsx",
|
|
16
|
+
".web.ts",
|
|
17
|
+
".web.tsx",
|
|
18
|
+
...config.resolve.extensions || []
|
|
19
|
+
];
|
|
20
|
+
return config;
|
|
21
|
+
}
|
|
22
|
+
function withPresentationMetroAliases(config, opts = {}) {
|
|
23
|
+
const uiWeb = opts.uiKitWeb ?? "@contractspec/lib.ui-kit-web";
|
|
24
|
+
const uiNative = opts.uiKitNative ?? "@contractspec/lib.ui-kit";
|
|
25
|
+
const presReact = opts.presentationReact ?? "@contractspec/lib.presentation-runtime-react";
|
|
26
|
+
const presNative = opts.presentationNative ?? "@contractspec/lib.presentation-runtime-react-native";
|
|
27
|
+
config.resolver ??= {};
|
|
28
|
+
config.resolver.unstable_enablePackageExports = true;
|
|
29
|
+
config.resolver.platforms = [
|
|
30
|
+
"ios",
|
|
31
|
+
"android",
|
|
32
|
+
"native",
|
|
33
|
+
"mobile",
|
|
34
|
+
"web",
|
|
35
|
+
...config.resolver.platforms || []
|
|
36
|
+
];
|
|
37
|
+
const original = config.resolver.resolveRequest;
|
|
38
|
+
config.resolver.resolveRequest = (ctx, moduleName, platform) => {
|
|
39
|
+
if (platform === "ios" || platform === "android" || platform === "native") {
|
|
40
|
+
if (typeof moduleName === "string" && moduleName.startsWith(uiWeb + "/ui")) {
|
|
41
|
+
const mapped = moduleName.replace(uiWeb + "/ui", uiNative + "/ui");
|
|
42
|
+
return (original ?? ctx.resolveRequest)(ctx, mapped, platform);
|
|
43
|
+
}
|
|
44
|
+
if (moduleName === presReact) return (original ?? ctx.resolveRequest)(ctx, presNative, platform);
|
|
45
|
+
}
|
|
46
|
+
return (original ?? ctx.resolveRequest)(ctx, moduleName, platform);
|
|
47
|
+
};
|
|
48
|
+
return config;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
export { withPresentationMetroAliases, withPresentationNextAliases };
|
|
53
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export interface ListState<TFilters extends Record<string, unknown>> {\n q: string;\n page: number;\n limit: number;\n sort?: string | null;\n filters: TFilters;\n}\n\nexport type ListFetcher<TVars, TItem> = (\n vars: TVars\n) => Promise<{ items: TItem[]; totalItems?: number; totalPages?: number }>;\n\n// ---- Framework config helpers (Next / Metro) ----\nexport interface NextAliasOptions {\n uiKitWeb?: string; // default '@contractspec/lib.ui-kit-web'\n uiKitNative?: string; // default '@contractspec/lib.ui-kit'\n presentationReact?: string; // default '@contractspec/lib.presentation-runtime-react'\n presentationNative?: string; // default '@contractspec/lib.presentation-runtime-react-native'\n}\n\nexport function withPresentationNextAliases(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config: any,\n opts: NextAliasOptions = {}\n) {\n const uiWeb = opts.uiKitWeb ?? '@contractspec/lib.ui-kit-web';\n const uiNative = opts.uiKitNative ?? '@contractspec/lib.ui-kit';\n const presReact =\n opts.presentationReact ?? '@contractspec/lib.presentation-runtime-react';\n const presNative =\n opts.presentationNative ??\n '@contractspec/lib.presentation-runtime-react-native';\n\n config.resolve ??= {};\n config.resolve.alias = {\n ...(config.resolve.alias || {}),\n [uiNative]: uiWeb,\n [presNative]: presReact,\n };\n config.resolve.extensions = [\n '.web.js',\n '.web.jsx',\n '.web.ts',\n '.web.tsx',\n ...((config.resolve.extensions as string[]) || []),\n ];\n return config;\n}\n\nexport type MetroAliasOptions = NextAliasOptions & {\n monorepoRoot?: string;\n};\n\nexport function withPresentationMetroAliases(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config: any,\n opts: MetroAliasOptions = {}\n) {\n const uiWeb = opts.uiKitWeb ?? '@contractspec/lib.ui-kit-web';\n const uiNative = opts.uiKitNative ?? '@contractspec/lib.ui-kit';\n const presReact =\n opts.presentationReact ?? '@contractspec/lib.presentation-runtime-react';\n const presNative =\n opts.presentationNative ??\n '@contractspec/lib.presentation-runtime-react-native';\n\n // Prefer package exports resolution\n config.resolver ??= {};\n config.resolver.unstable_enablePackageExports = true;\n\n // Platform resolution ordering\n config.resolver.platforms = [\n 'ios',\n 'android',\n 'native',\n 'mobile',\n 'web',\n ...((config.resolver.platforms as string[]) || []),\n ];\n\n // Map web kit → native at resolver-level\n const original = config.resolver.resolveRequest;\n config.resolver.resolveRequest = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ctx: any,\n moduleName: string,\n platform: string\n ) => {\n if (platform === 'ios' || platform === 'android' || platform === 'native') {\n if (\n typeof moduleName === 'string' &&\n moduleName.startsWith(uiWeb + '/ui')\n ) {\n const mapped = moduleName.replace(uiWeb + '/ui', uiNative + '/ui');\n return (original ?? ctx.resolveRequest)(ctx, mapped, platform);\n }\n if (moduleName === presReact) {\n return (original ?? ctx.resolveRequest)(ctx, presNative, platform);\n }\n }\n return (original ?? ctx.resolveRequest)(ctx, moduleName, platform);\n };\n\n return config;\n}\n"],"mappings":";AAoBA,SAAgB,4BAEd,QACA,OAA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",
|
|
4
|
+
"description": "Core presentation runtime for contract-driven UIs",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"contractspec",
|
|
7
|
+
"presentation",
|
|
8
|
+
"runtime",
|
|
9
|
+
"ui",
|
|
10
|
+
"core",
|
|
11
|
+
"typescript"
|
|
12
|
+
],
|
|
13
|
+
"type": "module",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"scripts": {
|
|
17
|
+
"publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
|
|
18
|
+
"publish:pkg:canary": "bun publish:pkg --tag canary",
|
|
19
|
+
"build": "bun build:bundle && bun build:types",
|
|
20
|
+
"build:bundle": "tsdown",
|
|
21
|
+
"build:types": "tsc --noEmit -p tsconfig.json",
|
|
22
|
+
"clean": "rimraf dist .turbo",
|
|
23
|
+
"dev": "bun run build:bundle --watch",
|
|
24
|
+
"lint": "bun run lint:fix",
|
|
25
|
+
"lint:fix": "eslint src --fix",
|
|
26
|
+
"lint:check": "eslint src"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"typescript": "^5.9.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@contractspec/tool.tsdown": "0.0.0-canary-20260113162409",
|
|
33
|
+
"@contractspec/tool.typescript": "0.0.0-canary-20260113162409",
|
|
34
|
+
"tsdown": "^0.19.0",
|
|
35
|
+
"typescript": "^5.9.3"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist",
|
|
39
|
+
"README.md"
|
|
40
|
+
],
|
|
41
|
+
"exports": {
|
|
42
|
+
".": "./dist/index.js",
|
|
43
|
+
"./*": "./*"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public",
|
|
47
|
+
"exports": {
|
|
48
|
+
".": "./dist/index.js",
|
|
49
|
+
"./metro.cjs": "./src/metro.cjs",
|
|
50
|
+
"./next.mjs": "./src/next.mjs"
|
|
51
|
+
},
|
|
52
|
+
"registry": "https://registry.npmjs.org/"
|
|
53
|
+
},
|
|
54
|
+
"license": "MIT",
|
|
55
|
+
"repository": {
|
|
56
|
+
"type": "git",
|
|
57
|
+
"url": "https://github.com/lssm-tech/contractspec.git",
|
|
58
|
+
"directory": "packages/libs/presentation-runtime-core"
|
|
59
|
+
},
|
|
60
|
+
"homepage": "https://contractspec.io"
|
|
61
|
+
}
|