Skip to content

Commit 27a39a2

Browse files
Merge pull request #1962 from NullVoxPopuli/start-docs
Docs + <REPL> enhancements
2 parents 9908ebc + df2504e commit 27a39a2

File tree

95 files changed

+3239
-1437
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+3239
-1437
lines changed

.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*.md
44
*.json
55
renovate.json5
6-
docs/
6+
public/docs/
77

88
node_modules/
99
dist/

apps/repl/.template-lintrc.cjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ module.exports = {
77
{
88
files: ['**/*.gts', '**/*.gjs'],
99
rules: {
10+
// eh
11+
'no-inline-styles': 'off',
1012
// Handled by ESLint
1113
// otherwise gives false negatives
1214
'no-implicit-this': 'off',
1315
// false negatives due to being defined in js-scope
1416
'no-curly-component-invocation': 'off',
1517
// Don't care
1618
'no-forbidden-elements': 'off',
19+
// Incorrect, because it matches anything that looks like an arg, even if it's a string (intentionally)
20+
'no-potential-path-strings': 'off',
1721
},
1822
},
1923
{

apps/repl/app/app.ts

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
import 'limber-ui/theme.css';
21
import 'ember-statechart-component';
32
import './icons.ts';
43

5-
import Application from '@ember/application';
4+
import { isDevelopingApp, macroCondition } from '@embroider/macros';
65

7-
import Resolver from 'ember-resolver';
6+
import PageTitleService from 'ember-page-title/services/page-title';
7+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
8+
// @ts-ignore - no types
9+
import EmberResizeObserverService from 'ember-resize-observer-service/addon/services/resize-observer';
10+
import Application from 'ember-strict-application-resolver';
811

9-
import config from '#config';
12+
import '@nullvoxpopuli/limber-shared/theme.css';
1013

11-
import { registry } from './registry.ts';
14+
import Router from './router.ts';
1215

1316
// @babel/traverse (from babel-plugin-ember-template-imports)
1417
// accesses process.....
@@ -20,12 +23,36 @@ Object.assign(window, {
2023
});
2124

2225
export default class App extends Application {
23-
modulePrefix = config.modulePrefix;
24-
Resolver = Resolver.withModules(registry);
25-
26-
// LOG_RESOLVER = true;
27-
// LOG_ACTIVE_GENERATION = true;
28-
// LOG_TRANSITIONS = true;
29-
// LOG_TRANSITIONS_INTERNAL = true;
30-
// LOG_VIEW_LOOKUPS = true;
26+
modules = {
27+
'./router': Router,
28+
...import.meta.glob('./routes/{edit,index,application,error-404}.ts', { eager: true }),
29+
...import.meta.glob('./services/{editor,status}.ts', { eager: true }),
30+
...import.meta.glob('./controllers/*.ts', { eager: true }),
31+
...import.meta.glob('./templates/docs/*.gts', { eager: true }),
32+
...import.meta.glob('./templates/{application,edit,output,docs,error-404}.gts', {
33+
eager: true,
34+
}),
35+
36+
// /////////////////
37+
// To Eliminate
38+
// /////////////////
39+
40+
// Used by ember-container-query
41+
'./services/resize-observer': EmberResizeObserverService,
42+
43+
// /////////////////
44+
// To keep
45+
// /////////////////
46+
'./services/page-title': PageTitleService,
47+
};
48+
}
49+
50+
if (macroCondition(isDevelopingApp())) {
51+
Object.assign(App, {
52+
LOG_RESOLVER: true,
53+
LOG_ACTIVE_GENERATION: true,
54+
LOG_TRANSITIONS: true,
55+
LOG_TRANSITIONS_INTERNAL: true,
56+
LOG_VIEW_LOOKUPS: true,
57+
});
3158
}

apps/repl/app/controllers/application.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,6 @@ export default class ApplicationController extends Controller {
3333
*/
3434
'editor',
3535

36-
// Normally the editor will load automatically upon detecting
37-
// activity -- this is to optimize page-load (as editors can be heavy
38-
// when fully featured)
39-
//
40-
// when this is 'true', the user will have to click a button to start editing.
41-
// This can be useful when limber is embedded for code samples on documentation sites
42-
// where the primary use case is reading, rather than tinkering.
43-
'noAutoEditor',
44-
4536
// Normally the editor will load automatically upon detecting
4637
// activity -- this is to optimize page-load (as editors can be heavy
4738
// when fully featured)
@@ -50,6 +41,17 @@ export default class ApplicationController extends Controller {
5041
// requiring user interaction.
5142
'forceEditor',
5243

44+
// Determines how the editor should load.
45+
// Normally the editor will load automatically upon detecting interaction activity. This is to optimize page-load as editors can be heavy when fully featured.
46+
//
47+
// When this is set to:
48+
// - "force" - the editor will always load eagerly
49+
// - "onclick" - the editor will only load when the user clicks that they want to edit
50+
// - "never" - the editor is entirely disabled and the left-hand side is just a highlighted code snippet
51+
//
52+
//
53+
'editorLoad',
54+
5355
// This is the file format to use for the editor.
5456
//
5557
// Supported
@@ -72,5 +74,8 @@ export default class ApplicationController extends Controller {
7274
// Disable shiki highlighting on page load
7375
// this is primarily an optimization for tests
7476
'nohighlight',
77+
78+
// For dev only. When present, will tell certain components to use localhost
79+
'local',
7580
];
7681
}

apps/repl/app/languages.gts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ export function formatQPFrom(x: string | undefined | null): FormatQP {
203203

204204
assert(`Expected formatQP to be set`, x);
205205
assert(
206-
`Expected ${x} to be one of ${Object.keys(languages).join(', ')}`,
206+
`Expected ${JSON.stringify(x)} to be one of ${Object.keys(languages).join(', ')}`,
207207
Object.keys(languages).includes(x)
208208
);
209209

apps/repl/app/modifiers/-utils/highlighting.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export async function getHighlighter(): Promise<HighlighterGeneric<never, never>
7272
import('shiki/langs/vue.mjs'),
7373
import('shiki/langs/jsx.mjs'),
7474
import('shiki/langs/mermaid.mjs'),
75+
import('shiki/langs/bash.mjs'),
7576
],
7677
langAlias: {
7778
gjs: 'glimmer-js',

apps/repl/app/modifiers/highlighted.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ export default modifier<Signature>((element: Element, [code]) => {
5151
lang = 'markdown';
5252
}
5353

54-
if (!isAllowedFormat(lang)) {
54+
const isAllowed = isAllowedFormat(lang) || lang === 'bash';
55+
56+
if (!isAllowed) {
5557
return;
5658
}
5759

apps/repl/app/registry.ts

Lines changed: 0 additions & 55 deletions
This file was deleted.

apps/repl/app/router.ts

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,45 @@
1-
import EmberRouter from '@embroider/router';
1+
import EmbroiderRouter from '@embroider/router';
22

33
import { properLinks } from 'ember-primitives/proper-links';
44

55
import config from '#config';
66

77
@properLinks
8-
export default class Router extends EmberRouter {
8+
export default class Router extends EmbroiderRouter {
99
location = config.locationType;
1010
rootURL = config.rootURL;
1111
}
1212

13+
/**
14+
* See: https://github.com/embroider-build/embroider/issues/2521
15+
*/
16+
function bundle(name: string, loader: () => Promise<{ default: unknown }>[]) {
17+
return {
18+
names: [name],
19+
load: async () => {
20+
const [template, route, controller] = await Promise.all(loader());
21+
const slashName = name.replaceAll('.', '/');
22+
const results: Record<string, unknown> = {};
23+
24+
if (template) results[`limber/templates/${slashName}`] = template.default;
25+
if (route) results[`limber/routes/${slashName}`] = route.default;
26+
if (controller) results[`limber/controllers/${slashName}`] = controller.default;
27+
28+
return {
29+
default: results,
30+
};
31+
},
32+
};
33+
}
34+
35+
(window as any)._embroiderRouteBundles_ = [
36+
bundle('docs', () => [import('./templates/docs.gts')]),
37+
bundle('docs.repl-sdk', () => [import('./templates/docs/repl-sdk.gts')]),
38+
bundle('docs.ember-repl', () => [import('./templates/docs/ember-repl.gts')]),
39+
bundle('docs.embedding', () => [import('./templates/docs/embedding.gts')]),
40+
bundle('docs.editor', () => [import('./templates/docs/editor.gts')]),
41+
];
42+
1343
Router.map(function () {
1444
/**
1545
* The main editing UI is here
@@ -22,7 +52,12 @@ Router.map(function () {
2252
*/
2353
this.route('ember');
2454
this.route('output');
25-
// this.route('docs');
55+
this.route('docs', function () {
56+
this.route('repl-sdk');
57+
this.route('ember-repl');
58+
this.route('embedding');
59+
this.route('editor');
60+
});
2661

27-
this.route('error', { path: '*' });
62+
this.route('error-404', { path: '*' });
2863
});

apps/repl/app/routes/edit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ export default class EditRoute extends Route {
4646

4747
if (hasFileReference && hasFormat) {
4848
const format = formatQPFrom(qps.format as string);
49+
4950
const response = await fetch(qps.file as string);
5051
const text = await response.text();
5152

52-
transition.abort();
5353
this.editor.fileURIComponent.set(text, format);
5454
await this.editor.fileURIComponent.flush();
5555

0 commit comments

Comments
 (0)