@syncropel/projections 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/CHANGELOG.md +33 -0
- package/LICENSE +201 -0
- package/README.md +136 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/markdown.d.ts +50 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +315 -0
- package/dist/markdown.js.map +1 -0
- package/dist/schema.d.ts +258 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +32 -0
- package/dist/schema.js.map +1 -0
- package/dist/validators.d.ts +45 -0
- package/dist/validators.d.ts.map +1 -0
- package/dist/validators.js +312 -0
- package/dist/validators.js.map +1 -0
- package/package.json +57 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@syncropel/projections` are documented here. Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); this project uses [SemVer](https://semver.org/spec/v2.0.0.html).
|
|
4
|
+
|
|
5
|
+
## [0.1.0] — 2026-04-20
|
|
6
|
+
|
|
7
|
+
Initial release.
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
- **Complete TypeScript schema for SRP v0.1** — 19 block-level node types exported as a discriminated union. Containers (5: column, row, grid, card, divider), record-rendering (3: record-line, record-line-list, chip), data display (4: heading, text, stat, key-value), interactive (4: button, icon-button, copy-button, select), feedback (3: empty-state, error-state, skeleton).
|
|
12
|
+
|
|
13
|
+
- **Token enumerations** — `Gap`, `Padding`, `Cols`, `RowAlign`, `ColumnAlign`, `Justify`, `RecordLineVariant`, `TextSize`, `TextWeight`, `TextTone`, `ButtonVariant`, `ButtonSize`, `ChipTone`, `SkeletonShape`, `GlyphKind`, `DividerSpacing` — match the token scales in `@syncropel/react` and the spec.
|
|
14
|
+
|
|
15
|
+
- **Action + query types** — `ActionDesc` (for named intents), `VQLQuery` (for record-list bindings).
|
|
16
|
+
|
|
17
|
+
- **`validateSRP(doc)` runtime validator** — walks an arbitrary value and returns either `{ valid: true }` or `{ valid: false, errors }` with JSON-pointer-style paths and machine-readable error codes.
|
|
18
|
+
|
|
19
|
+
- **Per-node validators** — `validateNode(node, path)` for incremental validation; `isSRPDocument(x)`, `isSRPNode(x)` as type guards for adapter code receiving untrusted JSON.
|
|
20
|
+
|
|
21
|
+
- **Markdown subset parser** — `parseInline(text)` turns text-valued prop content into an AST of inline nodes (`text`, `bold`, `italic`, `code`, `link`, `strike`). Supports nested constructs. Unbalanced delimiters render as literal text. `stripFormatting(nodes)` reduces the AST to plain text.
|
|
22
|
+
|
|
23
|
+
### Runtime targets
|
|
24
|
+
|
|
25
|
+
- Node.js 18+ (built-in `fetch` + `AbortController`)
|
|
26
|
+
- Deno 1.30+
|
|
27
|
+
- Bun 1.0+
|
|
28
|
+
- Cloudflare Workers
|
|
29
|
+
- Modern browsers
|
|
30
|
+
|
|
31
|
+
### Dependencies
|
|
32
|
+
|
|
33
|
+
Zero runtime dependencies. Dev-only: `typescript`, `@types/node`, `tsx`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding any notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. Please also get an in-depth
|
|
186
|
+
understanding of how to properly apply this license to your work
|
|
187
|
+
by reading the FAQ at http://www.apache.org/foundation/license-faq.html
|
|
188
|
+
|
|
189
|
+
Copyright 2024-2026 Syncropic, Inc.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# @syncropel/projections
|
|
2
|
+
|
|
3
|
+
TypeScript schema and runtime validators for the [Syncropel Rendering Protocol (SRP)](https://syncropel.com) — declarative UI documents composed from a constrained palette of block-level primitives, designed for query-driven and AI-generated interfaces.
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
import { validateSRP, type SRPDocument } from "@syncropel/projections";
|
|
7
|
+
|
|
8
|
+
const doc: SRPDocument = {
|
|
9
|
+
srp: "0.1",
|
|
10
|
+
root: {
|
|
11
|
+
type: "column",
|
|
12
|
+
props: { gap: "md" },
|
|
13
|
+
children: [
|
|
14
|
+
{ type: "heading", props: { level: 1, text: "Session summary" } },
|
|
15
|
+
{
|
|
16
|
+
type: "grid",
|
|
17
|
+
props: { cols: 3, gap: "sm" },
|
|
18
|
+
children: [
|
|
19
|
+
{ type: "stat", props: { label: "Tracks played", value: 47 } },
|
|
20
|
+
{ type: "stat", props: { label: "Artists", value: 14, delta: 3 } },
|
|
21
|
+
{ type: "stat", props: { label: "Transitions", value: 12 } },
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const result = validateSRP(doc);
|
|
29
|
+
if (!result.valid) {
|
|
30
|
+
for (const err of result.errors) {
|
|
31
|
+
console.warn(`${err.path}: ${err.message}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Features
|
|
39
|
+
|
|
40
|
+
- **19 block-level primitives** — containers, record-rendering, data display, interactive, feedback. Closed palette; growth happens through reviewed spec proposals, not consumer-side overrides.
|
|
41
|
+
- **TypeScript schema** — every primitive has a typed node interface with discriminated-union dispatching.
|
|
42
|
+
- **Runtime validators** — `validateSRP()` walks a document and returns structured errors (JSON-pointer-style paths + machine-readable codes) for anything that doesn't conform.
|
|
43
|
+
- **Markdown subset parser** — inline `**bold**`, `*italic*`, `` `code` ``, `[link](url)`, `~~strike~~` in text-valued props, rendered via the corresponding typography atoms.
|
|
44
|
+
- **Zero runtime dependencies** — uses the platform only.
|
|
45
|
+
- **Universal runtime** — Node 18+, Deno, Bun, Cloudflare Workers, modern browsers.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Install
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm install @syncropel/projections
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Ships compiled JavaScript + TypeScript declarations. ESM only.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## What's in the box
|
|
60
|
+
|
|
61
|
+
### Schema types
|
|
62
|
+
|
|
63
|
+
The 19 node types are exported as a discriminated union keyed on `type`:
|
|
64
|
+
|
|
65
|
+
| Category | Nodes |
|
|
66
|
+
|---|---|
|
|
67
|
+
| **Containers** | `column`, `row`, `grid`, `card`, `divider` |
|
|
68
|
+
| **Record rendering** | `record-line`, `record-line-list`, `chip` |
|
|
69
|
+
| **Data display** | `heading`, `text`, `stat`, `key-value` |
|
|
70
|
+
| **Interactive** | `button`, `icon-button`, `copy-button`, `select` |
|
|
71
|
+
| **Feedback** | `empty-state`, `error-state`, `skeleton` |
|
|
72
|
+
|
|
73
|
+
Every node has a matching TypeScript interface (e.g., `ButtonNode`, `StatNode`). Import the ones you need, or use `SRPNode` for the full union.
|
|
74
|
+
|
|
75
|
+
### Validators
|
|
76
|
+
|
|
77
|
+
`validateSRP(doc)` accepts an `unknown` and returns:
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
type ValidationResult =
|
|
81
|
+
| { valid: true }
|
|
82
|
+
| { valid: false; errors: ValidationError[] };
|
|
83
|
+
|
|
84
|
+
interface ValidationError {
|
|
85
|
+
path: string; // JSON-pointer-style path
|
|
86
|
+
message: string; // human-readable
|
|
87
|
+
code: ValidationErrorCode; // machine-readable
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Error codes: `SRP_VERSION_INVALID`, `ROOT_MISSING`, `NODE_NOT_OBJECT`, `NODE_TYPE_MISSING`, `NODE_TYPE_UNKNOWN`, `PROPS_MISSING_REQUIRED`, `PROPS_INVALID_VALUE`, `CHILDREN_NOT_ARRAY`, `CHILDREN_NOT_ALLOWED`, `BIND_MISSING_REQUIRED`, `BIND_INVALID_SHAPE`.
|
|
92
|
+
|
|
93
|
+
Use `isSRPDocument(x)` or `isSRPNode(x)` as type guards in adapter code that receives untrusted JSON.
|
|
94
|
+
|
|
95
|
+
### Markdown subset
|
|
96
|
+
|
|
97
|
+
Text-valued props (`text`, `label`, `message`, etc.) accept a narrow markdown subset for inline formatting. Parse it with `parseInline(text)` to get an AST you can render:
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import { parseInline, type InlineNode } from "@syncropel/projections";
|
|
101
|
+
|
|
102
|
+
const nodes = parseInline("Visit **example.com** or read the [docs](/docs).");
|
|
103
|
+
// → [
|
|
104
|
+
// { kind: "text", text: "Visit " },
|
|
105
|
+
// { kind: "bold", children: [{ kind: "text", text: "example.com" }] },
|
|
106
|
+
// { kind: "text", text: " or read the " },
|
|
107
|
+
// { kind: "link", url: "/docs", children: [{ kind: "text", text: "docs" }] },
|
|
108
|
+
// { kind: "text", text: "." }
|
|
109
|
+
// ]
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Supported constructs: `**bold**`, `*italic*`, `` `code` ``, `[label](url)`, `~~strike~~`. Unbalanced delimiters render as literal text (no silent drops). Block-level markdown (headings, lists, tables, etc.) is NOT parsed — use SRP block-level nodes for structural content.
|
|
113
|
+
|
|
114
|
+
Strip formatting for aria-labels / plain-text search with `stripFormatting(nodes)`.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Who uses this
|
|
119
|
+
|
|
120
|
+
- **Adapter authors** — emit projection documents as record bodies; the schema guarantees your document renders across every Syncropel surface.
|
|
121
|
+
- **Renderer authors** — `@syncropel/react` consumes this package for its prop types; future renderers (Vue, Svelte, server-side HTML, etc.) will too.
|
|
122
|
+
- **Backend servers** — validate projection documents before storing them, without pulling in a React runtime.
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Related packages
|
|
127
|
+
|
|
128
|
+
- **[@syncropel/sdk](https://www.npmjs.com/package/@syncropel/sdk)** — emit + query records (TypeScript SDK for the Syncropel protocol)
|
|
129
|
+
- **@syncropel/react** *(planned)* — React renderer for SRP documents
|
|
130
|
+
- **@syncropel/extensions** *(planned)* — iframe postMessage runtime for Tier-2 extensions (SAP protocol)
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## License
|
|
135
|
+
|
|
136
|
+
[Apache-2.0](./LICENSE).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @syncropel/projections — Syncropel Rendering Protocol (SRP) v0.1.
|
|
3
|
+
*
|
|
4
|
+
* TypeScript schema + runtime validators for declarative UI documents
|
|
5
|
+
* rendered by @syncropel/react (and other renderers). Zero runtime
|
|
6
|
+
* dependencies; universal runtime (Node, Deno, Bun, Workers, browsers).
|
|
7
|
+
*
|
|
8
|
+
* Docs: https://syncropel.com
|
|
9
|
+
*/
|
|
10
|
+
export type { SRPDocument, SRPMeta, SRPNode, NodeType, ColumnNode, RowNode, GridNode, CardNode, DividerNode, RecordLineNode, RecordLineListNode, ChipNode, HeadingNode, TextNode, StatNode, KeyValueNode, ButtonNode, IconButtonNode, CopyButtonNode, SelectNode, EmptyStateNode, ErrorStateNode, SkeletonNode, Gap, Padding, DividerSpacing, Cols, ColumnAlign, RowAlign, Justify, RecordLineVariant, ChipTone, TextSize, TextWeight, TextTone, ButtonVariant, ButtonSize, SkeletonShape, GlyphKind, ActionDesc, VQLQuery, } from "./schema.js";
|
|
11
|
+
export { NODE_TYPES } from "./schema.js";
|
|
12
|
+
export { validateSRP, validateNode, isSRPDocument, isSRPNode, } from "./validators.js";
|
|
13
|
+
export type { ValidationResult, ValidationError, ValidationErrorCode, } from "./validators.js";
|
|
14
|
+
export { parseInline, stripFormatting } from "./markdown.js";
|
|
15
|
+
export type { InlineNode } from "./markdown.js";
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,YAAY,EACV,WAAW,EACX,OAAO,EACP,OAAO,EACP,QAAQ,EAER,UAAU,EACV,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,WAAW,EAEX,cAAc,EACd,kBAAkB,EAClB,QAAQ,EAER,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,YAAY,EAEZ,UAAU,EACV,cAAc,EACd,cAAc,EACd,UAAU,EAEV,cAAc,EACd,cAAc,EACd,YAAY,EAEZ,GAAG,EACH,OAAO,EACP,cAAc,EACd,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,OAAO,EACP,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,aAAa,EACb,UAAU,EACV,aAAa,EACb,SAAS,EAET,UAAU,EACV,QAAQ,GACT,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EACL,WAAW,EACX,YAAY,EACZ,aAAa,EACb,SAAS,GACV,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC7D,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @syncropel/projections — Syncropel Rendering Protocol (SRP) v0.1.
|
|
3
|
+
*
|
|
4
|
+
* TypeScript schema + runtime validators for declarative UI documents
|
|
5
|
+
* rendered by @syncropel/react (and other renderers). Zero runtime
|
|
6
|
+
* dependencies; universal runtime (Node, Deno, Bun, Workers, browsers).
|
|
7
|
+
*
|
|
8
|
+
* Docs: https://syncropel.com
|
|
9
|
+
*/
|
|
10
|
+
export { NODE_TYPES } from "./schema.js";
|
|
11
|
+
// Validators
|
|
12
|
+
export { validateSRP, validateNode, isSRPDocument, isSRPNode, } from "./validators.js";
|
|
13
|
+
// Markdown subset parser
|
|
14
|
+
export { parseInline, stripFormatting } from "./markdown.js";
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAsDH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,aAAa;AACb,OAAO,EACL,WAAW,EACX,YAAY,EACZ,aAAa,EACb,SAAS,GACV,MAAM,iBAAiB,CAAC;AAQzB,yBAAyB;AACzB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC","sourcesContent":["/**\n * @syncropel/projections — Syncropel Rendering Protocol (SRP) v0.1.\n *\n * TypeScript schema + runtime validators for declarative UI documents\n * rendered by @syncropel/react (and other renderers). Zero runtime\n * dependencies; universal runtime (Node, Deno, Bun, Workers, browsers).\n *\n * Docs: https://syncropel.com\n */\n\n// Schema types\nexport type {\n SRPDocument,\n SRPMeta,\n SRPNode,\n NodeType,\n // Container nodes\n ColumnNode,\n RowNode,\n GridNode,\n CardNode,\n DividerNode,\n // Record-rendering nodes\n RecordLineNode,\n RecordLineListNode,\n ChipNode,\n // Data-display nodes\n HeadingNode,\n TextNode,\n StatNode,\n KeyValueNode,\n // Interactive nodes\n ButtonNode,\n IconButtonNode,\n CopyButtonNode,\n SelectNode,\n // Feedback nodes\n EmptyStateNode,\n ErrorStateNode,\n SkeletonNode,\n // Token unions\n Gap,\n Padding,\n DividerSpacing,\n Cols,\n ColumnAlign,\n RowAlign,\n Justify,\n RecordLineVariant,\n ChipTone,\n TextSize,\n TextWeight,\n TextTone,\n ButtonVariant,\n ButtonSize,\n SkeletonShape,\n GlyphKind,\n // Actions + queries\n ActionDesc,\n VQLQuery,\n} from \"./schema.js\";\n\nexport { NODE_TYPES } from \"./schema.js\";\n\n// Validators\nexport {\n validateSRP,\n validateNode,\n isSRPDocument,\n isSRPNode,\n} from \"./validators.js\";\n\nexport type {\n ValidationResult,\n ValidationError,\n ValidationErrorCode,\n} from \"./validators.js\";\n\n// Markdown subset parser\nexport { parseInline, stripFormatting } from \"./markdown.js\";\nexport type { InlineNode } from \"./markdown.js\";\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline markdown subset parser for SRP text-valued props.
|
|
3
|
+
*
|
|
4
|
+
* Parses the five canonical inline constructs supported in SRP text:
|
|
5
|
+
*
|
|
6
|
+
* **bold** → { kind: "bold", children: [...] }
|
|
7
|
+
* *italic* → { kind: "italic", children: [...] }
|
|
8
|
+
* `code` → { kind: "code", text: "..." }
|
|
9
|
+
* [label](url) → { kind: "link", url: "...", children: [...] }
|
|
10
|
+
* ~~strike~~ → { kind: "strike", children: [...] }
|
|
11
|
+
*
|
|
12
|
+
* Other markdown (headings, lists, blockquotes, tables, images, raw HTML)
|
|
13
|
+
* is NOT parsed — structural formatting uses block-level SRP nodes.
|
|
14
|
+
*
|
|
15
|
+
* This parser is runtime-agnostic — it returns an AST that a React
|
|
16
|
+
* renderer (or any other renderer) can walk and emit typography atoms.
|
|
17
|
+
*/
|
|
18
|
+
export type InlineNode = {
|
|
19
|
+
kind: "text";
|
|
20
|
+
text: string;
|
|
21
|
+
} | {
|
|
22
|
+
kind: "bold";
|
|
23
|
+
children: InlineNode[];
|
|
24
|
+
} | {
|
|
25
|
+
kind: "italic";
|
|
26
|
+
children: InlineNode[];
|
|
27
|
+
} | {
|
|
28
|
+
kind: "code";
|
|
29
|
+
text: string;
|
|
30
|
+
} | {
|
|
31
|
+
kind: "link";
|
|
32
|
+
url: string;
|
|
33
|
+
children: InlineNode[];
|
|
34
|
+
} | {
|
|
35
|
+
kind: "strike";
|
|
36
|
+
children: InlineNode[];
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Parse a text string into an array of inline nodes.
|
|
40
|
+
*
|
|
41
|
+
* The subset is deliberately narrow. Unknown or unbalanced delimiters
|
|
42
|
+
* render as literal text (no silent drops).
|
|
43
|
+
*/
|
|
44
|
+
export declare function parseInline(text: string): InlineNode[];
|
|
45
|
+
/**
|
|
46
|
+
* Reduce an AST back to a plain-text string (formatting stripped).
|
|
47
|
+
* Useful for aria-label derivation, plain-text search, and logs.
|
|
48
|
+
*/
|
|
49
|
+
export declare function stripFormatting(nodes: InlineNode[]): string;
|
|
50
|
+
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,UAAU,EAAE,CAAA;CAAE,GACxC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,UAAU,EAAE,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,UAAU,EAAE,CAAA;CAAE,GACrD;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,UAAU,EAAE,CAAA;CAAE,CAAC;AAM/C;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,CAEtD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,MAAM,CAgB3D"}
|