ember-repl 6.0.0 → 7.0.1
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.md +1 -1
- package/README.md +2 -404
- package/config/.try.mjs +87 -0
- package/config/addon-main.cjs +7 -0
- package/config/attw.json +7 -0
- package/config/babel.publish.config.cjs +29 -0
- package/config/ember-cli-update.json +21 -0
- package/config/rollup.config.mjs +44 -0
- package/config/testem.cjs +35 -0
- package/config/tsconfig.publish.json +15 -0
- package/config/vite.config.mjs +36 -0
- package/declarations/compile/Compiled.d.ts +7 -0
- package/declarations/compile/Compiled.d.ts.map +1 -0
- package/declarations/compile/compile.d.ts +17 -0
- package/declarations/compile/compile.d.ts.map +1 -0
- package/declarations/compile/state.d.ts +43 -0
- package/declarations/compile/state.d.ts.map +1 -0
- package/declarations/compile/types.d.ts +5 -12
- package/declarations/compile/types.d.ts.map +1 -1
- package/declarations/index.d.ts +6 -2
- package/declarations/index.d.ts.map +1 -1
- package/declarations/services/compiler.d.ts +94 -0
- package/declarations/services/compiler.d.ts.map +1 -0
- package/declarations/services/known-modules.d.ts +7 -0
- package/declarations/services/known-modules.d.ts.map +1 -0
- package/declarations/setup.d.ts +7 -0
- package/declarations/setup.d.ts.map +1 -0
- package/declarations/test-support.d.ts +20 -0
- package/declarations/test-support.d.ts.map +1 -0
- package/dist/_commonjsHelpers-BAGoDD49.js +37 -0
- package/dist/_commonjsHelpers-BAGoDD49.js.map +1 -0
- package/dist/babel-8wMrbxkT.js +110427 -0
- package/dist/babel-8wMrbxkT.js.map +1 -0
- package/dist/blank-line-Bzg2Qt4K.js +482 -0
- package/dist/blank-line-Bzg2Qt4K.js.map +1 -0
- package/dist/compile/Compiled.js +26 -0
- package/dist/compile/Compiled.js.map +1 -0
- package/dist/compile/compile.js +62 -0
- package/dist/compile/compile.js.map +1 -0
- package/dist/compile/state.js +75 -0
- package/dist/compile/state.js.map +1 -0
- package/dist/compile/utils.js +213 -2
- package/dist/compile/utils.js.map +1 -1
- package/dist/default-CoqAuVeH.js +4 -0
- package/dist/default-CoqAuVeH.js.map +1 -0
- package/dist/index-BTx1k6gT.js +323 -0
- package/dist/index-BTx1k6gT.js.map +1 -0
- package/dist/index-Bxzjtr16.js +87 -0
- package/dist/index-Bxzjtr16.js.map +1 -0
- package/dist/index-C371bO_b.js +1553 -0
- package/dist/index-C371bO_b.js.map +1 -0
- package/dist/index-C4AyeeIa.js +5721 -0
- package/dist/index-C4AyeeIa.js.map +1 -0
- package/dist/index-C8S2G0FH.js +1953 -0
- package/dist/index-C8S2G0FH.js.map +1 -0
- package/dist/index-CCcIVEUK.js +409 -0
- package/dist/index-CCcIVEUK.js.map +1 -0
- package/dist/index-CDSIcg03.js +9070 -0
- package/dist/index-CDSIcg03.js.map +1 -0
- package/dist/index-D8szzCn3.js +2 -0
- package/dist/index-D8szzCn3.js.map +1 -0
- package/dist/index-DBBNT106.js +2644 -0
- package/dist/index-DBBNT106.js.map +1 -0
- package/dist/index-DP_Su7Zc.js +362 -0
- package/dist/index-DP_Su7Zc.js.map +1 -0
- package/dist/index-DejgrVqh.js +11299 -0
- package/dist/index-DejgrVqh.js.map +1 -0
- package/dist/index-Dr5iYoKt.js +1551 -0
- package/dist/index-Dr5iYoKt.js.map +1 -0
- package/dist/index-DxolpiGq.js +3336 -0
- package/dist/index-DxolpiGq.js.map +1 -0
- package/dist/index-ZyJlPFQY.js +249 -0
- package/dist/index-ZyJlPFQY.js.map +1 -0
- package/dist/index-k6CfLgeq.js +26 -0
- package/dist/index-k6CfLgeq.js.map +1 -0
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/services/compiler.js +329 -0
- package/dist/services/compiler.js.map +1 -0
- package/dist/services/known-modules.js +123 -0
- package/dist/services/known-modules.js.map +1 -0
- package/dist/setup.js +15 -0
- package/dist/setup.js.map +1 -0
- package/dist/test-support.js +33 -0
- package/dist/test-support.js.map +1 -0
- package/package.json +117 -138
- package/src/compile/Compiled.ts +45 -0
- package/src/compile/compile.ts +89 -0
- package/src/compile/state.ts +88 -0
- package/src/compile/types.ts +14 -13
- package/src/index.ts +6 -2
- package/src/services/compiler.ts +401 -0
- package/src/services/known-modules.ts +130 -0
- package/src/setup.ts +26 -0
- package/src/test-support.ts +64 -0
- package/addon-main.cjs +0 -5
- package/declarations/__PRIVATE__.d.ts +0 -2
- package/declarations/__PRIVATE__.d.ts.map +0 -1
- package/declarations/compile/formats/gjs/babel.d.ts +0 -7
- package/declarations/compile/formats/gjs/babel.d.ts.map +0 -1
- package/declarations/compile/formats/gjs/eval.d.ts +0 -8
- package/declarations/compile/formats/gjs/eval.d.ts.map +0 -1
- package/declarations/compile/formats/gjs/index.d.ts +0 -24
- package/declarations/compile/formats/gjs/index.d.ts.map +0 -1
- package/declarations/compile/formats/gjs/known-modules.d.ts +0 -48
- package/declarations/compile/formats/gjs/known-modules.d.ts.map +0 -1
- package/declarations/compile/formats/hbs.d.ts +0 -17
- package/declarations/compile/formats/hbs.d.ts.map +0 -1
- package/declarations/compile/formats/markdown.d.ts +0 -22
- package/declarations/compile/formats/markdown.d.ts.map +0 -1
- package/declarations/compile/formats.d.ts +0 -17
- package/declarations/compile/formats.d.ts.map +0 -1
- package/declarations/compile/index.d.ts +0 -80
- package/declarations/compile/index.d.ts.map +0 -1
- package/declarations/test-support/index.d.ts +0 -2
- package/declarations/test-support/index.d.ts.map +0 -1
- package/dist/__PRIVATE__.js +0 -2
- package/dist/__PRIVATE__.js.map +0 -1
- package/dist/compile/formats/gjs/babel.js +0 -2
- package/dist/compile/formats/gjs/babel.js.map +0 -1
- package/dist/compile/formats/gjs/eval.js +0 -19
- package/dist/compile/formats/gjs/eval.js.map +0 -1
- package/dist/compile/formats/gjs/index.js +0 -122
- package/dist/compile/formats/gjs/index.js.map +0 -1
- package/dist/compile/formats/gjs/known-modules.js +0 -52
- package/dist/compile/formats/gjs/known-modules.js.map +0 -1
- package/dist/compile/formats/hbs.js +0 -93
- package/dist/compile/formats/hbs.js.map +0 -1
- package/dist/compile/formats/markdown.js +0 -266
- package/dist/compile/formats/markdown.js.map +0 -1
- package/dist/compile/formats.js +0 -173
- package/dist/compile/formats.js.map +0 -1
- package/dist/compile/index.js +0 -113
- package/dist/compile/index.js.map +0 -1
- package/dist/test-support/index.js +0 -8
- package/dist/test-support/index.js.map +0 -1
- package/src/__PRIVATE__.ts +0 -1
- package/src/compile/formats/gjs/babel.ts +0 -7
- package/src/compile/formats/gjs/eval.ts +0 -29
- package/src/compile/formats/gjs/index.ts +0 -153
- package/src/compile/formats/gjs/known-modules.ts +0 -49
- package/src/compile/formats/hbs.ts +0 -100
- package/src/compile/formats/markdown.ts +0 -345
- package/src/compile/formats.ts +0 -178
- package/src/compile/index.ts +0 -219
- package/src/test-support/index.ts +0 -5
package/LICENSE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2025
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
6
|
|
package/README.md
CHANGED
|
@@ -3,411 +3,9 @@
|
|
|
3
3
|
[](https://badge.fury.io/js/ember-repl)
|
|
4
4
|
[](https://github.com/NullVoxPopuli/ember-repl/actions/workflows/ci.yml)
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
StyleGuide for your design system.
|
|
6
|
+
## Documentation
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
ember + glimmer as well as `@babel/standalone`._
|
|
11
|
-
Your payload will be affected and Embroider is recommended
|
|
12
|
-
with maximum strictness enabled so automatic bundle splitting occurs to help
|
|
13
|
-
your app's initial time-to-interactive/etc stats.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
## Compatibility
|
|
17
|
-
|
|
18
|
-
* Ember.js v3.27 or above
|
|
19
|
-
* Ember CLI v3.27 or above
|
|
20
|
-
* Webpack v5 or above
|
|
21
|
-
* ember-auto-import v2 or above
|
|
22
|
-
* Node.js v14 or above
|
|
23
|
-
|
|
24
|
-
## Capabilities
|
|
25
|
-
|
|
26
|
-
* gjs
|
|
27
|
-
* hbs
|
|
28
|
-
* markdown with gjs/hbs blocks (glimdown)
|
|
29
|
-
|
|
30
|
-
## Installation
|
|
31
|
-
|
|
32
|
-
```
|
|
33
|
-
ember install ember-repl
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## Setup
|
|
37
|
-
|
|
38
|
-
This library uses babel, which does some goofy things in the browser.
|
|
39
|
-
You'll need to define a global `process` and `Buffer` somewhere in your app.
|
|
40
|
-
|
|
41
|
-
For example:
|
|
42
|
-
```js
|
|
43
|
-
// app/app.js
|
|
44
|
-
|
|
45
|
-
// @babel/traverse (from babel-plugin-ember-template-imports)
|
|
46
|
-
// accesses process.....
|
|
47
|
-
// maybe one day we can have a browser-only verison?
|
|
48
|
-
// But they aren't used.... so.. that's fun.
|
|
49
|
-
Object.assign(window, {
|
|
50
|
-
process: { env: {} },
|
|
51
|
-
Buffer: {},
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## Usage
|
|
57
|
-
|
|
58
|
-
### Compiling GJS
|
|
59
|
-
|
|
60
|
-
There are two ways to compile gjs text, imperatively via `compileJS`, where you manage the reactivity yourself.
|
|
61
|
-
Or `Compiled`, which is a resource that manages the reactivity for you.
|
|
62
|
-
|
|
63
|
-
#### Automatic reactivity via the Resource
|
|
64
|
-
|
|
65
|
-
Following the Resources documentation, you can use `Compiled` in both
|
|
66
|
-
template-only or class-backed contexts:
|
|
67
|
-
|
|
68
|
-
```js
|
|
69
|
-
import { Compiled } from 'ember-repl';
|
|
70
|
-
|
|
71
|
-
<template>
|
|
72
|
-
{{#let (Compiled @gjsText 'gjs') as |compileResult|}}
|
|
73
|
-
|
|
74
|
-
{{#if compileResult.error}}
|
|
75
|
-
an error! {{compileResult.error}}
|
|
76
|
-
{{/if}}
|
|
77
|
-
|
|
78
|
-
{{#if compileResult.component}}
|
|
79
|
-
<compileResult.component />
|
|
80
|
-
{{/if}}
|
|
81
|
-
|
|
82
|
-
{{/let}}
|
|
83
|
-
</template>
|
|
84
|
-
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
One advantage of using a backing JS context, is that you can utilize the `keepLatest`
|
|
88
|
-
resource so that when an error occurs, you could keep rendering the latest successful compile.
|
|
89
|
-
|
|
90
|
-
```js
|
|
91
|
-
import Component from '@glimmer/component';
|
|
92
|
-
import { Compiled } from 'ember-repl';
|
|
93
|
-
import { use } from 'ember-resources';
|
|
94
|
-
import { keepLatest } from 'reactiveweb/keep-latest';
|
|
95
|
-
|
|
96
|
-
export class Renderer extends Component {
|
|
97
|
-
@use compile = Compiled(() => this.args.gjsText, 'gjs');
|
|
98
|
-
|
|
99
|
-
@use latest = keepLatest({
|
|
100
|
-
value: () => this.compile.component,
|
|
101
|
-
when: () => this.compile.error,
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
<template>
|
|
105
|
-
{{#if this.compile.error}}
|
|
106
|
-
Error! {{this.compile.error}}
|
|
107
|
-
{{/if}}
|
|
108
|
-
|
|
109
|
-
{{! This will keep showing even when there is an error.
|
|
110
|
-
Which can help reduce visual jitter }}
|
|
111
|
-
{{#if this.latest.value}}
|
|
112
|
-
<this.latest.latest />
|
|
113
|
-
{{/if}}
|
|
114
|
-
|
|
115
|
-
</template>
|
|
116
|
-
}
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
#### Managing your own reactivity
|
|
121
|
-
|
|
122
|
-
```js
|
|
123
|
-
import Component from '@glimmer/component';
|
|
124
|
-
import { tracked } from '@glimmer/tracking';
|
|
125
|
-
import { compileJS } from 'ember-repl';
|
|
126
|
-
|
|
127
|
-
export class Renderer extends Component {
|
|
128
|
-
@tracked compileResult;
|
|
129
|
-
|
|
130
|
-
constructor(...args) {
|
|
131
|
-
super(...args);
|
|
132
|
-
|
|
133
|
-
compileJS('...').then((compileResult) => this.compileResult = compileResult);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
```
|
|
137
|
-
```hbs
|
|
138
|
-
{{#if this.compileResult.component}}
|
|
139
|
-
<this.compileResult.component />
|
|
140
|
-
{{/if}}
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
### Compiling HBS
|
|
145
|
-
|
|
146
|
-
#### Automatic reactivity via the Resource
|
|
147
|
-
|
|
148
|
-
The hbs utilities do not provide a utility Resource.
|
|
149
|
-
|
|
150
|
-
#### Managing your own reactivity
|
|
151
|
-
|
|
152
|
-
```js
|
|
153
|
-
import Component from '@glimmer/component';
|
|
154
|
-
import { compileHBS } from 'ember-repl';
|
|
155
|
-
|
|
156
|
-
export class Renderer extends Component {
|
|
157
|
-
compileResult = compileHBS(this.args.input);
|
|
158
|
-
}
|
|
159
|
-
```
|
|
160
|
-
```hbs
|
|
161
|
-
<this.compileResult.component />
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
### Compiling Markdown
|
|
166
|
-
|
|
167
|
-
There are two ways to compile markdown text, imperatively via `compile` (passing the `glimdown` format), where you manage the reactivity yourself.
|
|
168
|
-
Or `CompileMarkdown`, which is a resource that manages the reactivity for you.
|
|
169
|
-
|
|
170
|
-
#### Automatic reactivity via the Resource
|
|
171
|
-
|
|
172
|
-
Following the Resources documentation, you can use `Compiled` in both
|
|
173
|
-
template-only or class-backed contexts:
|
|
174
|
-
|
|
175
|
-
```js
|
|
176
|
-
import { Compiled } from 'ember-repl';
|
|
177
|
-
|
|
178
|
-
<template>
|
|
179
|
-
{{#let (Compiled @mdText 'glimdown') as |compileResult|}}
|
|
180
|
-
|
|
181
|
-
{{#if compileResult.error}}
|
|
182
|
-
an error! {{compileResult.error}}
|
|
183
|
-
{{/if}}
|
|
184
|
-
|
|
185
|
-
{{#if compileResult.component}}
|
|
186
|
-
<compileResult.component />
|
|
187
|
-
{{/if}}
|
|
188
|
-
|
|
189
|
-
{{/let}}
|
|
190
|
-
</template>
|
|
191
|
-
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
One advantage of using a backing JS context, is that you can utilize the `keepLatest`
|
|
195
|
-
resource so that when an error occurs, you could keep rendering the latest successful compile.
|
|
196
|
-
|
|
197
|
-
```js
|
|
198
|
-
import Component from '@glimmer/component';
|
|
199
|
-
import { Compiled } from 'ember-repl';
|
|
200
|
-
import { use } from 'ember-resources';
|
|
201
|
-
import { keepLatest } from 'reactiveweb/util/keep-latest';
|
|
202
|
-
|
|
203
|
-
export class Renderer extends Component {
|
|
204
|
-
@use compile = Compiled(() => this.args.mdText, 'glimdown');
|
|
205
|
-
|
|
206
|
-
@use latest = keepLatest({
|
|
207
|
-
value: () => this.compile.component,
|
|
208
|
-
when: () => this.compile.error,
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
<template>
|
|
212
|
-
{{#if this.compile.error}}
|
|
213
|
-
Error! {{this.compile.error}}
|
|
214
|
-
{{/if}}
|
|
215
|
-
|
|
216
|
-
{{! This will keep showing even when there is an error.
|
|
217
|
-
Which can help reduce visual jitter }}
|
|
218
|
-
{{#if this.latest.value}}
|
|
219
|
-
<this.latest.latest />
|
|
220
|
-
{{/if}}
|
|
221
|
-
|
|
222
|
-
</template>
|
|
223
|
-
}
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
#### Managing your own reactivity
|
|
228
|
-
|
|
229
|
-
```js
|
|
230
|
-
import Component from '@glimmer/component';
|
|
231
|
-
import { tracked } from '@glimmer/tracking';
|
|
232
|
-
import { compile } from 'ember-repl';
|
|
233
|
-
|
|
234
|
-
export class Renderer extends Component {
|
|
235
|
-
@tracked component;
|
|
236
|
-
@tracked error;
|
|
237
|
-
@tracked isCompiling;
|
|
238
|
-
|
|
239
|
-
constructor(...args) {
|
|
240
|
-
super(...args);
|
|
241
|
-
|
|
242
|
-
compile('...', {
|
|
243
|
-
format: 'glimdown', // or 'gjs' or 'hbs'
|
|
244
|
-
onSuccess: async (component) => {
|
|
245
|
-
this.error = null;
|
|
246
|
-
this.isCompiling = false;
|
|
247
|
-
this.component = component;
|
|
248
|
-
|
|
249
|
-
},
|
|
250
|
-
onError: async (error) => {
|
|
251
|
-
this.isCompiling = false;
|
|
252
|
-
this.error = error;
|
|
253
|
-
},
|
|
254
|
-
onCompileStart: async () => {
|
|
255
|
-
this.isCompiling = true;
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
```
|
|
261
|
-
```hbs
|
|
262
|
-
{{#if this.component}}
|
|
263
|
-
<this.component />
|
|
264
|
-
{{/if}}
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
### Using existing components
|
|
269
|
-
|
|
270
|
-
`ember-repl` is strict-mode only, so any component that you want to invoke
|
|
271
|
-
needs to be passed to the scope option of `compileHBS` or `compileJS`.
|
|
272
|
-
Following code is assuming that right next to our `Renderer` component
|
|
273
|
-
there is a component named `Bar`.
|
|
274
|
-
|
|
275
|
-
```js
|
|
276
|
-
import Component from '@glimmer/component';
|
|
277
|
-
import { compileHBS } from 'ember-repl';
|
|
278
|
-
import BarComponent from './bar'
|
|
279
|
-
|
|
280
|
-
export class Renderer extends Component {
|
|
281
|
-
compileResult = compileHBS(
|
|
282
|
-
'<Bar />',
|
|
283
|
-
{
|
|
284
|
-
scope: {
|
|
285
|
-
Bar: BarComponent
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
);
|
|
289
|
-
}
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
### Modifiers and Helpers
|
|
293
|
-
|
|
294
|
-
When writing components / demos / examples using this library, you must use
|
|
295
|
-
template-strict mode. Strict mode isn't available by default in proper ember
|
|
296
|
-
apps yet. The main difference in strict mode is that all globals must be imported.
|
|
297
|
-
|
|
298
|
-
Example of a template-only component that only provides a button:
|
|
299
|
-
|
|
300
|
-
<!-- If you're reading the source for this README, JSX is incorrect, but we
|
|
301
|
-
haven't yet PR'd to github for support for this style of writing ember -->
|
|
302
|
-
```jsx
|
|
303
|
-
import { on } from '@ember/modifier';
|
|
304
|
-
import { fn, hash } from '@ember/helper';
|
|
305
|
-
|
|
306
|
-
<template>
|
|
307
|
-
<button {{on 'click' (fn @callback (hash a=1 b=2))}}>...</button>
|
|
308
|
-
</template>
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
For a list of all the imports for things that are global in loose mode, view
|
|
312
|
-
the [Strict Mode RFC](https://github.com/emberjs/rfcs/blob/master/text/0496-handlebars-strict-mode.md#keywords)
|
|
313
|
-
|
|
314
|
-
### Expecting Errors
|
|
315
|
-
|
|
316
|
-
`compileJS` and `compileHBS` may result an an error.
|
|
317
|
-
|
|
318
|
-
To handle this, you'll want to make sure that rendering the `component` output is
|
|
319
|
-
guarded by either:
|
|
320
|
-
- the truthiness of `component` (which is undefined if `error` is present)
|
|
321
|
-
- the falsiness of `error` (which is undefined if compilation was successful)
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
Depending on your desired UI/UX, how the async build of updates to input is conveyed
|
|
325
|
-
may vary and is not provided by this library.
|
|
326
|
-
Here is an example of a way that someone could handle rendering with `compileJS`:
|
|
327
|
-
|
|
328
|
-
```js
|
|
329
|
-
export default class AwaitBuild extends Component {
|
|
330
|
-
@tracked component;
|
|
331
|
-
@tracked error;
|
|
332
|
-
|
|
333
|
-
constructor(...args) {
|
|
334
|
-
super(...args);
|
|
335
|
-
|
|
336
|
-
compileJS(args.inputText)
|
|
337
|
-
.then(({ component, error }) => {
|
|
338
|
-
this.component = component;
|
|
339
|
-
this.error = error;
|
|
340
|
-
})
|
|
341
|
-
.catch(error => this.error = error);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
get isPending() {
|
|
345
|
-
return !this.component';
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
```
|
|
349
|
-
```hbs
|
|
350
|
-
{{#if this.error}}
|
|
351
|
-
Error: {{this.error}}
|
|
352
|
-
{{else if this.isPending}}
|
|
353
|
-
Building...
|
|
354
|
-
{{else}}
|
|
355
|
-
<this.component />
|
|
356
|
-
{{/if}}
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
**A Note on Capabilities**
|
|
361
|
-
This library currently uses a CommonJS technique for modules, but as browser-support
|
|
362
|
-
permits, this library will eventually switch to using a web-worker with an import-map
|
|
363
|
-
for lightning fast, `eval`-free REPLing. (But the same security caution below would
|
|
364
|
-
still apply)
|
|
365
|
-
|
|
366
|
-
### API
|
|
367
|
-
|
|
368
|
-
#### Methods
|
|
369
|
-
|
|
370
|
-
- `compileJS`: async, returns `compileResult` - compiles a single JS file
|
|
371
|
-
uses the syntax from [ember-template-imports](https://github.com/ember-template-imports/ember-template-imports)
|
|
372
|
-
- `compileHBS`: returns `compileResult` - compiles a template-only component with no dependencies
|
|
373
|
-
- `invocationOf`: `string` - converts hyphenated text to an `<AngleBracketInvocation />`
|
|
374
|
-
- `nameFor`: `string` - generates a component-safe GUID-like derivation from code
|
|
375
|
-
|
|
376
|
-
#### Properties
|
|
377
|
-
|
|
378
|
-
```ts
|
|
379
|
-
interface CompileResult {
|
|
380
|
-
// invokable from templates
|
|
381
|
-
component?: unknown;
|
|
382
|
-
|
|
383
|
-
// if there is a compilation error, this will be non-falsey
|
|
384
|
-
error?: Error;
|
|
385
|
-
|
|
386
|
-
// the name assigned to the input text via UUIDv5
|
|
387
|
-
name: string;
|
|
388
|
-
}
|
|
389
|
-
```
|
|
390
|
-
|
|
391
|
-
### Using in an app that uses Embroider
|
|
392
|
-
|
|
393
|
-
If you are using the `Webpack` packager, you will need these settings:
|
|
394
|
-
|
|
395
|
-
```js
|
|
396
|
-
packagerOptions: {
|
|
397
|
-
webpackConfig: {
|
|
398
|
-
node: {
|
|
399
|
-
global: false,
|
|
400
|
-
__filename: true,
|
|
401
|
-
__dirname: true,
|
|
402
|
-
},
|
|
403
|
-
resolve: {
|
|
404
|
-
fallback: {
|
|
405
|
-
path: 'path-browserify',
|
|
406
|
-
},
|
|
407
|
-
},
|
|
408
|
-
},
|
|
409
|
-
},
|
|
410
|
-
```
|
|
8
|
+
Docs are here: https://limber.glimdown.com/docs/ember-repl
|
|
411
9
|
|
|
412
10
|
## Security
|
|
413
11
|
|
package/config/.try.mjs
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// When building your addon for older Ember versions you need to have the required files
|
|
2
|
+
const compatFiles = {
|
|
3
|
+
"ember-cli-build.js": `const EmberApp = require('ember-cli/lib/broccoli/ember-app');
|
|
4
|
+
const { compatBuild } = require('@embroider/compat');
|
|
5
|
+
module.exports = async function (defaults) {
|
|
6
|
+
const { buildOnce } = await import('@embroider/vite');
|
|
7
|
+
let app = new EmberApp(defaults);
|
|
8
|
+
return compatBuild(app, buildOnce);
|
|
9
|
+
};`,
|
|
10
|
+
"config/optional-features.json": JSON.stringify({
|
|
11
|
+
"application-template-wrapper": false,
|
|
12
|
+
"default-async-observers": true,
|
|
13
|
+
"jquery-integration": false,
|
|
14
|
+
"template-only-glimmer-components": true,
|
|
15
|
+
"no-implicit-route-model": true,
|
|
16
|
+
}),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const compatDeps = {
|
|
20
|
+
"@embroider/compat": "^4.0.3",
|
|
21
|
+
"ember-cli": "^5.12.0",
|
|
22
|
+
"ember-auto-import": "^2.10.0",
|
|
23
|
+
"@ember/optional-features": "^2.2.0",
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default {
|
|
27
|
+
scenarios: [
|
|
28
|
+
{
|
|
29
|
+
name: "ember-lts-5.8",
|
|
30
|
+
npm: {
|
|
31
|
+
devDependencies: {
|
|
32
|
+
"ember-source": "~5.8.0",
|
|
33
|
+
...compatDeps,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
env: {
|
|
37
|
+
ENABLE_COMPAT_BUILD: true,
|
|
38
|
+
},
|
|
39
|
+
files: compatFiles,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "ember-lts-5.12",
|
|
43
|
+
npm: {
|
|
44
|
+
devDependencies: {
|
|
45
|
+
"ember-source": "~5.12.0",
|
|
46
|
+
...compatDeps,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
env: {
|
|
50
|
+
ENABLE_COMPAT_BUILD: true,
|
|
51
|
+
},
|
|
52
|
+
files: compatFiles,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: `ember-lts-6.4`,
|
|
56
|
+
npm: {
|
|
57
|
+
devDependencies: {
|
|
58
|
+
"ember-source": `npm:ember-source@~6.4.0`,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: `ember-latest`,
|
|
64
|
+
npm: {
|
|
65
|
+
devDependencies: {
|
|
66
|
+
"ember-source": `npm:ember-source@latest`,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: `ember-beta`,
|
|
72
|
+
npm: {
|
|
73
|
+
devDependencies: {
|
|
74
|
+
"ember-source": `npm:ember-source@beta`,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: `ember-alpha`,
|
|
80
|
+
npm: {
|
|
81
|
+
devDependencies: {
|
|
82
|
+
"ember-source": `npm:ember-source@alpha`,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
};
|
package/config/attw.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This babel.config is only used for publishing.
|
|
3
|
+
*
|
|
4
|
+
* For local dev experience, see the babel.config
|
|
5
|
+
*/
|
|
6
|
+
module.exports = {
|
|
7
|
+
plugins: [
|
|
8
|
+
[
|
|
9
|
+
'@babel/plugin-transform-typescript',
|
|
10
|
+
{
|
|
11
|
+
allExtensions: true,
|
|
12
|
+
allowDeclareFields: true,
|
|
13
|
+
onlyRemoveTypeImports: true,
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
[
|
|
17
|
+
'module:decorator-transforms',
|
|
18
|
+
{
|
|
19
|
+
runtime: {
|
|
20
|
+
import: 'decorator-transforms/runtime-esm',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
],
|
|
25
|
+
|
|
26
|
+
generatorOpts: {
|
|
27
|
+
compact: false,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "1.0.0",
|
|
3
|
+
"projectName": "ember-repl",
|
|
4
|
+
"packages": [
|
|
5
|
+
{
|
|
6
|
+
"name": "@ember/addon-blueprint",
|
|
7
|
+
"version": "0.8.1",
|
|
8
|
+
"blueprints": [
|
|
9
|
+
{
|
|
10
|
+
"name": "@ember/addon-blueprint",
|
|
11
|
+
"isBaseBlueprint": true,
|
|
12
|
+
"options": [
|
|
13
|
+
"--ci-provider=github",
|
|
14
|
+
"--pnpm",
|
|
15
|
+
"--typescript"
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Addon } from "@embroider/addon-dev/rollup";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
|
|
4
|
+
import { babel } from "@rollup/plugin-babel";
|
|
5
|
+
import cjs from "@rollup/plugin-commonjs";
|
|
6
|
+
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
|
7
|
+
import nodePolyfills from "rollup-plugin-node-polyfills";
|
|
8
|
+
|
|
9
|
+
const addon = new Addon({
|
|
10
|
+
srcDir: "src",
|
|
11
|
+
destDir: "dist",
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const babelConfig = resolve(import.meta.dirname, "./babel.publish.config.cjs");
|
|
15
|
+
const tsConfig = resolve(import.meta.dirname, "./tsconfig.publish.json");
|
|
16
|
+
|
|
17
|
+
export default {
|
|
18
|
+
output: addon.output(),
|
|
19
|
+
plugins: [
|
|
20
|
+
addon.publicEntrypoints(["**/*.js"]),
|
|
21
|
+
addon.dependencies(),
|
|
22
|
+
babel({
|
|
23
|
+
extensions: [".js", ".gjs", ".ts", ".gts"],
|
|
24
|
+
babelHelpers: "bundled",
|
|
25
|
+
configFile: babelConfig,
|
|
26
|
+
}),
|
|
27
|
+
nodeResolve({
|
|
28
|
+
browser: true,
|
|
29
|
+
preferBuiltins: false,
|
|
30
|
+
// Defaults for this plugin are for node...
|
|
31
|
+
exportConditions: ["browser", "module", "default"],
|
|
32
|
+
}),
|
|
33
|
+
// This is needed because babel doesn't ship a proper browser bundle...
|
|
34
|
+
nodePolyfills(),
|
|
35
|
+
// line-column, unified (extend)...
|
|
36
|
+
cjs(),
|
|
37
|
+
|
|
38
|
+
// Emit .d.ts declaration files
|
|
39
|
+
addon.declarations("declarations", `pnpm ember-tsc --declaration --project ${tsConfig}`),
|
|
40
|
+
|
|
41
|
+
// Remove leftover build artifacts when starting a new build.
|
|
42
|
+
addon.clean(),
|
|
43
|
+
],
|
|
44
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_BROWSER = 'Chrome';
|
|
4
|
+
|
|
5
|
+
if (typeof module !== 'undefined') {
|
|
6
|
+
const CI_BROWSER = process.env.CI_BROWSER || DEFAULT_BROWSER;
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
test_page: 'tests/index.html?hidepassed',
|
|
10
|
+
cwd: 'dist-tests',
|
|
11
|
+
disable_watching: true,
|
|
12
|
+
launch_in_ci: [CI_BROWSER],
|
|
13
|
+
launch_in_dev: [DEFAULT_BROWSER],
|
|
14
|
+
browser_start_timeout: 120,
|
|
15
|
+
browser_args: {
|
|
16
|
+
Firefox: {
|
|
17
|
+
mode: 'ci',
|
|
18
|
+
// https://github.com/SeleniumHQ/selenium/pull/6075
|
|
19
|
+
args: ['-headless', '--width=1440', '--height=900'],
|
|
20
|
+
},
|
|
21
|
+
Chrome: {
|
|
22
|
+
ci: [
|
|
23
|
+
// --no-sandbox is needed when running Chrome inside a container
|
|
24
|
+
process.env.CI ? '--no-sandbox' : null,
|
|
25
|
+
'--headless=new',
|
|
26
|
+
'--disable-dev-shm-usage',
|
|
27
|
+
'--disable-software-rasterizer',
|
|
28
|
+
'--mute-audio',
|
|
29
|
+
'--remote-debugging-port=0',
|
|
30
|
+
'--window-size=1440,900',
|
|
31
|
+
].filter(Boolean),
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This tsconfig is only used for publishing.
|
|
3
|
+
*
|
|
4
|
+
* For local dev experience, see the tsconfig.json
|
|
5
|
+
*/
|
|
6
|
+
{
|
|
7
|
+
"extends": "@ember/library-tsconfig",
|
|
8
|
+
"include": ["../src", "../unpublished-development-types"],
|
|
9
|
+
"compilerOptions": {
|
|
10
|
+
"baseUrl": "../",
|
|
11
|
+
"allowJs": true,
|
|
12
|
+
"declarationDir": "../declarations",
|
|
13
|
+
"types": ["ember-source/types"]
|
|
14
|
+
}
|
|
15
|
+
}
|