repl-sdk 1.1.0 → 1.1.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "repl-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
"resolve.imports": "^2.0.3",
|
|
86
86
|
"tarparser": "^0.0.5",
|
|
87
87
|
"codemirror-lang-glimdown": "2.0.1",
|
|
88
|
-
"codemirror-lang-glimmer
|
|
89
|
-
"codemirror-lang-glimmer": "2.0.1"
|
|
88
|
+
"codemirror-lang-glimmer": "2.0.1",
|
|
89
|
+
"codemirror-lang-glimmer-js": "2.0.1"
|
|
90
90
|
},
|
|
91
91
|
"volta": {
|
|
92
92
|
"extends": "../../package.json"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { makeOwner } from './owner.js';
|
|
1
|
+
// import { makeOwner } from './owner.js';
|
|
2
|
+
import { renderApp } from './render-app-island.js';
|
|
2
3
|
|
|
3
4
|
let elementId = 0;
|
|
4
5
|
|
|
@@ -167,12 +168,43 @@ export async function compiler(config, api) {
|
|
|
167
168
|
|
|
168
169
|
element.setAttribute(attribute, '');
|
|
169
170
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
171
|
+
// ------------------------------------------------
|
|
172
|
+
// https://github.com/emberjs/ember.js/issues/21023
|
|
173
|
+
// ------------------------------------------------
|
|
174
|
+
//
|
|
175
|
+
// const { renderComponent } = await compiler.tryResolve('@ember/renderer');
|
|
176
|
+
//
|
|
177
|
+
// const owner = makeOwner(config.owner);
|
|
178
|
+
// const result = renderComponent(compiled, { into: element, owner });
|
|
179
|
+
//
|
|
180
|
+
// return () => result.destroy();
|
|
181
|
+
|
|
182
|
+
const [application, destroyable, resolver, router, route, testWaiters, runloop] =
|
|
183
|
+
await compiler.tryResolveAll([
|
|
184
|
+
'@ember/application',
|
|
185
|
+
'@ember/destroyable',
|
|
186
|
+
'ember-resolver',
|
|
187
|
+
'@ember/routing/router',
|
|
188
|
+
'@ember/routing/route',
|
|
189
|
+
'@ember/test-waiters',
|
|
190
|
+
'@ember/runloop',
|
|
191
|
+
]);
|
|
192
|
+
|
|
193
|
+
return renderApp({
|
|
194
|
+
element,
|
|
195
|
+
selector: `[${attribute}]`,
|
|
196
|
+
component: compiled,
|
|
197
|
+
log: compiler.announce,
|
|
198
|
+
modules: {
|
|
199
|
+
application,
|
|
200
|
+
destroyable,
|
|
201
|
+
resolver,
|
|
202
|
+
router,
|
|
203
|
+
route,
|
|
204
|
+
testWaiters,
|
|
205
|
+
runloop,
|
|
206
|
+
},
|
|
207
|
+
});
|
|
176
208
|
},
|
|
177
209
|
handlers: {
|
|
178
210
|
js: async (text) => {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { assert, isRecord } from '../../utils.js';
|
|
5
5
|
import { buildCodeFenceMetaUtils } from '../markdown/utils.js';
|
|
6
|
+
import { renderApp } from './render-app-island.js';
|
|
6
7
|
|
|
7
8
|
let elementId = 0;
|
|
8
9
|
|
|
@@ -96,15 +97,48 @@ export async function compiler(config, api) {
|
|
|
96
97
|
|
|
97
98
|
element.setAttribute(attribute, '');
|
|
98
99
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
// ------------------------------------------------
|
|
101
|
+
// https://github.com/emberjs/ember.js/issues/21023
|
|
102
|
+
// ------------------------------------------------
|
|
103
|
+
//
|
|
104
|
+
// const { renderComponent } = await compiler.tryResolve('@ember/renderer');
|
|
105
|
+
//
|
|
106
|
+
// const result = renderComponent(compiled, {
|
|
107
|
+
// into: element,
|
|
108
|
+
// owner: userOptions.owner,
|
|
109
|
+
// });
|
|
110
|
+
//
|
|
111
|
+
// const destroy = () => result.destroy();
|
|
112
|
+
const [application, destroyable, resolver, router, route, testWaiters, runloop] =
|
|
113
|
+
await compiler.tryResolveAll([
|
|
114
|
+
'@ember/application',
|
|
115
|
+
'@ember/destroyable',
|
|
116
|
+
'ember-resolver',
|
|
117
|
+
'@ember/routing/router',
|
|
118
|
+
'@ember/routing/route',
|
|
119
|
+
'@ember/test-waiters',
|
|
120
|
+
'@ember/runloop',
|
|
121
|
+
]);
|
|
122
|
+
|
|
123
|
+
// We don't want to await here, because we need to early
|
|
124
|
+
// return the element so that the app can render in to it.
|
|
125
|
+
// (Ember will only render in to an element if it's present in the DOM)
|
|
126
|
+
const destroy = await renderApp({
|
|
127
|
+
element,
|
|
128
|
+
selector: `[${attribute}]`,
|
|
129
|
+
component: compiled,
|
|
130
|
+
log: compiler.announce,
|
|
131
|
+
modules: {
|
|
132
|
+
application,
|
|
133
|
+
destroyable,
|
|
134
|
+
resolver,
|
|
135
|
+
router,
|
|
136
|
+
route,
|
|
137
|
+
testWaiters,
|
|
138
|
+
runloop,
|
|
139
|
+
},
|
|
104
140
|
});
|
|
105
141
|
|
|
106
|
-
const destroy = () => result.destroy();
|
|
107
|
-
|
|
108
142
|
/**
|
|
109
143
|
* @type {(() => void)[]}
|
|
110
144
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isRecord } from '../../utils.js';
|
|
2
|
-
import { makeOwner } from './owner.js';
|
|
2
|
+
// import { makeOwner } from './owner.js';
|
|
3
|
+
import { renderApp } from './render-app-island.js';
|
|
3
4
|
|
|
4
5
|
let elementId = 0;
|
|
5
6
|
|
|
@@ -65,11 +66,41 @@ export async function compiler(config, api) {
|
|
|
65
66
|
|
|
66
67
|
element.setAttribute(attribute, '');
|
|
67
68
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
// ------------------------------------------------
|
|
70
|
+
// https://github.com/emberjs/ember.js/issues/21023
|
|
71
|
+
// ------------------------------------------------
|
|
72
|
+
//
|
|
73
|
+
// const { renderComponent } = await compiler.tryResolve('@ember/renderer');
|
|
74
|
+
// const owner = makeOwner(config.owner);
|
|
75
|
+
// const result = renderComponent(compiled, { into: element, owner });
|
|
76
|
+
//
|
|
77
|
+
// return () => result.destroy();
|
|
78
|
+
const [application, destroyable, resolver, router, route, testWaiters, runloop] =
|
|
79
|
+
await compiler.tryResolveAll([
|
|
80
|
+
'@ember/application',
|
|
81
|
+
'@ember/destroyable',
|
|
82
|
+
'ember-resolver',
|
|
83
|
+
'@ember/routing/router',
|
|
84
|
+
'@ember/routing/route',
|
|
85
|
+
'@ember/test-waiters',
|
|
86
|
+
'@ember/runloop',
|
|
87
|
+
]);
|
|
71
88
|
|
|
72
|
-
return (
|
|
89
|
+
return renderApp({
|
|
90
|
+
element,
|
|
91
|
+
selector: `[${attribute}]`,
|
|
92
|
+
component: compiled,
|
|
93
|
+
log: compiler.announce,
|
|
94
|
+
modules: {
|
|
95
|
+
application,
|
|
96
|
+
destroyable,
|
|
97
|
+
resolver,
|
|
98
|
+
router,
|
|
99
|
+
route,
|
|
100
|
+
testWaiters,
|
|
101
|
+
runloop,
|
|
102
|
+
},
|
|
103
|
+
});
|
|
73
104
|
},
|
|
74
105
|
};
|
|
75
106
|
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/** @type {any} */
|
|
2
|
+
let bootWaiter;
|
|
3
|
+
/** @type {any} */
|
|
4
|
+
let createWaiter;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Wait to boot the app until the Element is in the DOM.
|
|
8
|
+
* because This old way of making a whole app requires that the element
|
|
9
|
+
* be present in the app.
|
|
10
|
+
*
|
|
11
|
+
* We really need renderComponent(...)
|
|
12
|
+
* https://github.com/emberjs/ember.js/pull/20781
|
|
13
|
+
*
|
|
14
|
+
* @param {{
|
|
15
|
+
* element: Element,
|
|
16
|
+
* modules: { [name: string]: any},
|
|
17
|
+
* selector: string,
|
|
18
|
+
* log: (type: 'error' | 'info', message: string) => void;
|
|
19
|
+
* component: unknown
|
|
20
|
+
* }} options
|
|
21
|
+
*/
|
|
22
|
+
export async function renderApp({ element, modules, selector, component, log }) {
|
|
23
|
+
const App = modules.application.default;
|
|
24
|
+
const registerDestructor = modules.destroyable.registerDestructor;
|
|
25
|
+
const destroy = modules.destroyable.destroy;
|
|
26
|
+
const Resolver = modules.resolver.default;
|
|
27
|
+
const Router = modules.router.default;
|
|
28
|
+
const Route = modules.route.default;
|
|
29
|
+
const schedule = modules.runloop.schedule;
|
|
30
|
+
|
|
31
|
+
bootWaiter ||= modules.testWaiters.buildWaiter('repl-output:waiting-for-boot');
|
|
32
|
+
createWaiter ||= modules.testWaiters.buildWaiter('repl-output:waiting-for-creation');
|
|
33
|
+
|
|
34
|
+
const bootToken = bootWaiter.beginAsync();
|
|
35
|
+
const createToken = createWaiter.beginAsync();
|
|
36
|
+
|
|
37
|
+
class EphemeralApp extends App {
|
|
38
|
+
modulePrefix = 'ephemeral-render-output';
|
|
39
|
+
rootElement = element;
|
|
40
|
+
Resolver = Resolver.withModules({
|
|
41
|
+
'ephemeral-render-output/templates/application': { default: component },
|
|
42
|
+
'ephemeral-render-output/routes/application': {
|
|
43
|
+
default: class Application extends Route {
|
|
44
|
+
/**
|
|
45
|
+
* @param {unknown[]} args
|
|
46
|
+
*/
|
|
47
|
+
constructor(...args) {
|
|
48
|
+
super(...args);
|
|
49
|
+
|
|
50
|
+
registerDestructor(() => {
|
|
51
|
+
bootWaiter.endAsync(bootToken);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
afterModel() {
|
|
55
|
+
schedule('afterRender', () => {
|
|
56
|
+
requestAnimationFrame(() => {
|
|
57
|
+
log('info', 'Ember Island Rendered');
|
|
58
|
+
bootWaiter.endAsync(bootToken);
|
|
59
|
+
createWaiter.endAsync(createToken);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
'ephemeral-render-output/router': {
|
|
66
|
+
default: class BoilerplateRouter extends Router {
|
|
67
|
+
location = 'none';
|
|
68
|
+
rootURL = '/';
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
log('info', 'Booting Ember Island');
|
|
75
|
+
|
|
76
|
+
const app = EphemeralApp.create({
|
|
77
|
+
rootElement: element,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
return () => {
|
|
81
|
+
destroy(app);
|
|
82
|
+
};
|
|
83
|
+
}
|