Skip to content

Commit 0774f9c

Browse files
authored
Merge pull request #1645 from glimmerjs/feature/error-recovery-redux-pt2
Move from const enums to consts
2 parents 57e59c4 + 5636a8f commit 0774f9c

File tree

105 files changed

+2640
-1862
lines changed

Some content is hidden

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

105 files changed

+2640
-1862
lines changed

benchmark/benchmarks/krausest/vite.config.mts

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export default defineConfig({
2222
resolve: {
2323
alias: {
2424
'@glimmer-workspace/benchmark-env': '@glimmer-workspace/benchmark-env/index.ts',
25-
'@glimmer/debug': packagePath('@glimmer/debug'),
2625
'@glimmer/runtime': packagePath('@glimmer/runtime'),
2726
'@/components': path.join(currentPath, 'lib', 'components'),
2827
'@/utils': path.join(currentPath, 'lib', 'utils'),

bin/build-verify.mjs

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ const FORBIDDEN = [
2121
'CheckOr',
2222
'CheckFunction',
2323
'CheckObject',
24+
25+
'@glimmer/debug',
26+
'@glimmer/constants',
27+
'@glimmer/debug-util',
2428
];
2529

26-
const IGNORED_DIRS = [`@glimmer/debug`];
30+
const IGNORED_DIRS = [`@glimmer/debug`, `@glimmer/constants`, `@glimmer/debug-util`];
2731

2832
let files = await globby(resolve(currentDir, '../../packages/**/dist/**/index.js'), {
2933
ignore: ['node_modules', '**/node_modules'],

packages/@glimmer-workspace/build/lib/config.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,13 @@ export function typescript(pkg, config) {
114114
const EXTERNAL_OPTIONS = [
115115
[
116116
'is',
117-
['tslib', '@glimmer/local-debug-flags', '@glimmer/debug', '@glimmer/debug-util'],
117+
[
118+
'tslib',
119+
'@glimmer/local-debug-flags',
120+
'@glimmer/constants',
121+
'@glimmer/debug',
122+
'@glimmer/debug-util',
123+
],
118124
'inline',
119125
],
120126
['is', ['@handlebars/parser', 'simple-html-tokenizer', 'babel-plugin-debug-macros'], 'external'],

packages/@glimmer-workspace/integration-tests/lib/dom/simple-utils.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
import type {
2+
COMMENT_NODE,
3+
DOCUMENT_FRAGMENT_NODE,
4+
DOCUMENT_NODE,
5+
TEXT_NODE,
6+
} from '@glimmer/constants';
17
import type {
28
Maybe,
39
Nullable,
@@ -10,8 +16,8 @@ import type {
1016
SimpleNode,
1117
SimpleText,
1218
} from '@glimmer/interfaces';
13-
import type { COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, TEXT_NODE } from '@glimmer/util';
14-
import { clearElement, ELEMENT_NODE, INSERT_AFTER_BEGIN } from '@glimmer/util';
19+
import { ELEMENT_NODE, INSERT_AFTER_BEGIN } from '@glimmer/constants';
20+
import { clearElement } from '@glimmer/util';
1521
import Serializer from '@simple-dom/serializer';
1622
import voidMap from '@simple-dom/void-map';
1723

packages/@glimmer-workspace/integration-tests/lib/modes/rehydration/builder.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Cursor, ElementBuilder, Environment, SimpleNode } from '@glimmer/interfaces';
2+
import { COMMENT_NODE, ELEMENT_NODE } from '@glimmer/constants';
23
import { RehydrateBuilder } from '@glimmer/runtime';
3-
import { COMMENT_NODE, ELEMENT_NODE } from '@glimmer/util';
44

55
export class DebugRehydrationBuilder extends RehydrateBuilder {
66
clearedNodes: SimpleNode[] = [];
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,60 @@
11
/* eslint-disable no-console */
2+
import type { Expand } from '@glimmer/interfaces';
23
import { debug } from '@glimmer/validator';
34
import { autoRegister } from 'js-reporters';
5+
import { default as QUnit } from 'qunit';
46

57
export async function setupQunit() {
6-
const qunit = await import('qunit');
8+
const qunitLib: QUnit = await import('qunit');
79
await import('qunit/qunit/qunit.css');
810

11+
const testing = Testing.withConfig(
12+
{
13+
id: 'smoke_tests',
14+
label: 'Smoke Tests',
15+
tooltip: 'Enable Smoke Tests',
16+
},
17+
{
18+
id: 'ci',
19+
label: 'CI Mode',
20+
tooltip:
21+
'CI mode emits tap output and makes tests run faster by sacrificing UI responsiveness',
22+
},
23+
{
24+
id: 'enable_internals_logging',
25+
label: 'Log Deep Internals',
26+
tooltip: 'Logs internals that are used in the development of the trace logs',
27+
},
28+
29+
{
30+
id: 'enable_trace_logging',
31+
label: 'Trace Logs',
32+
tooltip: 'Trace logs emit information about the internal VM state',
33+
},
34+
35+
{
36+
id: 'enable_subtle_logging',
37+
label: '+ Subtle',
38+
tooltip:
39+
'Subtle logs include unchanged information and other details not necessary for normal debugging',
40+
},
41+
42+
{
43+
id: 'enable_trace_explanations',
44+
label: '+ Explanations',
45+
tooltip: 'Also explain the trace logs',
46+
}
47+
);
48+
949
const runner = autoRegister();
10-
// @ts-expect-error qunit types don't expose "reporters"
11-
const tap = qunit.reporters.tap;
12-
tap.init(runner, { log: console.info });
13-
14-
QUnit.config.urlConfig.push({
15-
id: 'smoke_tests',
16-
label: 'Enable Smoke Tests',
17-
tooltip: 'Enable Smoke Tests',
18-
});
1950

20-
QUnit.config.urlConfig.push({
21-
id: 'ci',
22-
label: 'Enable CI Mode',
23-
tooltip: 'CI mode makes tests run faster by sacrificing UI responsiveness',
51+
testing.begin(() => {
52+
if (testing.config.ci) {
53+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
54+
// @ts-ignore
55+
const tap = qunitLib.reporters.tap;
56+
tap.init(runner, { log: console.info });
57+
}
2458
});
2559

2660
await Promise.resolve();
@@ -34,7 +68,7 @@ export async function setupQunit() {
3468

3569
console.log(`[HARNESS] ci=${hasFlag('ci')}`);
3670

37-
QUnit.testStart(() => {
71+
testing.testStart(() => {
3872
debug.resetTrackingTransaction?.();
3973
});
4074

@@ -52,44 +86,94 @@ export async function setupQunit() {
5286
});
5387

5488
let start = performance.now();
55-
qunit.testDone(async () => {
89+
qunitLib.testDone(async () => {
5690
let gap = performance.now() - start;
5791
if (gap > 200) {
5892
await pause();
5993
start = performance.now();
6094
}
6195
});
6296

63-
qunit.moduleDone(pause);
97+
qunitLib.moduleDone(pause);
6498
}
6599

66-
// @ts-expect-error missing in types, does exist: https://api.qunitjs.com/callbacks/QUnit.on/#the-testend-event
67-
QUnit.on('testEnd', (testEnd) => {
68-
if (testEnd.status === 'failed') {
69-
testEnd.errors.forEach((assertion: any) => {
70-
console.error(assertion.stack);
71-
// message: speedometer
72-
// actual: 75
73-
// expected: 88
74-
// stack: at dmc.test.js:12
75-
});
76-
}
77-
});
78-
79-
qunit.done(({ failed }) => {
80-
if (failed > 0) {
81-
console.log('[HARNESS] fail');
82-
} else {
83-
console.log('[HARNESS] done');
84-
}
100+
qunitLib.done(() => {
101+
console.log('[HARNESS] done');
85102
});
86103

87104
return {
88105
smokeTest: hasFlag('smoke_test'),
89106
};
90107
}
91108

109+
class Testing<Q extends typeof QUnit> {
110+
static withConfig<const C extends readonly UrlConfig[]>(...configs: C): Testing<WithConfig<C>> {
111+
return new Testing(withConfig(...configs));
112+
}
113+
114+
readonly #qunit: Q;
115+
116+
constructor(qunit: Q) {
117+
this.#qunit = qunit;
118+
}
119+
120+
get config(): Q['config'] {
121+
return this.#qunit.config;
122+
}
123+
124+
readonly begin = (begin: (details: QUnit.BeginDetails) => void | Promise<void>): void => {
125+
this.#qunit.begin(begin);
126+
};
127+
128+
readonly testStart = (
129+
callback: (details: QUnit.TestStartDetails) => void | Promise<void>
130+
): void => {
131+
this.#qunit.testStart(callback);
132+
};
133+
}
134+
92135
function hasFlag(flag: string): boolean {
136+
return hasSpecificFlag(flag);
137+
}
138+
139+
function hasSpecificFlag(flag: string): boolean {
93140
let location = typeof window !== 'undefined' && window.location;
94141
return location && new RegExp(`[?&]${flag}`).test(location.search);
95142
}
143+
144+
// eslint-disable-next-line unused-imports/no-unused-vars
145+
function getSpecificFlag(flag: string): string | undefined {
146+
let location = typeof window !== 'undefined' && window.location;
147+
if (!location) {
148+
return undefined;
149+
}
150+
151+
const matches = new RegExp(`[?&]${flag}=([^&]*)`).exec(location.search);
152+
return matches ? matches[1] : undefined;
153+
}
154+
155+
interface UrlConfig {
156+
id: string;
157+
label?: string | undefined;
158+
tooltip?: string | undefined;
159+
value?: string | string[] | { [key: string]: string } | undefined;
160+
}
161+
162+
type WithConfig<C extends readonly UrlConfig[]> = typeof QUnit & {
163+
config: QUnit['config'] & {
164+
[P in C[number]['id']]: string | undefined;
165+
};
166+
};
167+
168+
function withConfig<const C extends readonly UrlConfig[]>(...configs: C): Expand<WithConfig<C>> {
169+
for (let config of configs) {
170+
QUnit.config.urlConfig.push(config);
171+
}
172+
173+
const index = QUnit.config.urlConfig.findIndex((c) => c.id === 'noglobals');
174+
if (index !== -1) {
175+
QUnit.config.urlConfig.splice(index, 1);
176+
}
177+
178+
return QUnit as any;
179+
}

packages/@glimmer-workspace/integration-tests/lib/snapshot.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Nullable, SimpleElement, SimpleNode } from '@glimmer/interfaces';
22
import type { EndTag, Token } from 'simple-html-tokenizer';
3+
import { COMMENT_NODE, TEXT_NODE } from '@glimmer/constants';
34
import { castToSimple, unwrap } from '@glimmer/debug-util';
4-
import { COMMENT_NODE, TEXT_NODE } from '@glimmer/util';
55
import { tokenize } from 'simple-html-tokenizer';
66

77
import { replaceHTML, toInnerHTML } from './dom/simple-utils';

packages/@glimmer-workspace/integration-tests/lib/suites/initial-render.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { SimpleElement } from '@glimmer/interfaces';
2+
import { NS_SVG } from '@glimmer/constants';
23
import { castToBrowser, checkNode, unwrap } from '@glimmer/debug-util';
3-
import { NS_SVG, strip } from '@glimmer/util';
4+
import { strip } from '@glimmer/util';
45

56
import { assertNodeTagName } from '../dom/assertions';
67
import { firstElementChild, getElementsByTagName } from '../dom/simple-utils';

packages/@glimmer-workspace/integration-tests/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"simple-html-tokenizer": "^0.5.11"
3535
},
3636
"devDependencies": {
37+
"@glimmer/constants": "workspace:*",
3738
"@glimmer/debug-util": "workspace:*",
3839
"@glimmer/local-debug-flags": "workspace:*",
3940
"@types/js-reporters": "workspace:*",

packages/@glimmer-workspace/integration-tests/test/attributes-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { SimpleElement } from '@glimmer/interfaces';
2+
import { NS_SVG } from '@glimmer/constants';
23
import { castToBrowser, expect } from '@glimmer/debug-util';
34
import { normalizeProperty } from '@glimmer/runtime';
4-
import { NS_SVG } from '@glimmer/util';
55

66
import { assertingElement, hasAttribute, jitSuite, RenderTest, test, tracked } from '..';
77

packages/@glimmer-workspace/integration-tests/test/chaos-rehydration-test.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Dict, Nullable, SimpleElement } from '@glimmer/interfaces';
2+
import { COMMENT_NODE, ELEMENT_NODE } from '@glimmer/constants';
23
import { castToBrowser, castToSimple, expect } from '@glimmer/debug-util';
3-
import { COMMENT_NODE, ELEMENT_NODE, isObject, LOCAL_LOGGER } from '@glimmer/util';
4+
import { isObject, LOCAL_LOGGER } from '@glimmer/util';
45

56
import type { ComponentBlueprint, Content } from '..';
67

@@ -101,7 +102,7 @@ abstract class AbstractChaosMonkeyTest extends RenderTest {
101102
}
102103

103104
if (shouldLog) {
104-
LOCAL_LOGGER.log(
105+
LOCAL_LOGGER.debug(
105106
`${removedNodeDisplay} was removed;\noriginal: ${original}\nupdated: ${element.innerHTML}`
106107
);
107108
}

packages/@glimmer-workspace/integration-tests/test/updating-content-matrix-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { SimpleElement, SimpleNode } from '@glimmer/interfaces';
22
import type { SafeString } from '@glimmer/runtime';
3-
import { NS_SVG } from '@glimmer/util';
3+
import { NS_SVG } from '@glimmer/constants';
44

55
import type { RenderTestConstructor } from '..';
66
import type RenderDelegate from '../lib/render-delegate';

packages/@glimmer-workspace/integration-tests/test/updating-svg-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { SimpleElement } from '@glimmer/interfaces';
2-
import { NS_HTML, NS_SVG, NS_XLINK } from '@glimmer/util';
2+
import { NS_HTML, NS_SVG, NS_XLINK } from '@glimmer/constants';
33

44
import { assertNodeTagName, jitSuite, RenderTest, test } from '..';
55
import { assert } from './support';

packages/@glimmer/compiler/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export {
77
s,
88
unicode,
99
} from './lib/builder/builder';
10-
export { Builder, type BuilderStatement } from './lib/builder/builder-interface';
10+
export { type BuilderStatement } from './lib/builder/builder-interface';
1111
export { defaultId, precompile, precompileJSON, type PrecompileOptions } from './lib/compiler';
1212

1313
// exported only for tests!

0 commit comments

Comments
 (0)