ember-json-render 0.0.0-stage → 0.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.
- package/LICENSE +166 -0
- package/README.md +93 -2
- package/addon-main.cjs +2 -0
- package/dist/components/json-children.js +9 -0
- package/dist/components/json-children.js.map +1 -0
- package/dist/components/json-node.js +80 -0
- package/dist/components/json-node.js.map +1 -0
- package/dist/components/json-renderer.js +5 -0
- package/dist/components/json-renderer.js.map +1 -0
- package/dist/index.js +144 -0
- package/dist/index.js.map +1 -0
- package/dist/json-renderer-Chp6164I.js +106 -0
- package/dist/json-renderer-Chp6164I.js.map +1 -0
- package/package.json +58 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other
|
|
16
|
+
entities that control, are controlled by, or are under common control
|
|
17
|
+
with that entity. For the purposes of this definition, "control" means
|
|
18
|
+
(i) the power, direct or indirect, to cause the direction or management
|
|
19
|
+
of such entity, whether by contract or otherwise, or (ii) ownership of
|
|
20
|
+
fifty percent (50%) or more of the outstanding shares, or (iii) beneficial
|
|
21
|
+
ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
24
|
+
permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation source,
|
|
28
|
+
and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical transformation
|
|
31
|
+
or translation of a Source form, including but not limited to compiled
|
|
32
|
+
object code, generated documentation, and conversions to other media types.
|
|
33
|
+
|
|
34
|
+
"Work" shall mean the work of authorship, whether in Source or Object form,
|
|
35
|
+
made available under the License, as indicated by a copyright notice that
|
|
36
|
+
is included in or attached to the work (an example is provided in the
|
|
37
|
+
Appendix below).
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object form,
|
|
40
|
+
that is based on (or derived from) the Work and for which the editorial
|
|
41
|
+
revisions, annotations, elaborations, or other modifications represent,
|
|
42
|
+
as a whole, an original work of authorship. For the purposes of this
|
|
43
|
+
License, Derivative Works shall not include works that remain separable
|
|
44
|
+
from, or merely link (or bind by name) to the interfaces of, the Work and
|
|
45
|
+
Derivative Works thereof.
|
|
46
|
+
|
|
47
|
+
"Contribution" shall mean any work of authorship, including the original
|
|
48
|
+
version of the Work and any modifications or additions to that Work or
|
|
49
|
+
Derivative Works thereof, that is intentionally submitted to Licensor for
|
|
50
|
+
inclusion in the Work by the copyright owner or by an individual or Legal
|
|
51
|
+
Entity authorized to submit on behalf of the copyright owner. For the
|
|
52
|
+
purposes of this definition, "submitted" means any form of electronic,
|
|
53
|
+
verbal, or written communication sent to the Licensor or its representatives,
|
|
54
|
+
including but not limited to communication on electronic mailing lists,
|
|
55
|
+
source code control systems, and issue tracking systems that are managed by,
|
|
56
|
+
or on behalf of, the Licensor for the purpose of discussing and improving
|
|
57
|
+
the Work, but excluding communication that is conspicuously marked or
|
|
58
|
+
otherwise designated in writing by the copyright owner as "Not a
|
|
59
|
+
Contribution."
|
|
60
|
+
|
|
61
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on
|
|
62
|
+
behalf of whom a Contribution has been received by Licensor and subsequently
|
|
63
|
+
incorporated within the Work.
|
|
64
|
+
|
|
65
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this
|
|
66
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
67
|
+
non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
|
68
|
+
reproduce, prepare Derivative Works of, publicly display, publicly perform,
|
|
69
|
+
sublicense, and distribute the Work and such Derivative Works in Source or
|
|
70
|
+
Object form.
|
|
71
|
+
|
|
72
|
+
3. Grant of Patent License. Subject to the terms and conditions of this
|
|
73
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
74
|
+
non-exclusive, no-charge, royalty-free, irrevocable (except as stated in
|
|
75
|
+
this section) patent license to make, have made, use, offer to sell, sell,
|
|
76
|
+
import, and otherwise transfer the Work, where such license applies only to
|
|
77
|
+
those patent claims licensable by such Contributor that are necessarily
|
|
78
|
+
infringed by their Contribution(s) alone or by combination of their
|
|
79
|
+
Contribution(s) with the Work to which such Contribution(s) was submitted.
|
|
80
|
+
If You institute patent litigation against any entity (including a
|
|
81
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
|
82
|
+
Contribution incorporated within the Work constitutes direct or
|
|
83
|
+
contributory patent infringement, then any patent licenses granted to You
|
|
84
|
+
under this License for that Work shall terminate as of the date such
|
|
85
|
+
litigation is filed.
|
|
86
|
+
|
|
87
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or
|
|
88
|
+
Derivative Works thereof in any medium, with or without modifications, and
|
|
89
|
+
in Source or Object form, provided that You meet the following conditions:
|
|
90
|
+
|
|
91
|
+
(a) You must give any other recipients of the Work or Derivative Works a
|
|
92
|
+
copy of this License; and
|
|
93
|
+
|
|
94
|
+
(b) You must cause any modified files to carry prominent notices stating
|
|
95
|
+
that You changed the files; and
|
|
96
|
+
|
|
97
|
+
(c) You must retain, in the Source form of any Derivative Works that You
|
|
98
|
+
distribute, all copyright, patent, trademark, and attribution notices
|
|
99
|
+
from the Source form of the Work, excluding those notices that do not
|
|
100
|
+
pertain to any part of the Derivative Works; and
|
|
101
|
+
|
|
102
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution,
|
|
103
|
+
then any Derivative Works that You distribute must include a readable
|
|
104
|
+
copy of the attribution notices contained within such NOTICE file,
|
|
105
|
+
excluding those notices that do not pertain to any part of the
|
|
106
|
+
Derivative Works, in at least one of the following places: within a
|
|
107
|
+
NOTICE text file distributed as part of the Derivative Works; within
|
|
108
|
+
the Source form or documentation, if provided along with the Derivative
|
|
109
|
+
Works; or, within a display generated by the Derivative Works, if and
|
|
110
|
+
wherever such third-party notices normally appear. The contents of the
|
|
111
|
+
NOTICE file are for informational purposes only and do not modify the
|
|
112
|
+
License. You may add Your own attribution notices within Derivative
|
|
113
|
+
Works that You distribute, alongside or as an addendum to the NOTICE
|
|
114
|
+
text from the Work, provided that such additional attribution notices
|
|
115
|
+
cannot be construed as modifying the License.
|
|
116
|
+
|
|
117
|
+
You may add Your own copyright statement to Your modifications and may
|
|
118
|
+
provide additional or different license terms and conditions for use,
|
|
119
|
+
reproduction, or distribution of Your modifications, or for any such
|
|
120
|
+
Derivative Works as a whole, provided Your use, reproduction, and
|
|
121
|
+
distribution of the Work otherwise complies with the conditions stated in
|
|
122
|
+
this License.
|
|
123
|
+
|
|
124
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any
|
|
125
|
+
Contribution intentionally submitted for inclusion in the Work by You to the
|
|
126
|
+
Licensor shall be under the terms and conditions of this License, without
|
|
127
|
+
any additional terms or conditions. Notwithstanding the above, nothing
|
|
128
|
+
herein shall supersede or modify the terms of any separate license
|
|
129
|
+
agreement you may have executed with Licensor regarding such Contributions.
|
|
130
|
+
|
|
131
|
+
6. Trademarks. This License does not grant permission to use the trade names,
|
|
132
|
+
trademarks, service marks, or product names of the Licensor, except as
|
|
133
|
+
required for reasonable and customary use in describing the origin of the
|
|
134
|
+
Work and reproducing the content of the NOTICE file.
|
|
135
|
+
|
|
136
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
|
|
137
|
+
writing, Licensor provides the Work (and each Contributor provides its
|
|
138
|
+
Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
139
|
+
KIND, either express or implied, including, without limitation, any
|
|
140
|
+
warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or
|
|
141
|
+
FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining
|
|
142
|
+
the appropriateness of using or redistributing the Work and assume any risks
|
|
143
|
+
associated with Your exercise of permissions under this License.
|
|
144
|
+
|
|
145
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in
|
|
146
|
+
tort (including negligence), contract, or otherwise, unless required by
|
|
147
|
+
applicable law (such as deliberate and grossly negligent acts) or agreed to
|
|
148
|
+
in writing, shall any Contributor be liable to You for damages, including
|
|
149
|
+
any direct, indirect, special, incidental, or consequential damages of any
|
|
150
|
+
character arising as a result of this License or out of the use or inability
|
|
151
|
+
to use the Work (including but not limited to damages for loss of goodwill,
|
|
152
|
+
work stoppage, computer failure or malfunction, or any and all other
|
|
153
|
+
commercial damages or losses), even if such Contributor has been advised of
|
|
154
|
+
the possibility of such damages.
|
|
155
|
+
|
|
156
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work
|
|
157
|
+
or Derivative Works thereof, You may choose to offer, and charge a fee for,
|
|
158
|
+
acceptance of support, warranty, indemnity, or other liability obligations
|
|
159
|
+
and/or rights consistent with this License. However, in accepting such
|
|
160
|
+
obligations, You may act only on Your own behalf and on Your sole
|
|
161
|
+
responsibility, not on behalf of any other Contributor, and only if You
|
|
162
|
+
agree to indemnify, defend, and hold each Contributor harmless for any
|
|
163
|
+
liability incurred by, or claims asserted against, such Contributor by
|
|
164
|
+
reason of your accepting any such warranty or additional liability.
|
|
165
|
+
|
|
166
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
CHANGED
|
@@ -1,3 +1,94 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ember-json-render
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Ember and Glimmer adapter for [Vercel's json-render](https://github.com/vercel-labs/json-render). It renders the same flat `Spec` shape used by other framework adapters and lets an application map catalog names to ordinary Ember components.
|
|
4
|
+
|
|
5
|
+
Early preview of an Ember adapter for the shared json-render spec. Catalogs and specs stay portable between framework adapters; the Ember package supplies the renderer and a tracked SpecStream client.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install ember-json-render @json-render/core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
This package targets Ember 5, 6, and 7 with Glimmer components. `@json-render/core` remains the source of the spec, expression, action, and streaming protocol APIs; no forked wire format is introduced.
|
|
14
|
+
|
|
15
|
+
## Define a registry
|
|
16
|
+
|
|
17
|
+
Catalog components receive resolved `@props`, `@state`, an `@emit` callback, and children through the yielded block:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
// app/components/ui-card.ts
|
|
21
|
+
import Component from '@glimmer/component';
|
|
22
|
+
|
|
23
|
+
interface Args { props: { title?: string }; }
|
|
24
|
+
export default class UiCard extends Component<{ Args: Args }> {}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```hbs
|
|
28
|
+
{{! app/components/ui-card.hbs }}
|
|
29
|
+
<section class="card">
|
|
30
|
+
{{#if @props.title}}<h2>{{@props.title}}</h2>{{/if}}
|
|
31
|
+
{{yield}}
|
|
32
|
+
</section>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
// app/render-registry.ts
|
|
37
|
+
import { defineRegistry } from 'ember-json-render';
|
|
38
|
+
import UiCard from './components/ui-card';
|
|
39
|
+
import UiButton from './components/ui-button';
|
|
40
|
+
|
|
41
|
+
export const registry = defineRegistry({ Card: UiCard, Button: UiButton });
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```hbs
|
|
45
|
+
<JsonRenderer @spec={{this.spec}} @registry={{this.registry}} @onAction={{this.handleAction}} />
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import type { Spec } from 'ember-json-render';
|
|
50
|
+
|
|
51
|
+
spec: Spec = {
|
|
52
|
+
root: 'card',
|
|
53
|
+
state: { count: 0 },
|
|
54
|
+
elements: {
|
|
55
|
+
card: { type: 'Card', props: { title: 'Hello' }, children: ['button'] },
|
|
56
|
+
button: {
|
|
57
|
+
type: 'Button', props: { label: 'Increment' },
|
|
58
|
+
on: { press: { action: 'increment', params: { amount: 1 } } },
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`@onAction` receives `{ name, params, elementKey }`. Supply `@actions` to handle catalog action names. Built-in `setState`, `removeState`, and `pushState` bindings update the renderer's `StateStore`. Supply `@store` to share an upstream store, or `@state` to seed an owned store. Components receive resolved `@props`, `@bindings`, and a `@bind` callback; call `this.args.bind('value', nextValue)` in a component method to write a prop declared with `$bindState` or `$bindItem`.
|
|
65
|
+
|
|
66
|
+
## Dynamic props
|
|
67
|
+
|
|
68
|
+
The renderer delegates dynamic prop resolution and visibility evaluation to `@json-render/core`, including `$state`, `$bindState`, `$bindItem`, `$item`, `$index`, templates, conditionals, and nested repeat scopes. Unknown catalog component names are skipped while `@loading` is false and shown as a placeholder while a streamed spec is incomplete.
|
|
69
|
+
|
|
70
|
+
## Streaming a spec
|
|
71
|
+
|
|
72
|
+
`createJsonRenderUIStream` is a tracked controller for endpoints that return SpecStream JSONL (RFC 6902 patch lines):
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
import { createJsonRenderUIStream } from 'ember-json-render';
|
|
76
|
+
|
|
77
|
+
ui = createJsonRenderUIStream({ api: '/api/generate' });
|
|
78
|
+
// In a component action:
|
|
79
|
+
await this.ui.send('A dashboard for weekly sales');
|
|
80
|
+
// Refine:
|
|
81
|
+
if (this.ui.spec) await this.ui.send('Use a bar chart', { previousSpec: this.ui.spec });
|
|
82
|
+
// Stop and keep the partial result: this.ui.stop();
|
|
83
|
+
// Clear the current result and error: this.ui.clear();
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Pass `ui.spec` and `ui.isStreaming` to `<JsonRenderer>`. The controller accepts a custom `fetch`, headers, and an `onComplete` callback. For chat streams, prompts, catalog schemas, validation, and directives, use the corresponding upstream `@json-render/core` APIs alongside this renderer.
|
|
87
|
+
|
|
88
|
+
## Docs and releases
|
|
89
|
+
|
|
90
|
+
The `docs/` site is published with GitHub Pages through `.github/workflows/pages.yml`. Add a Changesets file with `pnpm changeset` for each user-facing change. Version packages with `pnpm version-packages`; publishing remains a manual `pnpm release` step through the maintainer's npm trusted publishing setup.
|
|
91
|
+
|
|
92
|
+
Enable **Settings → Pages → Build and deployment → GitHub Actions** once in the repository to turn on the docs workflow. The release workflow stays gated until the first manual npm release and trusted publishing setup are complete; set the repository variable `NPM_TRUSTED_PUBLISHING_ENABLED=true` afterward to enable Changesets automation.
|
|
93
|
+
|
|
94
|
+
The addon uses Embroider v2 package metadata and Rollup packaging. Its current API is an early preview; consumers should check the docs for the supported surface and current limitations.
|
package/addon-main.cjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
|
|
3
|
+
/** Named template marker for Ember catalog components. The renderer passes
|
|
4
|
+
* child nodes in the default block; render a named slot by yielding where
|
|
5
|
+
* your component chooses to place it. */
|
|
6
|
+
class JsonChildren extends Component {}
|
|
7
|
+
|
|
8
|
+
export { JsonChildren as default };
|
|
9
|
+
//# sourceMappingURL=json-children.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-children.js","sources":["../../src/components/json-children.ts"],"sourcesContent":["import Component from '@glimmer/component';\n\ninterface Args { slot?: string; }\n\n/** Named template marker for Ember catalog components. The renderer passes\n * child nodes in the default block; render a named slot by yielding where\n * your component chooses to place it. */\nexport default class JsonChildren extends Component<{ Args: Args }> {}\n"],"names":["JsonChildren","Component"],"mappings":";;AAIA;AACA;AACA;AACe,MAAMA,YAAY,SAASC,SAAS,CAAiB;;"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { resolveElementProps, resolveBindings, evaluateVisibility, resolveRepeatItemStatePath, conditionUsesItemScope, resolveRepeatStatePath, getByPath } from '@json-render/core';
|
|
3
|
+
|
|
4
|
+
class JsonNode extends Component {
|
|
5
|
+
constructor(...args) {
|
|
6
|
+
super(...args);
|
|
7
|
+
this.propsFor = (item, index, repeatBasePath) => resolveElementProps(this.element?.props ?? {}, {
|
|
8
|
+
stateModel: this.args.state,
|
|
9
|
+
repeatItem: item,
|
|
10
|
+
repeatIndex: index,
|
|
11
|
+
repeatBasePath
|
|
12
|
+
});
|
|
13
|
+
this.bindingsFor = (item, index, repeatBasePath) => resolveBindings(this.element?.props ?? {}, {
|
|
14
|
+
stateModel: this.args.state,
|
|
15
|
+
repeatItem: item,
|
|
16
|
+
repeatIndex: index,
|
|
17
|
+
repeatBasePath
|
|
18
|
+
}) ?? {};
|
|
19
|
+
this.visibleFor = (item, index) => evaluateVisibility(this.element?.visible, {
|
|
20
|
+
stateModel: this.args.state,
|
|
21
|
+
repeatItem: item,
|
|
22
|
+
repeatIndex: index
|
|
23
|
+
});
|
|
24
|
+
this.repeatBaseAt = index => this.repeatPath ? resolveRepeatItemStatePath(this.repeatPath, index) : undefined;
|
|
25
|
+
this.emit = (name, payload) => this.args.emit(this.args.elementKey, name, payload);
|
|
26
|
+
this.bind = (propName, value) => {
|
|
27
|
+
const path = this.bindings[propName];
|
|
28
|
+
if (path) this.args.store.set(path, value);
|
|
29
|
+
};
|
|
30
|
+
this.bindFor = (item, index, repeatBasePath, propName, value) => {
|
|
31
|
+
const path = this.bindingsFor(item, index, repeatBasePath)[propName];
|
|
32
|
+
if (path) this.args.store.set(path, value);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
get element() {
|
|
36
|
+
return this.args.spec.elements[this.args.elementKey];
|
|
37
|
+
}
|
|
38
|
+
get component() {
|
|
39
|
+
return this.element ? this.args.registry[this.element.type] : undefined;
|
|
40
|
+
}
|
|
41
|
+
get children() {
|
|
42
|
+
return this.element?.children ?? [];
|
|
43
|
+
}
|
|
44
|
+
get resolutionContext() {
|
|
45
|
+
return {
|
|
46
|
+
stateModel: this.args.state,
|
|
47
|
+
repeatItem: this.args.item,
|
|
48
|
+
repeatIndex: this.args.index,
|
|
49
|
+
repeatBasePath: this.args.repeatBasePath
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
get props() {
|
|
53
|
+
return resolveElementProps(this.element?.props ?? {}, this.resolutionContext);
|
|
54
|
+
}
|
|
55
|
+
get bindings() {
|
|
56
|
+
return resolveBindings(this.element?.props ?? {}, this.resolutionContext) ?? {};
|
|
57
|
+
}
|
|
58
|
+
get containerVisible() {
|
|
59
|
+
if (this.element?.repeat && conditionUsesItemScope(this.element.visible)) return true;
|
|
60
|
+
return evaluateVisibility(this.element?.visible, this.resolutionContext);
|
|
61
|
+
}
|
|
62
|
+
get visible() {
|
|
63
|
+
return evaluateVisibility(this.element?.visible, this.resolutionContext);
|
|
64
|
+
}
|
|
65
|
+
get repeated() {
|
|
66
|
+
const repeat = this.element?.repeat;
|
|
67
|
+
if (!repeat) return [];
|
|
68
|
+
const path = resolveRepeatStatePath(repeat.statePath, this.args.repeatBasePath);
|
|
69
|
+
if (!path) return [];
|
|
70
|
+
const value = getByPath(this.args.state, path);
|
|
71
|
+
return Array.isArray(value) ? value : [];
|
|
72
|
+
}
|
|
73
|
+
get repeatPath() {
|
|
74
|
+
const path = this.element?.repeat?.statePath;
|
|
75
|
+
return path ? resolveRepeatStatePath(path, this.args.repeatBasePath) : undefined;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export { JsonNode as default };
|
|
80
|
+
//# sourceMappingURL=json-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-node.js","sources":["../../src/components/json-node.ts"],"sourcesContent":["import Component from '@glimmer/component';\nimport {\n evaluateVisibility,\n getByPath,\n resolveBindings,\n resolveElementProps,\n resolveRepeatItemStatePath,\n resolveRepeatStatePath,\n conditionUsesItemScope,\n type PropResolutionContext,\n type Spec,\n type StateStore,\n type UIElement,\n} from '@json-render/core';\nimport type { JsonRenderRegistry } from '../registry';\n\ninterface Args {\n elementKey: string;\n spec: Spec;\n registry: JsonRenderRegistry;\n state: Record<string, unknown>;\n store: StateStore;\n emit: (elementKey: string, eventName: string, payload?: unknown) => void;\n loading?: boolean;\n item?: unknown;\n index?: number;\n repeatBasePath?: string;\n}\n\nexport default class JsonNode extends Component<{ Args: Args }> {\n get element(): UIElement | undefined { return this.args.spec.elements[this.args.elementKey]; }\n get component(): unknown { return this.element ? this.args.registry[this.element.type] : undefined; }\n get children(): string[] { return this.element?.children ?? []; }\n get resolutionContext(): PropResolutionContext {\n return {\n stateModel: this.args.state,\n repeatItem: this.args.item,\n repeatIndex: this.args.index,\n repeatBasePath: this.args.repeatBasePath,\n };\n }\n get props(): Record<string, unknown> { return resolveElementProps(this.element?.props ?? {}, this.resolutionContext); }\n get bindings(): Record<string, string> { return resolveBindings(this.element?.props ?? {}, this.resolutionContext) ?? {}; }\n get containerVisible(): boolean {\n if (this.element?.repeat && conditionUsesItemScope(this.element.visible)) return true;\n return evaluateVisibility(this.element?.visible, this.resolutionContext);\n }\n get visible(): boolean {\n return evaluateVisibility(this.element?.visible, this.resolutionContext);\n }\n get repeated(): unknown[] {\n const repeat = this.element?.repeat;\n if (!repeat) return [];\n const path = resolveRepeatStatePath(repeat.statePath, this.args.repeatBasePath);\n if (!path) return [];\n const value = getByPath(this.args.state, path);\n return Array.isArray(value) ? value : [];\n }\n get repeatPath(): string | undefined {\n const path = this.element?.repeat?.statePath;\n return path ? resolveRepeatStatePath(path, this.args.repeatBasePath) : undefined;\n }\n propsFor = (item: unknown, index: number, repeatBasePath?: string): Record<string, unknown> =>\n resolveElementProps(this.element?.props ?? {}, {\n stateModel: this.args.state,\n repeatItem: item,\n repeatIndex: index,\n repeatBasePath,\n });\n bindingsFor = (item: unknown, index: number, repeatBasePath?: string): Record<string, string> =>\n resolveBindings(this.element?.props ?? {}, {\n stateModel: this.args.state,\n repeatItem: item,\n repeatIndex: index,\n repeatBasePath,\n }) ?? {};\n visibleFor = (item: unknown, index: number): boolean =>\n evaluateVisibility(this.element?.visible, {\n stateModel: this.args.state,\n repeatItem: item,\n repeatIndex: index,\n });\n repeatBaseAt = (index: number): string | undefined =>\n this.repeatPath ? resolveRepeatItemStatePath(this.repeatPath, index) : undefined;\n emit = (name: string, payload?: unknown): void => this.args.emit(this.args.elementKey, name, payload);\n bind = (propName: string, value: unknown): void => {\n const path = this.bindings[propName];\n if (path) this.args.store.set(path, value);\n };\n bindFor = (item: unknown, index: number, repeatBasePath: string | undefined, propName: string, value: unknown): void => {\n const path = this.bindingsFor(item, index, repeatBasePath)[propName];\n if (path) this.args.store.set(path, value);\n };\n}\n"],"names":["JsonNode","Component","constructor","args","propsFor","item","index","repeatBasePath","resolveElementProps","element","props","stateModel","state","repeatItem","repeatIndex","bindingsFor","resolveBindings","visibleFor","evaluateVisibility","visible","repeatBaseAt","repeatPath","resolveRepeatItemStatePath","undefined","emit","name","payload","elementKey","bind","propName","value","path","bindings","store","set","bindFor","spec","elements","component","registry","type","children","resolutionContext","containerVisible","repeat","conditionUsesItemScope","repeated","resolveRepeatStatePath","statePath","getByPath","Array","isArray"],"mappings":";;;AA6Be,MAAMA,QAAQ,SAASC,SAAS,CAAiB;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA;AAAA,IAAA,IAAA,CAiC9DC,QAAQ,GAAG,CAACC,IAAa,EAAEC,KAAa,EAAEC,cAAuB,KAC/DC,mBAAmB,CAAC,IAAI,CAACC,OAAO,EAAEC,KAAK,IAAI,EAAE,EAAE;AAC7CC,MAAAA,UAAU,EAAE,IAAI,CAACR,IAAI,CAACS,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,CAAC,GAAGgB,SAAS;AAClF,EAAA;AAgCF;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-renderer.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { _ as _applyDecoratedDescriptor, a as _initializerDefineProperty } from './json-renderer-Chp6164I.js';
|
|
2
|
+
export { J as JsonRenderer } from './json-renderer-Chp6164I.js';
|
|
3
|
+
export { default as JsonNode } from './components/json-node.js';
|
|
4
|
+
export { default as JsonChildren } from './components/json-children.js';
|
|
5
|
+
import { tracked } from '@glimmer/tracking';
|
|
6
|
+
import { createSpecStreamCompiler } from '@json-render/core';
|
|
7
|
+
|
|
8
|
+
function defineRegistry(registry) {
|
|
9
|
+
return registry;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
var _class, _descriptor, _descriptor2, _descriptor3;
|
|
13
|
+
/**
|
|
14
|
+
* Tracked Ember controller for a json-render SpecStream endpoint.
|
|
15
|
+
* The response body is JSONL containing RFC 6902 patch operations, one per line.
|
|
16
|
+
*/
|
|
17
|
+
let JsonRenderUIStream = (_class = class JsonRenderUIStream {
|
|
18
|
+
constructor(options) {
|
|
19
|
+
this.options = options;
|
|
20
|
+
_initializerDefineProperty(this, "spec", _descriptor, this);
|
|
21
|
+
_initializerDefineProperty(this, "isStreaming", _descriptor2, this);
|
|
22
|
+
_initializerDefineProperty(this, "error", _descriptor3, this);
|
|
23
|
+
this.activeRequest = null;
|
|
24
|
+
this.request = void 0;
|
|
25
|
+
this.request = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
26
|
+
}
|
|
27
|
+
async send(prompt, sendOptions = {}) {
|
|
28
|
+
this.stop();
|
|
29
|
+
const abort = new AbortController();
|
|
30
|
+
this.activeRequest = abort;
|
|
31
|
+
this.error = null;
|
|
32
|
+
this.isStreaming = true;
|
|
33
|
+
const startingSpec = sendOptions.previousSpec ?? undefined;
|
|
34
|
+
this.spec = startingSpec ?? null;
|
|
35
|
+
const compiler = createSpecStreamCompiler(startingSpec ?? {});
|
|
36
|
+
try {
|
|
37
|
+
const response = await this.request(this.options.api, {
|
|
38
|
+
method: 'POST',
|
|
39
|
+
headers: {
|
|
40
|
+
'Content-Type': 'application/json',
|
|
41
|
+
...Object.fromEntries(new Headers(this.options.headers).entries())
|
|
42
|
+
},
|
|
43
|
+
body: JSON.stringify({
|
|
44
|
+
prompt,
|
|
45
|
+
context: sendOptions.context,
|
|
46
|
+
currentSpec: startingSpec
|
|
47
|
+
}),
|
|
48
|
+
signal: abort.signal
|
|
49
|
+
});
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
throw new Error(`UI generation failed (${response.status} ${response.statusText})`);
|
|
52
|
+
}
|
|
53
|
+
if (!response.body) {
|
|
54
|
+
throw new Error('UI generation response has no readable body');
|
|
55
|
+
}
|
|
56
|
+
const reader = response.body.getReader();
|
|
57
|
+
const decoder = new TextDecoder();
|
|
58
|
+
try {
|
|
59
|
+
while (true) {
|
|
60
|
+
const {
|
|
61
|
+
done,
|
|
62
|
+
value
|
|
63
|
+
} = await reader.read();
|
|
64
|
+
if (done) break;
|
|
65
|
+
const {
|
|
66
|
+
result,
|
|
67
|
+
newPatches
|
|
68
|
+
} = compiler.push(decoder.decode(value, {
|
|
69
|
+
stream: true
|
|
70
|
+
}));
|
|
71
|
+
if (newPatches.length > 0) this.spec = result;
|
|
72
|
+
}
|
|
73
|
+
const remainder = decoder.decode();
|
|
74
|
+
if (remainder) {
|
|
75
|
+
const {
|
|
76
|
+
result,
|
|
77
|
+
newPatches
|
|
78
|
+
} = compiler.push(remainder);
|
|
79
|
+
if (newPatches.length > 0) this.spec = result;
|
|
80
|
+
}
|
|
81
|
+
} finally {
|
|
82
|
+
reader.releaseLock();
|
|
83
|
+
}
|
|
84
|
+
if (abort.signal.aborted) return;
|
|
85
|
+
const finalSpec = compiler.getResult();
|
|
86
|
+
this.spec = finalSpec;
|
|
87
|
+
this.options.onComplete?.(finalSpec);
|
|
88
|
+
} catch (cause) {
|
|
89
|
+
if (!abort.signal.aborted) {
|
|
90
|
+
this.error = cause instanceof Error ? cause : new Error(String(cause));
|
|
91
|
+
}
|
|
92
|
+
} finally {
|
|
93
|
+
if (this.activeRequest === abort) {
|
|
94
|
+
this.activeRequest = null;
|
|
95
|
+
this.isStreaming = false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Abort the active request and keep any patches already received. */
|
|
101
|
+
stop() {
|
|
102
|
+
const active = this.activeRequest;
|
|
103
|
+
if (!active) return;
|
|
104
|
+
this.activeRequest = null;
|
|
105
|
+
this.isStreaming = false;
|
|
106
|
+
active.abort();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Stop generation and reset spec and error state. */
|
|
110
|
+
clear() {
|
|
111
|
+
this.stop();
|
|
112
|
+
this.spec = null;
|
|
113
|
+
this.error = null;
|
|
114
|
+
}
|
|
115
|
+
}, _descriptor = _applyDecoratedDescriptor(_class.prototype, "spec", [tracked], {
|
|
116
|
+
configurable: true,
|
|
117
|
+
enumerable: true,
|
|
118
|
+
writable: true,
|
|
119
|
+
initializer: function () {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class.prototype, "isStreaming", [tracked], {
|
|
123
|
+
configurable: true,
|
|
124
|
+
enumerable: true,
|
|
125
|
+
writable: true,
|
|
126
|
+
initializer: function () {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}), _descriptor3 = _applyDecoratedDescriptor(_class.prototype, "error", [tracked], {
|
|
130
|
+
configurable: true,
|
|
131
|
+
enumerable: true,
|
|
132
|
+
writable: true,
|
|
133
|
+
initializer: function () {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
}), _class);
|
|
137
|
+
|
|
138
|
+
/** Create a tracked UI stream controller for use from a Glimmer component or service. */
|
|
139
|
+
function createJsonRenderUIStream(options) {
|
|
140
|
+
return new JsonRenderUIStream(options);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export { JsonRenderUIStream, createJsonRenderUIStream, defineRegistry };
|
|
144
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/registry.ts","../src/streaming.ts"],"sourcesContent":["import type { ComponentLike } from '@glint/template';\n\nexport interface JsonRenderEvent {\n name: string;\n params: Record<string, unknown>;\n elementKey: string;\n}\n\nexport interface JsonRenderComponentArgs {\n props: Record<string, unknown>;\n bindings: Record<string, string>;\n state: Record<string, unknown>;\n emit: (eventName: string, payload?: unknown) => void;\n children: string[];\n item?: unknown;\n index?: number;\n bind: (propName: string, value: unknown) => void;\n}\n\nexport type JsonRenderRegistry = Record<string, ComponentLike<JsonRenderComponentArgs>>;\n\nexport function defineRegistry<T extends JsonRenderRegistry>(registry: T): T {\n return registry;\n}\n","import { tracked } from '@glimmer/tracking';\nimport { createSpecStreamCompiler, type Spec } from '@json-render/core';\n\nexport interface JsonRenderStreamSendOptions {\n /** Optional application data forwarded to the generation endpoint. */\n context?: unknown;\n /** Continue refining an existing spec instead of starting from an empty one. */\n previousSpec?: Spec;\n}\n\nexport interface JsonRenderUIStreamOptions {\n /** Endpoint that accepts { prompt, context, currentSpec } and returns SpecStream JSONL. */\n api: string;\n /** Supply fetch to add authentication, use a test transport, or route through an app client. */\n fetch?: typeof fetch;\n /** Additional headers sent with each request. */\n headers?: HeadersInit;\n /** Called once with the final spec after a successful stream. */\n onComplete?: (spec: Spec) => void;\n}\n\n/**\n * Tracked Ember controller for a json-render SpecStream endpoint.\n * The response body is JSONL containing RFC 6902 patch operations, one per line.\n */\nexport class JsonRenderUIStream {\n @tracked spec: Spec | null = null;\n @tracked isStreaming = false;\n @tracked error: Error | null = null;\n\n private activeRequest: AbortController | null = null;\n private readonly request: typeof fetch;\n\n constructor(private readonly options: JsonRenderUIStreamOptions) {\n this.request = options.fetch ?? globalThis.fetch.bind(globalThis);\n }\n\n async send(prompt: string, sendOptions: JsonRenderStreamSendOptions = {}): Promise<void> {\n this.stop();\n const abort = new AbortController();\n this.activeRequest = abort;\n this.error = null;\n this.isStreaming = true;\n\n const startingSpec = sendOptions.previousSpec ?? undefined;\n this.spec = startingSpec ?? null;\n const compiler = createSpecStreamCompiler<Spec>(startingSpec ?? {});\n\n try {\n const response = await this.request(this.options.api, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n ...Object.fromEntries(new Headers(this.options.headers).entries()),\n },\n body: JSON.stringify({\n prompt,\n context: sendOptions.context,\n currentSpec: startingSpec,\n }),\n signal: abort.signal,\n });\n\n if (!response.ok) {\n throw new Error(`UI generation failed (${response.status} ${response.statusText})`);\n }\n if (!response.body) {\n throw new Error('UI generation response has no readable body');\n }\n\n const reader = response.body.getReader();\n const decoder = new TextDecoder();\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n const { result, newPatches } = compiler.push(decoder.decode(value, { stream: true }));\n if (newPatches.length > 0) this.spec = result;\n }\n const remainder = decoder.decode();\n if (remainder) {\n const { result, newPatches } = compiler.push(remainder);\n if (newPatches.length > 0) this.spec = result;\n }\n } finally {\n reader.releaseLock();\n }\n\n if (abort.signal.aborted) return;\n const finalSpec = compiler.getResult();\n this.spec = finalSpec;\n this.options.onComplete?.(finalSpec);\n } catch (cause) {\n if (!abort.signal.aborted) {\n this.error = cause instanceof Error ? cause : new Error(String(cause));\n }\n } finally {\n if (this.activeRequest === abort) {\n this.activeRequest = null;\n this.isStreaming = false;\n }\n }\n }\n\n /** Abort the active request and keep any patches already received. */\n stop(): void {\n const active = this.activeRequest;\n if (!active) return;\n this.activeRequest = null;\n this.isStreaming = false;\n active.abort();\n }\n\n /** Stop generation and reset spec and error state. */\n clear(): void {\n this.stop();\n this.spec = null;\n this.error = null;\n }\n}\n\n/** Create a tracked UI stream controller for use from a Glimmer component or service. */\nexport function createJsonRenderUIStream(options: JsonRenderUIStreamOptions): JsonRenderUIStream {\n return new JsonRenderUIStream(options);\n}\n"],"names":["defineRegistry","registry","JsonRenderUIStream","_class","constructor","options","_initializerDefineProperty","_descriptor","_descriptor2","_descriptor3","activeRequest","request","fetch","globalThis","bind","send","prompt","sendOptions","stop","abort","AbortController","error","isStreaming","startingSpec","previousSpec","undefined","spec","compiler","createSpecStreamCompiler","response","api","method","headers","Object","fromEntries","Headers","entries","body","JSON","stringify","context","currentSpec","signal","ok","Error","status","statusText","reader","getReader","decoder","TextDecoder","done","value","read","result","newPatches","push","decode","stream","length","remainder","releaseLock","aborted","finalSpec","getResult","onComplete","cause","String","active","clear","_applyDecoratedDescriptor","prototype","tracked","configurable","enumerable","writable","initializer","createJsonRenderUIStream"],"mappings":";;;;;;;AAqBO,SAASA,cAAcA,CAA+BC,QAAW,EAAK;AAC3E,EAAA,OAAOA,QAAQ;AACjB;;;ACFA;AACA;AACA;AACA;AACA,IAAaC,kBAAkB,IAAAC,MAAA,GAAxB,MAAMD,kBAAkB,CAAC;EAQ9BE,WAAWA,CAAkBC,OAAkC,EAAE;IAAA,IAAA,CAApCA,OAAkC,GAAlCA,OAAkC;AAAAC,IAAAA,0BAAA,eAAAC,WAAA,EAAA,IAAA,CAAA;AAAAD,IAAAA,0BAAA,sBAAAE,YAAA,EAAA,IAAA,CAAA;AAAAF,IAAAA,0BAAA,gBAAAG,YAAA,EAAA,IAAA,CAAA;IAAA,IAAA,CAHvDC,aAAa,GAA2B,IAAI;AAAA,IAAA,IAAA,CACnCC,OAAO,GAAA,MAAA;AAGtB,IAAA,IAAI,CAACA,OAAO,GAAGN,OAAO,CAACO,KAAK,IAAIC,UAAU,CAACD,KAAK,CAACE,IAAI,CAACD,UAAU,CAAC;AACnE,EAAA;EAEA,MAAME,IAAIA,CAACC,MAAc,EAAEC,WAAwC,GAAG,EAAE,EAAiB;IACvF,IAAI,CAACC,IAAI,EAAE;AACX,IAAA,MAAMC,KAAK,GAAG,IAAI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A;EAAAC,YAAA,EAAA,IAAA;EAAAC,UAAA,EAAA,IAAA;EAAAC,QAAA,EAAA,IAAA;AAAAC,EAAAA,WAAA,cAAA;AAAA,IAAA,OAAuB,IAAI;AAAA,EAAA;AAAA,CAAA,CAAA,EAAAzE,MAAA;;AA6FrC;AACO,SAAS0E,wBAAwBA,CAACxE,OAAkC,EAAsB;AAC/F,EAAA,OAAO,IAAIH,kBAAkB,CAACG,OAAO,CAAC;AACxC;;"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { tracked } from '@glimmer/tracking';
|
|
3
|
+
import { resolveAction, executeAction, createStateStore } from '@json-render/core';
|
|
4
|
+
|
|
5
|
+
function _applyDecoratedDescriptor(i, e, r, n, l) {
|
|
6
|
+
var a = {};
|
|
7
|
+
return Object.keys(n).forEach(function (i) {
|
|
8
|
+
a[i] = n[i];
|
|
9
|
+
}), a.enumerable = !!a.enumerable, a.configurable = !!a.configurable, ("value" in a || a.initializer) && (a.writable = true), a = r.slice().reverse().reduce(function (r, n) {
|
|
10
|
+
return n(i, e, r) || r;
|
|
11
|
+
}, a), void 0 === a.initializer ? (Object.defineProperty(i, e, a), null) : a;
|
|
12
|
+
}
|
|
13
|
+
function _initializerDefineProperty(e, i, r, l) {
|
|
14
|
+
r && Object.defineProperty(e, i, {
|
|
15
|
+
enumerable: r.enumerable,
|
|
16
|
+
configurable: r.configurable,
|
|
17
|
+
writable: r.writable,
|
|
18
|
+
value: r.initializer ? r.initializer.call(l) : void 0
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var _class, _descriptor;
|
|
23
|
+
let JsonRenderer = (_class = class JsonRenderer extends Component {
|
|
24
|
+
constructor(...args) {
|
|
25
|
+
super(...args);
|
|
26
|
+
_initializerDefineProperty(this, "revision", _descriptor, this);
|
|
27
|
+
this.currentStore = void 0;
|
|
28
|
+
this.unsubscribe = void 0;
|
|
29
|
+
this.seedState = void 0;
|
|
30
|
+
this.usingSuppliedStore = false;
|
|
31
|
+
this.emit = async (elementKey, eventName, payload) => {
|
|
32
|
+
const element = this.args.spec.elements[elementKey];
|
|
33
|
+
const binding = element?.on?.[eventName];
|
|
34
|
+
const bindings = Array.isArray(binding) ? binding : binding ? [binding] : [];
|
|
35
|
+
for (const binding of bindings) {
|
|
36
|
+
const action = resolveAction(binding, this.state);
|
|
37
|
+
if (action.action === 'setState' && typeof action.params.statePath === 'string') {
|
|
38
|
+
this.store.set(action.params.statePath, action.params.value);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (action.action === 'removeState' && typeof action.params.statePath === 'string') {
|
|
42
|
+
// StateStore exposes path writes, so removal currently clears its value.
|
|
43
|
+
this.store.set(action.params.statePath, undefined);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (action.action === 'pushState' && typeof action.params.statePath === 'string') {
|
|
47
|
+
const path = action.params.statePath;
|
|
48
|
+
const current = this.store.get(path);
|
|
49
|
+
this.store.set(path, [...(Array.isArray(current) ? current : []), action.params.value]);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const handler = this.args.actions?.[action.action];
|
|
53
|
+
if (handler) await executeAction({
|
|
54
|
+
action,
|
|
55
|
+
handler,
|
|
56
|
+
setState: (path, value) => this.store.set(path, value)
|
|
57
|
+
});
|
|
58
|
+
await this.args.onAction?.({
|
|
59
|
+
name: action.action,
|
|
60
|
+
params: action.params,
|
|
61
|
+
elementKey
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (bindings.length === 0) await this.args.onAction?.({
|
|
65
|
+
name: eventName,
|
|
66
|
+
params: payload ?? {},
|
|
67
|
+
elementKey
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
get store() {
|
|
72
|
+
const supplied = this.args.store;
|
|
73
|
+
const seedState = this.args.state ?? this.args.spec.state ?? {};
|
|
74
|
+
const storeChanged = supplied ? supplied !== this.currentStore : this.usingSuppliedStore || !this.currentStore || seedState !== this.seedState;
|
|
75
|
+
if (storeChanged) {
|
|
76
|
+
this.unsubscribe?.();
|
|
77
|
+
this.seedState = seedState;
|
|
78
|
+
this.currentStore = supplied ?? createStateStore(seedState);
|
|
79
|
+
this.usingSuppliedStore = Boolean(supplied);
|
|
80
|
+
this.unsubscribe = this.currentStore.subscribe(() => {
|
|
81
|
+
this.revision++;
|
|
82
|
+
this.args.onStateChange?.(this.currentStore.getSnapshot());
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return this.currentStore;
|
|
86
|
+
}
|
|
87
|
+
get state() {
|
|
88
|
+
// Read revision so Glimmer tracks external StateStore updates.
|
|
89
|
+
void this.revision;
|
|
90
|
+
return this.store.getSnapshot();
|
|
91
|
+
}
|
|
92
|
+
willDestroy() {
|
|
93
|
+
super.willDestroy();
|
|
94
|
+
this.unsubscribe?.();
|
|
95
|
+
}
|
|
96
|
+
}, _descriptor = _applyDecoratedDescriptor(_class.prototype, "revision", [tracked], {
|
|
97
|
+
configurable: true,
|
|
98
|
+
enumerable: true,
|
|
99
|
+
writable: true,
|
|
100
|
+
initializer: function () {
|
|
101
|
+
return 0;
|
|
102
|
+
}
|
|
103
|
+
}), _class);
|
|
104
|
+
|
|
105
|
+
export { JsonRenderer as J, _applyDecoratedDescriptor as _, _initializerDefineProperty as a };
|
|
106
|
+
//# sourceMappingURL=json-renderer-Chp6164I.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-renderer-Chp6164I.js","sources":["../src/components/json-renderer.ts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { createStateStore, executeAction, resolveAction, type ActionHandler, type Spec, type StateStore } from '@json-render/core';\nimport type { JsonRenderEvent, JsonRenderRegistry } from '../registry';\n\ninterface Args {\n spec: Spec;\n registry: JsonRenderRegistry;\n state?: Record<string, unknown>;\n store?: StateStore;\n loading?: boolean;\n onStateChange?: (state: Record<string, unknown>) => void;\n onAction?: (event: JsonRenderEvent) => void | Promise<void>;\n actions?: Record<string, ActionHandler>;\n}\n\nexport default class JsonRenderer extends Component<{ Args: Args }> {\n @tracked revision = 0;\n private currentStore?: StateStore;\n private unsubscribe?: () => void;\n private seedState?: Record<string, unknown>;\n private usingSuppliedStore = false;\n\n get store(): StateStore {\n const supplied = this.args.store;\n const seedState = this.args.state ?? this.args.spec.state ?? {};\n const storeChanged = supplied\n ? supplied !== this.currentStore\n : this.usingSuppliedStore || !this.currentStore || seedState !== this.seedState;\n if (storeChanged) {\n this.unsubscribe?.();\n this.seedState = seedState;\n this.currentStore = supplied ?? createStateStore(seedState);\n this.usingSuppliedStore = Boolean(supplied);\n this.unsubscribe = this.currentStore.subscribe(() => {\n this.revision++;\n this.args.onStateChange?.(this.currentStore!.getSnapshot());\n });\n }\n return this.currentStore;\n }\n\n get state(): Record<string, unknown> {\n // Read revision so Glimmer tracks external StateStore updates.\n void this.revision;\n return this.store.getSnapshot();\n }\n\n emit = async (elementKey: string, eventName: string, payload?: unknown): Promise<void> => {\n const element = this.args.spec.elements[elementKey];\n const binding = element?.on?.[eventName];\n const bindings = Array.isArray(binding) ? binding : binding ? [binding] : [];\n\n for (const binding of bindings) {\n const action = resolveAction(binding, this.state);\n if (action.action === 'setState' && typeof action.params.statePath === 'string') {\n this.store.set(action.params.statePath, action.params.value);\n continue;\n }\n if (action.action === 'removeState' && typeof action.params.statePath === 'string') {\n // StateStore exposes path writes, so removal currently clears its value.\n this.store.set(action.params.statePath, undefined);\n continue;\n }\n if (action.action === 'pushState' && typeof action.params.statePath === 'string') {\n const path = action.params.statePath;\n const current = this.store.get(path);\n this.store.set(path, [...(Array.isArray(current) ? current : []), action.params.value]);\n continue;\n }\n const handler = this.args.actions?.[action.action];\n if (handler) await executeAction({ action, handler, setState: (path, value) => this.store.set(path, value) });\n await this.args.onAction?.({ name: action.action, params: action.params, elementKey });\n }\n if (bindings.length === 0) await this.args.onAction?.({ name: eventName, params: (payload ?? {}) as Record<string, unknown>, elementKey });\n };\n\n willDestroy(): void {\n super.willDestroy();\n this.unsubscribe?.();\n }\n}\n"],"names":["JsonRenderer","_class","Component","constructor","args","_initializerDefineProperty","_descriptor","currentStore","unsubscribe","seedState","usingSuppliedStore","emit","elementKey","eventName","payload","element","spec","elements","binding","on","bindings","Array","isArray","action","resolveAction","state","params","statePath","store","set","value","undefined","path","current","get","handler","actions","executeAction","setState","onAction","name","length","supplied","storeChanged","createStateStore","Boolean","subscribe","revision","onStateChange","getSnapshot","willDestroy","_applyDecoratedDescriptor","prototype","tracked","configurable","enumerable","writable","initializer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEmI,IAc9GA,YAAY,IAAAC,MAAA,GAAlB,MAAMD,YAAY,SAASE,SAAS,CAAiB;AAAAC,EAAAA,WAAAA,CAAA,GAAAC,IAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAAA,IAAA,CAAA;AAAAC,IAAAA,0BAAA,mBAAAC,WAAA,EAAA,IAAA,CAAA;AAAA,IAAA,IAAA,CAE1DC,YAAY,GAAA,MAAA;AAAA,IAAA,IAAA,CACZC,WAAW,GAAA,MAAA;AAAA,IAAA,IAAA,CACXC,SAAS,GAAA,MAAA;IAAA,IAAA,CACTC,kBAAkB,GAAG,KAAK;IAAA,IAAA,CA2BlCC,IAAI,GAAG,OAAOC,UAAkB,EAAEC,SAAiB,EAAEC,OAAiB,KAAoB;MACxF,MAAMC,OAAO,GAAG,IAAI,CAACX,IAAI,CAACY,IAAI,CAACC,QAAQ,CAACL,UAAU,CAAC;AACnD,MAAA,MAAMM,OAAO,GAAGH,OAAO,EAAEI,EAAE,GAAGN,SAAS,CAAC;AACxC,MAAA,MAAMO,QAAQ,GAAGC,KAAK,CAACC,OAAO,CAACJ,OAAO,CAAC,GAAGA,OAAO,GAAGA,OAAO,GAAG,CAACA,OAAO,CAAC,GAAG,EAAE;AAE5E,MAAA,KAAK,MAAMA,OAAO,IAAIE,QAAQ,EAAE;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D,IAAI,CAACC,QAAQ,EAAE;AACf,QAAA,IAAI,CAAC3C,IAAI,CAAC4C,aAAa,GAAG,IAAI,CAACzC,YAAY,CAAE0C,WAAW,EAAE,CAAC;AAC7D,MAAA,CAAC,CAAC;AACJ,IAAA;IACA,OAAO,IAAI,CAAC1C,YAAY;AAC1B,EAAA;EAEA,IAAIkB,KAAKA,GAA4B;AACnC;IACA,KAAK,IAAI,CAACsB,QAAQ;AAClB,IAAA,OAAO,IAAI,CAACnB,KAAK,CAACqB,WAAW,EAAE;AACjC,EAAA;AA+BAC,EAAAA,WAAWA,GAAS;IAClB,KAAK,CAACA,WAAW,EAAE;IACnB,IAAI,CAAC1C,WAAW,IAAI;AACtB,EAAA;AACF,CAAC,EAAAF,WAAA,GAAA6C,yBAAA,CAAAlD,MAAA,CAAAmD,SAAA,EAAA,UAAA,EAAA,CAhEEC,OAAO,CAAA,EAAA;EAAAC,YAAA,EAAA,IAAA;EAAAC,UAAA,EAAA,IAAA;EAAAC,QAAA,EAAA,IAAA;AAAAC,EAAAA,WAAA,cAAA;AAAA,IAAA,OAAY,CAAC;AAAA,EAAA;AAAA,CAAA,CAAA,EAAAxD,MAAA;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-json-render",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Render json-render UI specs with Ember and Glimmer components",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"ember-addon",
|
|
8
|
+
"json-render",
|
|
9
|
+
"generative-ui",
|
|
10
|
+
"glimmer"
|
|
11
|
+
],
|
|
12
|
+
"license": "Apache-2.0",
|
|
13
|
+
"peerDependencies": {
|
|
14
|
+
"@glimmer/component": "^2.0.0",
|
|
15
|
+
"@json-render/core": "^0.23.0",
|
|
16
|
+
"ember-source": "^5.0.0 || ^6.0.0 || ^7.0.0"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@babel/core": "^7.29.0",
|
|
20
|
+
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
21
|
+
"@babel/plugin-proposal-decorators": "^7.29.0",
|
|
22
|
+
"@babel/plugin-transform-typescript": "^7.29.0",
|
|
23
|
+
"@embroider/addon-dev": "^8.0.0",
|
|
24
|
+
"@glint/template": "^1.5.0",
|
|
25
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
26
|
+
"babel-plugin-ember-template-compilation": "^4.0.0",
|
|
27
|
+
"rollup": "^4.6.0",
|
|
28
|
+
"typescript": "^5.7.0",
|
|
29
|
+
"@changesets/cli": "^2.27.0",
|
|
30
|
+
"@rollup/plugin-node-resolve": "^16.0.0"
|
|
31
|
+
},
|
|
32
|
+
"exports": {
|
|
33
|
+
".": "./dist/index.js",
|
|
34
|
+
"./*": "./dist/*.js",
|
|
35
|
+
"./addon-main.js": "./addon-main.cjs"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"addon-main.cjs",
|
|
39
|
+
"dist",
|
|
40
|
+
"README.md",
|
|
41
|
+
"LICENSE"
|
|
42
|
+
],
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@embroider/addon-shim": "^1.10.0"
|
|
45
|
+
},
|
|
46
|
+
"ember-addon": {
|
|
47
|
+
"version": 2,
|
|
48
|
+
"type": "addon",
|
|
49
|
+
"main": "addon-main.cjs"
|
|
50
|
+
},
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "https://github.com/Dhaulagiri/ember-json-render.git"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "rollup --config",
|
|
57
|
+
"changeset": "changeset",
|
|
58
|
+
"version-packages": "changeset version",
|
|
59
|
+
"release": "npm run build && changeset publish"
|
|
60
|
+
}
|
|
6
61
|
}
|