ember-repl 6.0.0 → 7.0.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.
Files changed (146) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +2 -404
  3. package/config/.try.mjs +87 -0
  4. package/config/addon-main.cjs +7 -0
  5. package/config/attw.json +7 -0
  6. package/config/babel.publish.config.cjs +29 -0
  7. package/config/ember-cli-update.json +21 -0
  8. package/config/rollup.config.mjs +44 -0
  9. package/config/testem.cjs +35 -0
  10. package/config/tsconfig.publish.json +18 -0
  11. package/config/vite.config.mjs +36 -0
  12. package/declarations/compile/Compiled.d.ts +7 -0
  13. package/declarations/compile/Compiled.d.ts.map +1 -0
  14. package/declarations/compile/compile.d.ts +17 -0
  15. package/declarations/compile/compile.d.ts.map +1 -0
  16. package/declarations/compile/state.d.ts +43 -0
  17. package/declarations/compile/state.d.ts.map +1 -0
  18. package/declarations/compile/types.d.ts +5 -12
  19. package/declarations/compile/types.d.ts.map +1 -1
  20. package/declarations/index.d.ts +6 -2
  21. package/declarations/index.d.ts.map +1 -1
  22. package/declarations/services/compiler.d.ts +94 -0
  23. package/declarations/services/compiler.d.ts.map +1 -0
  24. package/declarations/services/known-modules.d.ts +7 -0
  25. package/declarations/services/known-modules.d.ts.map +1 -0
  26. package/declarations/setup.d.ts +7 -0
  27. package/declarations/setup.d.ts.map +1 -0
  28. package/declarations/test-support.d.ts +20 -0
  29. package/declarations/test-support.d.ts.map +1 -0
  30. package/dist/_commonjsHelpers-BAGoDD49.js +37 -0
  31. package/dist/_commonjsHelpers-BAGoDD49.js.map +1 -0
  32. package/dist/babel-8wMrbxkT.js +110427 -0
  33. package/dist/babel-8wMrbxkT.js.map +1 -0
  34. package/dist/blank-line-Bzg2Qt4K.js +482 -0
  35. package/dist/blank-line-Bzg2Qt4K.js.map +1 -0
  36. package/dist/compile/Compiled.js +26 -0
  37. package/dist/compile/Compiled.js.map +1 -0
  38. package/dist/compile/compile.js +62 -0
  39. package/dist/compile/compile.js.map +1 -0
  40. package/dist/compile/state.js +75 -0
  41. package/dist/compile/state.js.map +1 -0
  42. package/dist/compile/utils.js +213 -2
  43. package/dist/compile/utils.js.map +1 -1
  44. package/dist/default-CoqAuVeH.js +4 -0
  45. package/dist/default-CoqAuVeH.js.map +1 -0
  46. package/dist/index-BTx1k6gT.js +323 -0
  47. package/dist/index-BTx1k6gT.js.map +1 -0
  48. package/dist/index-Bxzjtr16.js +87 -0
  49. package/dist/index-Bxzjtr16.js.map +1 -0
  50. package/dist/index-C371bO_b.js +1553 -0
  51. package/dist/index-C371bO_b.js.map +1 -0
  52. package/dist/index-C4AyeeIa.js +5721 -0
  53. package/dist/index-C4AyeeIa.js.map +1 -0
  54. package/dist/index-C8S2G0FH.js +1953 -0
  55. package/dist/index-C8S2G0FH.js.map +1 -0
  56. package/dist/index-CCcIVEUK.js +409 -0
  57. package/dist/index-CCcIVEUK.js.map +1 -0
  58. package/dist/index-CDSIcg03.js +9070 -0
  59. package/dist/index-CDSIcg03.js.map +1 -0
  60. package/dist/index-D8szzCn3.js +2 -0
  61. package/dist/index-D8szzCn3.js.map +1 -0
  62. package/dist/index-DBBNT106.js +2644 -0
  63. package/dist/index-DBBNT106.js.map +1 -0
  64. package/dist/index-DP_Su7Zc.js +362 -0
  65. package/dist/index-DP_Su7Zc.js.map +1 -0
  66. package/dist/index-DejgrVqh.js +11299 -0
  67. package/dist/index-DejgrVqh.js.map +1 -0
  68. package/dist/index-Dr5iYoKt.js +1551 -0
  69. package/dist/index-Dr5iYoKt.js.map +1 -0
  70. package/dist/index-DxolpiGq.js +3336 -0
  71. package/dist/index-DxolpiGq.js.map +1 -0
  72. package/dist/index-ZyJlPFQY.js +249 -0
  73. package/dist/index-ZyJlPFQY.js.map +1 -0
  74. package/dist/index-k6CfLgeq.js +26 -0
  75. package/dist/index-k6CfLgeq.js.map +1 -0
  76. package/dist/index.js +4 -1
  77. package/dist/index.js.map +1 -1
  78. package/dist/services/compiler.js +329 -0
  79. package/dist/services/compiler.js.map +1 -0
  80. package/dist/services/known-modules.js +123 -0
  81. package/dist/services/known-modules.js.map +1 -0
  82. package/dist/setup.js +15 -0
  83. package/dist/setup.js.map +1 -0
  84. package/dist/test-support.js +33 -0
  85. package/dist/test-support.js.map +1 -0
  86. package/package.json +117 -138
  87. package/src/compile/Compiled.ts +45 -0
  88. package/src/compile/compile.ts +89 -0
  89. package/src/compile/state.ts +88 -0
  90. package/src/compile/types.ts +14 -13
  91. package/src/index.ts +6 -2
  92. package/src/services/compiler.ts +401 -0
  93. package/src/services/known-modules.ts +130 -0
  94. package/src/setup.ts +26 -0
  95. package/src/test-support.ts +64 -0
  96. package/addon-main.cjs +0 -5
  97. package/declarations/__PRIVATE__.d.ts +0 -2
  98. package/declarations/__PRIVATE__.d.ts.map +0 -1
  99. package/declarations/compile/formats/gjs/babel.d.ts +0 -7
  100. package/declarations/compile/formats/gjs/babel.d.ts.map +0 -1
  101. package/declarations/compile/formats/gjs/eval.d.ts +0 -8
  102. package/declarations/compile/formats/gjs/eval.d.ts.map +0 -1
  103. package/declarations/compile/formats/gjs/index.d.ts +0 -24
  104. package/declarations/compile/formats/gjs/index.d.ts.map +0 -1
  105. package/declarations/compile/formats/gjs/known-modules.d.ts +0 -48
  106. package/declarations/compile/formats/gjs/known-modules.d.ts.map +0 -1
  107. package/declarations/compile/formats/hbs.d.ts +0 -17
  108. package/declarations/compile/formats/hbs.d.ts.map +0 -1
  109. package/declarations/compile/formats/markdown.d.ts +0 -22
  110. package/declarations/compile/formats/markdown.d.ts.map +0 -1
  111. package/declarations/compile/formats.d.ts +0 -17
  112. package/declarations/compile/formats.d.ts.map +0 -1
  113. package/declarations/compile/index.d.ts +0 -80
  114. package/declarations/compile/index.d.ts.map +0 -1
  115. package/declarations/test-support/index.d.ts +0 -2
  116. package/declarations/test-support/index.d.ts.map +0 -1
  117. package/dist/__PRIVATE__.js +0 -2
  118. package/dist/__PRIVATE__.js.map +0 -1
  119. package/dist/compile/formats/gjs/babel.js +0 -2
  120. package/dist/compile/formats/gjs/babel.js.map +0 -1
  121. package/dist/compile/formats/gjs/eval.js +0 -19
  122. package/dist/compile/formats/gjs/eval.js.map +0 -1
  123. package/dist/compile/formats/gjs/index.js +0 -122
  124. package/dist/compile/formats/gjs/index.js.map +0 -1
  125. package/dist/compile/formats/gjs/known-modules.js +0 -52
  126. package/dist/compile/formats/gjs/known-modules.js.map +0 -1
  127. package/dist/compile/formats/hbs.js +0 -93
  128. package/dist/compile/formats/hbs.js.map +0 -1
  129. package/dist/compile/formats/markdown.js +0 -266
  130. package/dist/compile/formats/markdown.js.map +0 -1
  131. package/dist/compile/formats.js +0 -173
  132. package/dist/compile/formats.js.map +0 -1
  133. package/dist/compile/index.js +0 -113
  134. package/dist/compile/index.js.map +0 -1
  135. package/dist/test-support/index.js +0 -8
  136. package/dist/test-support/index.js.map +0 -1
  137. package/src/__PRIVATE__.ts +0 -1
  138. package/src/compile/formats/gjs/babel.ts +0 -7
  139. package/src/compile/formats/gjs/eval.ts +0 -29
  140. package/src/compile/formats/gjs/index.ts +0 -153
  141. package/src/compile/formats/gjs/known-modules.ts +0 -49
  142. package/src/compile/formats/hbs.ts +0 -100
  143. package/src/compile/formats/markdown.ts +0 -345
  144. package/src/compile/formats.ts +0 -178
  145. package/src/compile/index.ts +0 -219
  146. package/src/test-support/index.ts +0 -5
