ember-repl 4.1.2 → 4.2.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.
@@ -21,10 +21,18 @@ interface GlimdownOptions extends Scope, Events {
21
21
  }
22
22
  interface GJSOptions extends Scope, Events {
23
23
  format: 'gjs';
24
+ remarkPlugins?: never;
25
+ rehypePlugins?: never;
26
+ CopyComponent?: never;
27
+ ShadowComponent?: never;
24
28
  }
25
29
  interface HBSOptions extends Scope, Events {
26
30
  format: 'hbs';
27
31
  topLevelScope?: ScopeMap;
32
+ remarkPlugins?: never;
33
+ rehypePlugins?: never;
34
+ CopyComponent?: never;
35
+ ShadowComponent?: never;
28
36
  }
29
37
  /**
30
38
  * Compile GitHub-flavored Markdown with GJS support
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compile/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAiB,aAAa,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,KAAK,MAAM,GAAG,UAAU,GAAG,KAAK,GAAG,KAAK,CAAC;AAEzC,eAAO,MAAM,KAAK,4BAAmC,CAAC;AAEtD,UAAU,MAAM;IACd,SAAS,EAAE,CAAC,SAAS,EAAE,aAAa,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACpE,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACvD,cAAc,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;CAClD;AAED,UAAU,KAAK;IACb,SAAS,CAAC,EAAE,aAAa,CAAC;CAC3B;AAID,UAAU,eAAgB,SAAQ,KAAK,EAAE,MAAM;IAC7C,MAAM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Y,GAAG,KAAK,CAAC;AAC7F,wBAAgB,QAAQ,CAAC,YAAY,EAAE,KAAK,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,YAAY,GAAG,KAAK,CAAC"}
@@ -1,4 +1,4 @@
1
1
  export { compile, Compiled } from './compile/index.ts';
2
2
  export { invocationName, invocationOf, nameFor } from './compile/utils.ts';
3
- export type { CompileResult } from './compile/types';
3
+ export type { CompileResult, EvalImportMap, ScopeMap, UnifiedPlugin } from './compile/types';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG3E,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG3E,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/compile/index.ts"],"sourcesContent":["import { cell, resource, resourceFactory } from 'ember-resources';\n\nimport {\n compileGJS as processGJS,\n compileHBS as processHBS,\n compileMD as processMD,\n} from './formats.ts';\nimport { nameFor } from './utils.ts';\n\nimport type { CompileResult, UnifiedPlugin } from './types.ts';\nimport type { EvalImportMap, ScopeMap } from './types.ts';\nimport type { ComponentLike } from '@glint/template';\ntype Format = 'glimdown' | 'gjs' | 'hbs';\n\nexport const CACHE = new Map<string, ComponentLike>();\n\ninterface Events {\n onSuccess: (component: ComponentLike) => Promise<unknown> | unknown;\n onError: (error: string) => Promise<unknown> | unknown;\n onCompileStart: () => Promise<unknown> | unknown;\n}\n\ninterface Scope {\n importMap?: EvalImportMap;\n}\n\nconst SUPPORTED_FORMATS = ['glimdown', 'gjs', 'hbs'];\n\ninterface GlimdownOptions extends Scope, Events {\n format: 'glimdown';\n remarkPlugins?: UnifiedPlugin[];\n rehypePlugins?: UnifiedPlugin[];\n CopyComponent?: string;\n ShadowComponent?: string;\n topLevelScope?: ScopeMap;\n}\ninterface GJSOptions extends Scope, Events {\n format: 'gjs';\n}\n\ninterface HBSOptions extends Scope, Events {\n format: 'hbs';\n topLevelScope?: ScopeMap;\n}\n\n/**\n * Compile GitHub-flavored Markdown with GJS support\n * and optionally render gjs-snippets via a `live` meta tag\n * on the code fences.\n */\nexport async function compile(text: string, options: GlimdownOptions): Promise<void>;\n\n/**\n * Compile GJS\n */\nexport async function compile(text: string, options: GJSOptions): Promise<void>;\n\n/**\n * Compile a stateless component using just the template\n */\nexport async function compile(text: string, options: HBSOptions): Promise<void>;\n\n/**\n * This compileMD is a more robust version of the raw compiling used in \"formats\".\n * This function manages cache, and has events for folks building UIs to hook in to\n */\nexport async function compile(\n text: string,\n options: GlimdownOptions | GJSOptions | HBSOptions\n): Promise<void> {\n let { onSuccess, onError, onCompileStart } = options;\n let id = nameFor(text);\n\n let existing = CACHE.get(id);\n\n if (existing) {\n onSuccess(existing);\n\n return;\n }\n\n if (!SUPPORTED_FORMATS.includes(options.format)) {\n await onError(`Unsupported format: ${options.format}. Supported formats: ${SUPPORTED_FORMATS}`);\n\n return;\n }\n\n await onCompileStart();\n\n if (!text) {\n await onError('No Input Document yet');\n\n return;\n }\n\n let result: CompileResult;\n\n if (options.format === 'glimdown') {\n result = await processMD(text, options);\n } else if (options.format === 'gjs') {\n result = await processGJS(text, options.importMap);\n } else if (options.format === 'hbs') {\n result = await processHBS(text, {\n scope: options.topLevelScope,\n });\n } else {\n await onError(\n `Unsupported format: ${(options as any).format}. Supported formats: ${SUPPORTED_FORMATS}`\n );\n\n return;\n }\n\n if (result.error) {\n await onError(result.error.message || `${result.error}`);\n\n return;\n }\n\n CACHE.set(id, result.component as ComponentLike);\n\n await onSuccess(result.component as ComponentLike);\n}\n\ntype Input = string | undefined | null;\n\ntype ExtraOptions =\n | {\n format: 'glimdown';\n remarkPlugins?: UnifiedPlugin[];\n rehypePlugins?: UnifiedPlugin[];\n importMap?: EvalImportMap;\n CopyComponent?: string;\n ShadowComponent?: string;\n topLevelScope?: ScopeMap;\n }\n | {\n format: 'hbs';\n topLevelScope?: ScopeMap;\n }\n | {\n format: 'gjs';\n importMap?: EvalImportMap;\n };\n\n/**\n * @internal\n */\nexport interface Value {\n isReady: boolean;\n error: string | null;\n component: ComponentLike;\n}\n\nexport function Compiled(markdownText: Input | (() => Input)): Value;\nexport function Compiled(markdownText: Input | (() => Input), options?: Format): Value;\nexport function Compiled(markdownText: Input | (() => Input), options?: () => Format): Value;\nexport function Compiled(markdownText: Input | (() => Input), options?: ExtraOptions): Value;\nexport function Compiled(markdownText: Input | (() => Input), options?: () => ExtraOptions): Value;\n\n/**\n * By default, this compiles to `glimdown`. A Markdown format which\n * extracts `live` tagged code snippets and compiles them to components.\n */\nexport function Compiled(\n markdownText: Input | (() => Input),\n maybeOptions?: Format | (() => Format) | ExtraOptions | (() => ExtraOptions)\n): Value {\n return resource(() => {\n let maybeObject = typeof maybeOptions === 'function' ? maybeOptions() : maybeOptions;\n let format =\n (typeof maybeObject === 'string' ? maybeObject : maybeObject?.format) || 'glimdown';\n let options = (typeof maybeObject === 'string' ? {} : maybeObject) || {};\n\n let input = typeof markdownText === 'function' ? markdownText() : markdownText;\n let ready = cell(false);\n let error = cell<string | null>();\n let result = cell<ComponentLike>();\n\n if (input) {\n compile(input, {\n // narrowing is hard here, but this is an implementation detail\n format: format as any,\n onSuccess: async (component) => {\n result.current = component;\n ready.set(true);\n error.set(null);\n },\n onError: async (e) => {\n error.set(e);\n },\n onCompileStart: async () => {\n ready.set(false);\n },\n ...options,\n });\n }\n\n return () => ({\n isReady: ready.current,\n error: error.current,\n component: result.current,\n });\n });\n}\n\nresourceFactory(Compiled);\n"],"names":["CACHE","Map","SUPPORTED_FORMATS","compile","text","options","onSuccess","onError","onCompileStart","id","nameFor","existing","get","includes","format","result","processMD","processGJS","importMap","processHBS","scope","topLevelScope","error","message","set","component","Compiled","markdownText","maybeOptions","resource","maybeObject","input","ready","cell","current","e","isReady","resourceFactory"],"mappings":";;;;MAcaA,KAAK,GAAG,IAAIC,GAAG,GAAyB;AAYrD,MAAMC,iBAAiB,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;;AAmBpD;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACO,eAAeC,OAAOA,CAC3BC,IAAY,EACZC,OAAkD,EACnC;EACf,IAAI;IAAEC,SAAS;IAAEC,OAAO;AAAEC,IAAAA,cAAAA;AAAe,GAAC,GAAGH,OAAO,CAAA;AACpD,EAAA,IAAII,EAAE,GAAGC,OAAO,CAACN,IAAI,CAAC,CAAA;AAEtB,EAAA,IAAIO,QAAQ,GAAGX,KAAK,CAACY,GAAG,CAACH,EAAE,CAAC,CAAA;AAE5B,EAAA,IAAIE,QAAQ,EAAE;IACZL,SAAS,CAACK,QAAQ,CAAC,CAAA;AAEnB,IAAA,OAAA;AACF,GAAA;EAEA,IAAI,CAACT,iBAAiB,CAACW,QAAQ,CAACR,OAAO,CAACS,MAAM,CAAC,EAAE;IAC/C,MAAMP,OAAO,CAAE,CAAsBF,oBAAAA,EAAAA,OAAO,CAACS,MAAO,CAAA,qBAAA,EAAuBZ,iBAAkB,CAAA,CAAC,CAAC,CAAA;AAE/F,IAAA,OAAA;AACF,GAAA;EAEA,MAAMM,cAAc,EAAE,CAAA;EAEtB,IAAI,CAACJ,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S,EAAEV,MAAM,CAACmB,OAAAA;AACpB,KAAC,CAAC,CAAA;AACJ,GAAC,CAAC,CAAA;AACJ,CAAA;AAEAG,eAAe,CAACX,QAAQ,CAAC;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/compile/index.ts"],"sourcesContent":["import { cell, resource, resourceFactory } from 'ember-resources';\n\nimport {\n compileGJS as processGJS,\n compileHBS as processHBS,\n compileMD as processMD,\n} from './formats.ts';\nimport { nameFor } from './utils.ts';\n\nimport type { CompileResult, UnifiedPlugin } from './types.ts';\nimport type { EvalImportMap, ScopeMap } from './types.ts';\nimport type { ComponentLike } from '@glint/template';\ntype Format = 'glimdown' | 'gjs' | 'hbs';\n\nexport const CACHE = new Map<string, ComponentLike>();\n\ninterface Events {\n onSuccess: (component: ComponentLike) => Promise<unknown> | unknown;\n onError: (error: string) => Promise<unknown> | unknown;\n onCompileStart: () => Promise<unknown> | unknown;\n}\n\ninterface Scope {\n importMap?: EvalImportMap;\n}\n\nconst SUPPORTED_FORMATS = ['glimdown', 'gjs', 'hbs'];\n\ninterface GlimdownOptions extends Scope, Events {\n format: 'glimdown';\n remarkPlugins?: UnifiedPlugin[];\n rehypePlugins?: UnifiedPlugin[];\n CopyComponent?: string;\n ShadowComponent?: string;\n topLevelScope?: ScopeMap;\n}\ninterface GJSOptions extends Scope, Events {\n format: 'gjs';\n\n // Make overloads easier?\n remarkPlugins?: never;\n rehypePlugins?: never;\n CopyComponent?: never;\n ShadowComponent?: never;\n}\n\ninterface HBSOptions extends Scope, Events {\n format: 'hbs';\n topLevelScope?: ScopeMap;\n\n // Make overloads easier?\n remarkPlugins?: never;\n rehypePlugins?: never;\n CopyComponent?: never;\n ShadowComponent?: never;\n}\n\n/**\n * Compile GitHub-flavored Markdown with GJS support\n * and optionally render gjs-snippets via a `live` meta tag\n * on the code fences.\n */\nexport async function compile(text: string, options: GlimdownOptions): Promise<void>;\n\n/**\n * Compile GJS\n */\nexport async function compile(text: string, options: GJSOptions): Promise<void>;\n\n/**\n * Compile a stateless component using just the template\n */\nexport async function compile(text: string, options: HBSOptions): Promise<void>;\n\n/**\n * This compileMD is a more robust version of the raw compiling used in \"formats\".\n * This function manages cache, and has events for folks building UIs to hook in to\n */\nexport async function compile(\n text: string,\n options: GlimdownOptions | GJSOptions | HBSOptions\n): Promise<void> {\n let { onSuccess, onError, onCompileStart } = options;\n let id = nameFor(text);\n\n let existing = CACHE.get(id);\n\n if (existing) {\n onSuccess(existing);\n\n return;\n }\n\n if (!SUPPORTED_FORMATS.includes(options.format)) {\n await onError(`Unsupported format: ${options.format}. Supported formats: ${SUPPORTED_FORMATS}`);\n\n return;\n }\n\n await onCompileStart();\n\n if (!text) {\n await onError('No Input Document yet');\n\n return;\n }\n\n let result: CompileResult;\n\n if (options.format === 'glimdown') {\n result = await processMD(text, options);\n } else if (options.format === 'gjs') {\n result = await processGJS(text, options.importMap);\n } else if (options.format === 'hbs') {\n result = await processHBS(text, {\n scope: options.topLevelScope,\n });\n } else {\n await onError(\n `Unsupported format: ${(options as any).format}. Supported formats: ${SUPPORTED_FORMATS}`\n );\n\n return;\n }\n\n if (result.error) {\n await onError(result.error.message || `${result.error}`);\n\n return;\n }\n\n CACHE.set(id, result.component as ComponentLike);\n\n await onSuccess(result.component as ComponentLike);\n}\n\ntype Input = string | undefined | null;\n\ntype ExtraOptions =\n | {\n format: 'glimdown';\n remarkPlugins?: UnifiedPlugin[];\n rehypePlugins?: UnifiedPlugin[];\n importMap?: EvalImportMap;\n CopyComponent?: string;\n ShadowComponent?: string;\n topLevelScope?: ScopeMap;\n }\n | {\n format: 'hbs';\n topLevelScope?: ScopeMap;\n }\n | {\n format: 'gjs';\n importMap?: EvalImportMap;\n };\n\n/**\n * @internal\n */\nexport interface Value {\n isReady: boolean;\n error: string | null;\n component: ComponentLike;\n}\n\nexport function Compiled(markdownText: Input | (() => Input)): Value;\nexport function Compiled(markdownText: Input | (() => Input), options?: Format): Value;\nexport function Compiled(markdownText: Input | (() => Input), options?: () => Format): Value;\nexport function Compiled(markdownText: Input | (() => Input), options?: ExtraOptions): Value;\nexport function Compiled(markdownText: Input | (() => Input), options?: () => ExtraOptions): Value;\n\n/**\n * By default, this compiles to `glimdown`. A Markdown format which\n * extracts `live` tagged code snippets and compiles them to components.\n */\nexport function Compiled(\n markdownText: Input | (() => Input),\n maybeOptions?: Format | (() => Format) | ExtraOptions | (() => ExtraOptions)\n): Value {\n return resource(() => {\n let maybeObject = typeof maybeOptions === 'function' ? maybeOptions() : maybeOptions;\n let format =\n (typeof maybeObject === 'string' ? maybeObject : maybeObject?.format) || 'glimdown';\n let options = (typeof maybeObject === 'string' ? {} : maybeObject) || {};\n\n let input = typeof markdownText === 'function' ? markdownText() : markdownText;\n let ready = cell(false);\n let error = cell<string | null>();\n let result = cell<ComponentLike>();\n\n if (input) {\n compile(input, {\n // narrowing is hard here, but this is an implementation detail\n format: format as any,\n onSuccess: async (component) => {\n result.current = component;\n ready.set(true);\n error.set(null);\n },\n onError: async (e) => {\n error.set(e);\n },\n onCompileStart: async () => {\n ready.set(false);\n },\n ...options,\n });\n }\n\n return () => ({\n isReady: ready.current,\n error: error.current,\n component: result.current,\n });\n });\n}\n\nresourceFactory(Compiled);\n"],"names":["CACHE","Map","SUPPORTED_FORMATS","compile","text","options","onSuccess","onError","onCompileStart","id","nameFor","existing","get","includes","format","result","processMD","processGJS","importMap","processHBS","scope","topLevelScope","error","message","set","component","Compiled","markdownText","maybeOptions","resource","maybeObject","input","ready","cell","current","e","isReady","resourceFactory"],"mappings":";;;;MAcaA,KAAK,GAAG,IAAIC,GAAG,GAAyB;AAYrD,MAAMC,iBAAiB,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;;AA+BpD;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACO,eAAeC,OAAOA,CAC3BC,IAAY,EACZC,OAAkD,EACnC;EACf,IAAI;IAAEC,SAAS;IAAEC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EAAEA,MAAa;QACrBR,SAAS,EAAE,MAAOmB,SAAS,IAAK;UAC9BV,MAAM,CAACmB,OAAO,GAAGT,SAAS,CAAA;AAC1BO,UAAAA,KAAK,CAACR,GAAG,CAAC,IAAI,CAAC,CAAA;AACfF,UAAAA,KAAK,CAACE,GAAG,CAAC,IAAI,CAAC,CAAA;SAChB;QACDjB,OAAO,EAAE,MAAO4B,CAAC,IAAK;AACpBb,UAAAA,KAAK,CAACE,GAAG,CAACW,CAAC,CAAC,CAAA;SACb;QACD3B,cAAc,EAAE,YAAY;AAC1BwB,UAAAA,KAAK,CAACR,GAAG,CAAC,KAAK,CAAC,CAAA;SACjB;QACD,GAAGnB,OAAAA;AACL,OAAC,CAAC,CAAA;AACJ,KAAA;AAEA,IAAA,OAAO,OAAO;MACZ+B,OAAO,EAAEJ,KAAK,CAACE,OAAO;MACtBZ,KAAK,EAAEA,KAAK,CAACY,OAAO;MACpBT,SAAS,EAAEV,MAAM,CAACmB,OAAAA;AACpB,KAAC,CAAC,CAAA;AACJ,GAAC,CAAC,CAAA;AACJ,CAAA;AAEAG,eAAe,CAACX,QAAQ,CAAC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-repl",
3
- "version": "4.1.2",
3
+ "version": "4.2.0",
4
4
  "description": "Addon for enabling REPL and Playground creation with Ember/Glimmer",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -36,11 +36,23 @@ interface GlimdownOptions extends Scope, Events {
36
36
  }
37
37
  interface GJSOptions extends Scope, Events {
38
38
  format: 'gjs';
39
+
40
+ // Make overloads easier?
41
+ remarkPlugins?: never;
42
+ rehypePlugins?: never;
43
+ CopyComponent?: never;
44
+ ShadowComponent?: never;
39
45
  }
40
46
 
41
47
  interface HBSOptions extends Scope, Events {
42
48
  format: 'hbs';
43
49
  topLevelScope?: ScopeMap;
50
+
51
+ // Make overloads easier?
52
+ remarkPlugins?: never;
53
+ rehypePlugins?: never;
54
+ CopyComponent?: never;
55
+ ShadowComponent?: never;
44
56
  }
45
57
 
46
58
  /**
package/src/index.ts CHANGED
@@ -2,4 +2,4 @@ export { compile, Compiled } from './compile/index.ts';
2
2
  export { invocationName, invocationOf, nameFor } from './compile/utils.ts';
3
3
 
4
4
  // Public Types
5
- export type { CompileResult } from './compile/types';
5
+ export type { CompileResult, EvalImportMap, ScopeMap, UnifiedPlugin } from './compile/types';