@@ -1,219 +0,0 @@
1
- import { cell, resource, resourceFactory } from 'ember-resources';
2
-
3
- import {
4
- compileGJS as processGJS,
5
- compileHBS as processHBS,
6
- compileMD as processMD,
7
- } from './formats.ts';
8
- import { nameFor } from './utils.ts';
9
-
10
- import type { CompileResult, EvalImportMap, ScopeMap, UnifiedPlugin } from './types.ts';
11
- import type { ComponentLike } from '@glint/template';
12
-
13
- type Format = 'glimdown' | 'gjs' | 'hbs';
14
-
15
- export const CACHE = new Map<string, ComponentLike>();
16
-
17
- interface Events {
18
- onSuccess: (component: ComponentLike) => Promise<unknown> | unknown;
19
- onError: (error: string) => Promise<unknown> | unknown;
20
- onCompileStart: () => Promise<unknown> | unknown;
21
- }
22
-
23
- interface Scope {
24
- importMap?: EvalImportMap;
25
- }
26
-
27
- const SUPPORTED_FORMATS = ['glimdown', 'gjs', 'hbs'];
28
-
29
- interface GlimdownOptions extends Scope, Events {
30
- format: 'glimdown';
31
- remarkPlugins?: UnifiedPlugin[];
32
- rehypePlugins?: UnifiedPlugin[];
33
- CopyComponent?: string;
34
- ShadowComponent?: string;
35
- topLevelScope?: ScopeMap;
36
- }
37
- interface GJSOptions extends Scope, Events {
38
- format: 'gjs';
39
-
40
- // Make overloads easier?
41
- remarkPlugins?: never;
42
- rehypePlugins?: never;
43
- CopyComponent?: never;
44
- ShadowComponent?: never;
45
- }
46
-
47
- interface HBSOptions extends Scope, Events {
48
- format: 'hbs';
49
- topLevelScope?: ScopeMap;
50
-
51
- // Make overloads easier?
52
- remarkPlugins?: never;
53
- rehypePlugins?: never;
54
- CopyComponent?: never;
55
- ShadowComponent?: never;
56
- }
57
-
58
- /**
59
- * Compile GitHub-flavored Markdown with GJS support
60
- * and optionally render gjs-snippets via a `live` meta tag
61
- * on the code fences.
62
- */
63
- export async function compile(text: string, options: GlimdownOptions): Promise<void>;
64
-
65
- /**
66
- * Compile GJS
67
- */
68
- export async function compile(text: string, options: GJSOptions): Promise<void>;
69
-
70
- /**
71
- * Compile a stateless component using just the template
72
- */
73
- export async function compile(text: string, options: HBSOptions): Promise<void>;
74
-
75
- /**
76
- * This compileMD is a more robust version of the raw compiling used in "formats".
77
- * This function manages cache, and has events for folks building UIs to hook in to
78
- */
79
- export async function compile(
80
- text: string,
81
- options: GlimdownOptions | GJSOptions | HBSOptions
82
- ): Promise<void> {
83
- const { onSuccess, onError, onCompileStart } = options;
84
- const id = nameFor(`${options.format}:${text}`);
85
-
86
- const existing = CACHE.get(id);
87
-
88
- if (existing) {
89
- onSuccess(existing);
90
-
91
- return;
92
- }
93
-
94
- if (!SUPPORTED_FORMATS.includes(options.format)) {
95
- await onError(`Unsupported format: ${options.format}. Supported formats: ${SUPPORTED_FORMATS}`);
96
-
97
- return;
98
- }
99
-
100
- await onCompileStart();
101
-
102
- if (!text) {
103
- await onError('No Input Document yet');
104
-
105
- return;
106
- }
107
-
108
- let result: CompileResult;
109
-
110
- if (options.format === 'glimdown') {
111
- result = await processMD(text, options);
112
- } else if (options.format === 'gjs') {
113
- result = await processGJS(text, options.importMap);
114
- } else if (options.format === 'hbs') {
115
- result = await processHBS(text, {
116
- scope: options.topLevelScope,
117
- });
118
- } else {
119
- await onError(
120
- `Unsupported format: ${(options as any).format}. Supported formats: ${SUPPORTED_FORMATS}`
121
- );
122
-
123
- return;
124
- }
125
-
126
- if (result.error) {
127
- await onError(result.error.message || `${result.error}`);
128
-
129
- return;
130
- }
131
-
132
- CACHE.set(id, result.component as ComponentLike);
133
-
134
- await onSuccess(result.component as ComponentLike);
135
- }
136
-
137
- type Input = string | undefined | null;
138
-
139
- type ExtraOptions =
140
- | {
141
- format: 'glimdown';
142
- remarkPlugins?: UnifiedPlugin[];
143
- rehypePlugins?: UnifiedPlugin[];
144
- importMap?: EvalImportMap;
145
- CopyComponent?: string;
146
- ShadowComponent?: string;
147
- topLevelScope?: ScopeMap;
148
- }
149
- | {
150
- format: 'hbs';
151
- topLevelScope?: ScopeMap;
152
- }
153
- | {
154
- format: 'gjs';
155
- importMap?: EvalImportMap;
156
- };
157
-
158
- /**
159
- * @internal
160
- */
161
- export interface Value {
162
- isReady: boolean;
163
- error: string | null;
164
- component: ComponentLike;
165
- }
166
-
167
- export function Compiled(markdownText: Input | (() => Input)): Value;
168
- export function Compiled(markdownText: Input | (() => Input), options?: Format): Value;
169
- export function Compiled(markdownText: Input | (() => Input), options?: () => Format): Value;
170
- export function Compiled(markdownText: Input | (() => Input), options?: ExtraOptions): Value;
171
- export function Compiled(markdownText: Input | (() => Input), options?: () => ExtraOptions): Value;
172
-
173
- /**
174
- * By default, this compiles to `glimdown`. A Markdown format which
175
- * extracts `live` tagged code snippets and compiles them to components.
176
- */
177
- export function Compiled(
178
- markdownText: Input | (() => Input),
179
- maybeOptions?: Format | (() => Format) | ExtraOptions | (() => ExtraOptions)
180
- ): Value {
181
- return resource(() => {
182
- const maybeObject = typeof maybeOptions === 'function' ? maybeOptions() : maybeOptions;
183
- const format =
184
- (typeof maybeObject === 'string' ? maybeObject : maybeObject?.format) || 'glimdown';
185
- const options = (typeof maybeObject === 'string' ? {} : maybeObject) || {};
186
-
187
- const input = typeof markdownText === 'function' ? markdownText() : markdownText;
188
- const ready = cell(false);
189
- const error = cell<string | null>();
190
- const result = cell<ComponentLike>();
191
-
192
- if (input) {
193
- compile(input, {
194
- // narrowing is hard here, but this is an implementation detail
195
- format: format as any,
196
- onSuccess: async (component) => {
197
- result.current = component;
198
- ready.set(true);
199
- error.set(null);
200
- },
201
- onError: async (e) => {
202
- error.set(e);
203
- },
204
- onCompileStart: async () => {
205
- ready.set(false);
206
- },
207
- ...options,
208
- });
209
- }
210
-
211
- return () => ({
212
- isReady: ready.current,
213
- error: error.current,
214
- component: result.current,
215
- });
216
- });
217
- }
218
-
219
- resourceFactory(Compiled);
@@ -1,5 +0,0 @@
1
- import { CACHE } from '../compile/index.ts';
2
-
3
- export function clearCompileCache() {
4
- CACHE.clear();
5
- }