ember-repl 3.0.0 → 4.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.
- package/package.json +34 -25
- package/src/compile/formats/gjs/babel.ts +7 -0
- package/src/{browser/cjs → compile/formats/gjs}/eval.ts +2 -4
- package/src/compile/formats/gjs/index.ts +123 -0
- package/src/{browser → compile/formats}/hbs.ts +7 -4
- package/src/{browser/compile/markdown-to-ember.ts → compile/formats/markdown.ts} +8 -1
- package/src/{browser/compile → compile}/formats.ts +6 -7
- package/src/{browser/compile → compile}/index.ts +2 -3
- package/src/compile/types.ts +26 -0
- package/src/index.ts +5 -0
- package/src/test-support/index.ts +1 -1
- package/declarations/browser/__PRIVATE__.d.ts +0 -2
- package/declarations/browser/__PRIVATE__.d.ts.map +0 -1
- package/declarations/browser/cjs/eval.d.ts +0 -9
- package/declarations/browser/cjs/eval.d.ts.map +0 -1
- package/declarations/browser/cjs/index.d.ts +0 -7
- package/declarations/browser/cjs/index.d.ts.map +0 -1
- package/declarations/browser/compile/formats.d.ts +0 -18
- package/declarations/browser/compile/formats.d.ts.map +0 -1
- package/declarations/browser/compile/index.d.ts +0 -71
- package/declarations/browser/compile/index.d.ts.map +0 -1
- package/declarations/browser/compile/markdown-to-ember.d.ts +0 -21
- package/declarations/browser/compile/markdown-to-ember.d.ts.map +0 -1
- package/declarations/browser/compile/types.d.ts +0 -9
- package/declarations/browser/compile/types.d.ts.map +0 -1
- package/declarations/browser/esm/index.d.ts +0 -8
- package/declarations/browser/esm/index.d.ts.map +0 -1
- package/declarations/browser/gjs.d.ts +0 -4
- package/declarations/browser/gjs.d.ts.map +0 -1
- package/declarations/browser/hbs.d.ts +0 -17
- package/declarations/browser/hbs.d.ts.map +0 -1
- package/declarations/browser/index.d.ts +0 -7
- package/declarations/browser/index.d.ts.map +0 -1
- package/declarations/browser/js.d.ts +0 -20
- package/declarations/browser/js.d.ts.map +0 -1
- package/declarations/browser/known-modules.d.ts +0 -65
- package/declarations/browser/known-modules.d.ts.map +0 -1
- package/declarations/browser/types.d.ts +0 -21
- package/declarations/browser/types.d.ts.map +0 -1
- package/declarations/browser/utils.d.ts +0 -19
- package/declarations/browser/utils.d.ts.map +0 -1
- package/declarations/test-support/index.d.ts +0 -2
- package/declarations/test-support/index.d.ts.map +0 -1
- package/dist/browser/__PRIVATE__.js +0 -2
- package/dist/browser/__PRIVATE__.js.map +0 -1
- package/dist/browser/cjs/eval.js +0 -22
- package/dist/browser/cjs/eval.js.map +0 -1
- package/dist/browser/cjs/index.js +0 -43
- package/dist/browser/cjs/index.js.map +0 -1
- package/dist/browser/compile/formats.js +0 -172
- package/dist/browser/compile/formats.js.map +0 -1
- package/dist/browser/compile/index.js +0 -113
- package/dist/browser/compile/index.js.map +0 -1
- package/dist/browser/compile/markdown-to-ember.js +0 -254
- package/dist/browser/compile/markdown-to-ember.js.map +0 -1
- package/dist/browser/compile/types.js +0 -2
- package/dist/browser/compile/types.js.map +0 -1
- package/dist/browser/esm/index.js +0 -67
- package/dist/browser/esm/index.js.map +0 -1
- package/dist/browser/gjs.js +0 -43
- package/dist/browser/gjs.js.map +0 -1
- package/dist/browser/hbs.js +0 -100
- package/dist/browser/hbs.js.map +0 -1
- package/dist/browser/index.js +0 -6
- package/dist/browser/index.js.map +0 -1
- package/dist/browser/js.js +0 -38
- package/dist/browser/js.js.map +0 -1
- package/dist/browser/known-modules.js +0 -48
- package/dist/browser/known-modules.js.map +0 -1
- package/dist/browser/types.js +0 -2
- package/dist/browser/types.js.map +0 -1
- package/dist/browser/utils.js +0 -46
- package/dist/browser/utils.js.map +0 -1
- package/dist/build/ember-cli.cjs +0 -36
- package/dist/test-support/index.js +0 -8
- package/dist/test-support/index.js.map +0 -1
- package/src/browser/cjs/index.ts +0 -44
- package/src/browser/compile/types.ts +0 -11
- package/src/browser/esm/index.ts +0 -80
- package/src/browser/gjs.ts +0 -59
- package/src/browser/index.ts +0 -8
- package/src/browser/js.ts +0 -42
- package/src/browser/types.ts +0 -24
- package/src/build/ember-cli.cjs +0 -36
- /package/src/{browser/__PRIVATE__.ts → __PRIVATE__.ts} +0 -0
- /package/src/{browser → compile/formats/gjs}/known-modules.ts +0 -0
- /package/src/{browser → compile}/utils.ts +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"known-modules.js","sources":["../../src/browser/known-modules.ts"],"sourcesContent":["/**\n * We need to import and hang on to these references so that they\n * don't get optimized away during deploy\n */\nimport _GlimmerComponent from '@glimmer/component';\nimport * as _tracking from '@glimmer/tracking';\nimport * as _application from '@ember/application';\nimport * as _array from '@ember/array';\nimport * as _EmberComponent from '@ember/component';\nimport * as _EmberComponentHelper from '@ember/component/helper';\nimport _TO from '@ember/component/template-only';\nimport * as _debug from '@ember/debug';\nimport * as _destroyable from '@ember/destroyable';\nimport * as _helpers from '@ember/helper';\nimport * as _modifier from '@ember/modifier';\nimport * as _object from '@ember/object';\nimport * as _owner from '@ember/owner';\nimport * as _runloop from '@ember/runloop';\nimport * as _service from '@ember/service';\nimport * as _template from '@ember/template';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { createTemplateFactory } from '@ember/template-factory';\nimport * as _utils from '@ember/utils';\n\nexport const modules = {\n '@ember/application': _application,\n '@ember/array': _array,\n '@ember/component': _EmberComponent,\n '@ember/component/helper': _EmberComponentHelper,\n '@ember/component/template-only': _TO,\n '@ember/debug': _debug,\n '@ember/destroyable': _destroyable,\n '@ember/helper': _helpers,\n '@ember/modifier': _modifier,\n '@ember/object': _object,\n '@ember/runloop': _runloop,\n '@ember/service': _service,\n '@ember/template-factory': { createTemplateFactory },\n '@ember/utils': _utils,\n '@ember/template': _template,\n '@ember/owner': _owner,\n\n '@glimmer/component': _GlimmerComponent,\n '@glimmer/tracking': _tracking,\n};\n"],"names":["modules","_application","_array","_EmberComponent","_EmberComponentHelper","_TO","_debug","_destroyable","_helpers","_modifier","_object","_runloop","_service","createTemplateFactory","_utils","_template","_owner","_GlimmerComponent","_tracking"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AAsBO,MAAMA,OAAO,GAAG;AACrB,EAAA,oBAAoB,EAAEC,YAAY;AAClC,EAAA,cAAc,EAAEC,MAAM;AACtB,EAAA,kBAAkB,EAAEC,eAAe;AACnC,EAAA,yBAAyB,EAAEC,qBAAqB;AAChD,EAAA,gCAAgC,EAAEC,GAAG;AACrC,EAAA,cAAc,EAAEC,MAAM;AACtB,EAAA,oBAAoB,EAAEC,YAAY;AAClC,EAAA,eAAe,EAAEC,QAAQ;AACzB,EAAA,iBAAiB,EAAEC,SAAS;AAC5B,EAAA,eAAe,EAAEC,OAAO;AACxB,EAAA,gBAAgB,EAAEC,QAAQ;AAC1B,EAAA,gBAAgB,EAAEC,QAAQ;AAC1B,EAAA,yBAAyB,EAAE;AAAEC,IAAAA,qBAAAA;GAAuB;AACpD,EAAA,cAAc,EAAEC,MAAM;AACtB,EAAA,iBAAiB,EAAEC,SAAS;AAC5B,EAAA,cAAc,EAAEC,MAAM;AAEtB,EAAA,oBAAoB,EAAEC,iBAAiB;AACvC,EAAA,mBAAmB,EAAEC,SAAAA;AACvB;;;;"}
|
package/dist/browser/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/browser/utils.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { assert } from '@ember/debug';
|
|
2
|
-
import { pascalCase } from 'change-case';
|
|
3
|
-
import { v5 } from 'uuid';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* a namespace is required for uuid v5
|
|
7
|
-
*
|
|
8
|
-
* it helps generate stable outputs for for any given input.
|
|
9
|
-
*/
|
|
10
|
-
const NAMESPACE = '926f034a-f480-4112-a363-321244f4e5de';
|
|
11
|
-
const DEFAULT_PREFIX = 'ember-repl';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* For any given code block, a reasonably stable name can be
|
|
15
|
-
* generated.
|
|
16
|
-
* This can help with cacheing previously compiled components,
|
|
17
|
-
* and generally allowing a consumer to derive "known references" to user-input
|
|
18
|
-
*/
|
|
19
|
-
function nameFor(code, prefix = DEFAULT_PREFIX) {
|
|
20
|
-
let id = v5(code, NAMESPACE);
|
|
21
|
-
return `${prefix ? `${prefix}-` : ''}${id}`;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Returns the text for invoking a component with a given name.
|
|
26
|
-
* It is assumed the component takes no arguments, as would be the
|
|
27
|
-
* case in REPLs / Playgrounds for the "root" component.
|
|
28
|
-
*/
|
|
29
|
-
function invocationOf(name) {
|
|
30
|
-
assert(`You must pass a name to invocationOf. Received: \`${name}\``, typeof name === 'string' && name.length > 0);
|
|
31
|
-
if (name.length === 0) {
|
|
32
|
-
throw new Error(`name passed to invocationOf must have non-0 length`);
|
|
33
|
-
}
|
|
34
|
-
return `<${invocationName(name)} />`;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Core team does not want to support changes to '@ember/string' (v2 addonification, specifically)
|
|
39
|
-
* inflection does not support hyphens
|
|
40
|
-
*/
|
|
41
|
-
function invocationName(name) {
|
|
42
|
-
return pascalCase(name).replaceAll('_', '');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export { invocationName, invocationOf, nameFor };
|
|
46
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../src/browser/utils.ts"],"sourcesContent":["import { assert } from '@ember/debug';\n\nimport { pascalCase } from 'change-case';\nimport { v5 as uuidv5 } from 'uuid';\n\n/**\n * a namespace is required for uuid v5\n *\n * it helps generate stable outputs for for any given input.\n */\nconst NAMESPACE = '926f034a-f480-4112-a363-321244f4e5de';\nconst DEFAULT_PREFIX = 'ember-repl';\n\n/**\n * For any given code block, a reasonably stable name can be\n * generated.\n * This can help with cacheing previously compiled components,\n * and generally allowing a consumer to derive \"known references\" to user-input\n */\nexport function nameFor(code: string, prefix = DEFAULT_PREFIX) {\n let id = uuidv5(code, NAMESPACE);\n\n return `${prefix ? `${prefix}-` : ''}${id}`;\n}\n\n/**\n * Returns the text for invoking a component with a given name.\n * It is assumed the component takes no arguments, as would be the\n * case in REPLs / Playgrounds for the \"root\" component.\n */\nexport function invocationOf(name: string) {\n assert(\n `You must pass a name to invocationOf. Received: \\`${name}\\``,\n typeof name === 'string' && name.length > 0\n );\n\n if (name.length === 0) {\n throw new Error(`name passed to invocationOf must have non-0 length`);\n }\n\n return `<${invocationName(name)} />`;\n}\n\n/**\n * Core team does not want to support changes to '@ember/string' (v2 addonification, specifically)\n * inflection does not support hyphens\n */\nexport function invocationName(name: string) {\n return pascalCase(name).replaceAll('_', '');\n}\n"],"names":["NAMESPACE","DEFAULT_PREFIX","nameFor","code","prefix","id","uuidv5","invocationOf","name","assert","length","Error","invocationName","pascalCase","replaceAll"],"mappings":";;;;AAKA;AACA;AACA;AACA;AACA;AACA,MAAMA,SAAS,GAAG,sCAAsC,CAAA;AACxD,MAAMC,cAAc,GAAG,YAAY,CAAA;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,OAAOA,CAACC,IAAY,EAAEC,MAAM,GAAGH,cAAc,EAAE;AAC7D,EAAA,IAAII,EAAE,GAAGC,EAAM,CAACH,IAAI,EAAEH,SAAS,CAAC,CAAA;EAEhC,OAAQ,CAAA,EAAEI,MAAM,GAAI,CAAEA,EAAAA,MAAO,GAAE,GAAG,EAAG,CAAEC,EAAAA,EAAG,CAAC,CAAA,CAAA;AAC7C,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASE,YAAYA,CAACC,IAAY,EAAE;AACzCC,EAAAA,MAAM,CACH,CAAA,kDAAA,EAAoDD,IAAK,CAAA,EAAA,CAAG,EAC7D,OAAOA,IAAI,KAAK,QAAQ,IAAIA,IAAI,CAACE,MAAM,GAAG,CAC5C,CAAC,CAAA;AAED,EAAA,IAAIF,IAAI,CAACE,MAAM,KAAK,CAAC,EAAE;AACrB,IAAA,MAAM,IAAIC,KAAK,CAAE,CAAA,kDAAA,CAAmD,CAAC,CAAA;AACvE,GAAA;AAEA,EAAA,OAAQ,CAAGC,CAAAA,EAAAA,cAAc,CAACJ,IAAI,CAAE,CAAI,GAAA,CAAA,CAAA;AACtC,CAAA;;AAEA;AACA;AACA;AACA;AACO,SAASI,cAAcA,CAACJ,IAAY,EAAE;EAC3C,OAAOK,UAAU,CAACL,IAAI,CAAC,CAACM,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;AAC7C;;;;"}
|
package/dist/build/ember-cli.cjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { stripIndents } = require('common-tags');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Builds a file with a single export, COMPONENT_MAP, that
|
|
7
|
-
* is a map of the provided paths *to* all exported identifiers
|
|
8
|
-
* from each of the provided paths.
|
|
9
|
-
*
|
|
10
|
-
* This is helpful for building a map of imports to force to be included
|
|
11
|
-
* in the build - a requirement for builds that tend to tree shake.
|
|
12
|
-
*
|
|
13
|
-
* @param {string[]} paths - list of import paths for each module that you want availableb to the REPL
|
|
14
|
-
*/
|
|
15
|
-
module.exports.buildComponentMap = function buildComponentMap(paths) {
|
|
16
|
-
const writeFile = require('broccoli-file-creator');
|
|
17
|
-
const fileContent = stripIndents`
|
|
18
|
-
${paths
|
|
19
|
-
.map((path, i) => {
|
|
20
|
-
return `import * as ComponentMapPart${i} from '${path}';`;
|
|
21
|
-
})
|
|
22
|
-
.join('\n')}
|
|
23
|
-
|
|
24
|
-
export const COMPONENT_MAP = {
|
|
25
|
-
${paths
|
|
26
|
-
.map((path, i) => {
|
|
27
|
-
return `'${path}': ComponentMapPart${i},`;
|
|
28
|
-
})
|
|
29
|
-
.join('\n')}
|
|
30
|
-
};
|
|
31
|
-
`;
|
|
32
|
-
|
|
33
|
-
const tree = writeFile('/ember-repl/component-map.js', fileContent);
|
|
34
|
-
|
|
35
|
-
return tree;
|
|
36
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/test-support/index.ts"],"sourcesContent":["import { CACHE } from '../browser/compile/index.ts';\n\nexport function clearCompileCache() {\n CACHE.clear();\n}\n"],"names":["clearCompileCache","CACHE","clear"],"mappings":";;AAEO,SAASA,iBAAiBA,GAAG;EAClCC,KAAK,CAACC,KAAK,EAAE,CAAA;AACf;;;;"}
|
package/src/browser/cjs/index.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { preprocess, transform } from '../gjs.ts';
|
|
2
|
-
import { nameFor } from '../utils.ts';
|
|
3
|
-
import { evalSnippet } from './eval.ts';
|
|
4
|
-
|
|
5
|
-
import type { CompileResult, ExtraModules } from '../types.ts';
|
|
6
|
-
import type { ComponentLike } from '@glint/template';
|
|
7
|
-
|
|
8
|
-
export interface Info {
|
|
9
|
-
code: string;
|
|
10
|
-
name: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export async function compileJS(code: string, extraModules?: ExtraModules): Promise<CompileResult> {
|
|
14
|
-
let name = nameFor(code);
|
|
15
|
-
let component: undefined | ComponentLike;
|
|
16
|
-
let error: undefined | Error;
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
let compiled = await compileGJS({ code: code, name });
|
|
20
|
-
|
|
21
|
-
if (!compiled) {
|
|
22
|
-
throw new Error(`Compiled output is missing`);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
component = evalSnippet(compiled, extraModules).default as unknown as ComponentLike;
|
|
26
|
-
} catch (e) {
|
|
27
|
-
error = e as Error | undefined;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return { name, component, error };
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async function compileGJS({ code: input, name }: Info) {
|
|
34
|
-
let preprocessed = await preprocess(input, name);
|
|
35
|
-
let result = await transform(preprocessed, name);
|
|
36
|
-
|
|
37
|
-
if (!result) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
let { code } = result;
|
|
42
|
-
|
|
43
|
-
return code;
|
|
44
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type Plugin } from 'unified';
|
|
2
|
-
|
|
3
|
-
export interface EvalImportMap {
|
|
4
|
-
[moduleName: string]: ScopeMap;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface ScopeMap {
|
|
8
|
-
[localName: string]: unknown;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export type UnifiedPlugin = Plugin; // Parameters<ReturnType<typeof unified>['use']>[0];
|
package/src/browser/esm/index.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { preprocess, transform } from '../gjs.ts';
|
|
2
|
-
import { modules } from '../known-modules.ts';
|
|
3
|
-
import { nameFor } from '../utils.ts';
|
|
4
|
-
|
|
5
|
-
import type { CompileResult, ExtraModules } from '../types.ts';
|
|
6
|
-
import type Component from '@glimmer/component';
|
|
7
|
-
import type { ComponentLike } from '@glint/template';
|
|
8
|
-
|
|
9
|
-
export interface Info {
|
|
10
|
-
code: string;
|
|
11
|
-
name: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export async function compileJS(code: string, extraModules?: ExtraModules): Promise<CompileResult> {
|
|
15
|
-
let name = nameFor(code);
|
|
16
|
-
let component: undefined | ComponentLike;
|
|
17
|
-
let error: undefined | Error;
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
let compiled = await compileGJS({ code: code, name });
|
|
21
|
-
|
|
22
|
-
if (!compiled) {
|
|
23
|
-
throw new Error(`Compiled output is missing`);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// NOTE: we cannot `eval` ESM
|
|
27
|
-
compiled = proxyToSkypack(compiled, extraModules);
|
|
28
|
-
component = (await evalSnippet(compiled)) as unknown as ComponentLike;
|
|
29
|
-
} catch (e) {
|
|
30
|
-
error = e as Error | undefined;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return { name, component, error };
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function proxyToSkypack(code: string, extraModules?: ExtraModules) {
|
|
37
|
-
let knownModules = [...Object.keys(extraModules || {}), ...Object.keys(modules)];
|
|
38
|
-
let origin = location.origin;
|
|
39
|
-
|
|
40
|
-
let result = code.replaceAll(/from ('|")([^"']+)('|")/g, (_, __, modulePath) => {
|
|
41
|
-
if (knownModules.includes(modulePath)) {
|
|
42
|
-
return `from '${origin}/${modulePath}'`;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return `from 'https://cdn.skypack.dev/${modulePath}'`;
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
return result;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async function evalSnippet(code: string) {
|
|
52
|
-
let encodedJs = encodeURIComponent(code);
|
|
53
|
-
let result = await import(
|
|
54
|
-
/* webpackIgnore: true */ `data:text/javascript;charset=utf-8,${encodedJs}`
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
if (!result.default) {
|
|
58
|
-
throw new Error(`Expected module to have a default export, found ${Object.keys(result)}`);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return result as {
|
|
62
|
-
default: Component;
|
|
63
|
-
services?: { [key: string]: unknown };
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
async function compileGJS({ code: input, name }: Info) {
|
|
68
|
-
let preprocessed = await preprocess(input, name);
|
|
69
|
-
let result = await transform(preprocessed, name, {
|
|
70
|
-
modules: false,
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
if (!result) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
let { code } = result;
|
|
78
|
-
|
|
79
|
-
return code;
|
|
80
|
-
}
|
package/src/browser/gjs.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { importSync } from '@embroider/macros';
|
|
2
|
-
|
|
3
|
-
import babelPluginEmberTemplateCompilation from 'babel-plugin-ember-template-compilation';
|
|
4
|
-
|
|
5
|
-
import type { Babel } from './types.ts';
|
|
6
|
-
|
|
7
|
-
const compiler = importSync('ember-source/dist/ember-template-compiler.js');
|
|
8
|
-
|
|
9
|
-
let processor: any;
|
|
10
|
-
let fetchingPromise: Promise<any>;
|
|
11
|
-
|
|
12
|
-
export async function preprocess(input: string, name: string): Promise<string> {
|
|
13
|
-
if (!fetchingPromise) {
|
|
14
|
-
fetchingPromise = import('content-tag');
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (!processor) {
|
|
18
|
-
let { Preprocessor } = await fetchingPromise;
|
|
19
|
-
|
|
20
|
-
processor = new Preprocessor();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return processor.process(input, `${name}.js`);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export async function transform(
|
|
27
|
-
intermediate: string,
|
|
28
|
-
name: string,
|
|
29
|
-
options: any = {}
|
|
30
|
-
): Promise<ReturnType<Babel['transform']>> {
|
|
31
|
-
let babel = (await import('@babel/standalone')) as Babel;
|
|
32
|
-
|
|
33
|
-
return babel.transform(intermediate, {
|
|
34
|
-
filename: `${name}.js`,
|
|
35
|
-
plugins: [
|
|
36
|
-
// [babelPluginIntermediateGJS],
|
|
37
|
-
[
|
|
38
|
-
babelPluginEmberTemplateCompilation,
|
|
39
|
-
{
|
|
40
|
-
compiler,
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
[babel.availablePlugins['proposal-decorators'], { legacy: true }],
|
|
44
|
-
[babel.availablePlugins['proposal-class-properties']],
|
|
45
|
-
],
|
|
46
|
-
presets: [
|
|
47
|
-
[
|
|
48
|
-
babel.availablePresets['env'],
|
|
49
|
-
{
|
|
50
|
-
// false -- keeps ES Modules
|
|
51
|
-
modules: 'cjs',
|
|
52
|
-
targets: { esmodules: true },
|
|
53
|
-
forceAllTransforms: false,
|
|
54
|
-
...options,
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
],
|
|
58
|
-
});
|
|
59
|
-
}
|
package/src/browser/index.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { compile, Compiled } from './compile/index.ts';
|
|
2
|
-
export { compileHBS } from './hbs.ts';
|
|
3
|
-
export { compileJS } from './js.ts';
|
|
4
|
-
export { modules as frameworkModules } from './known-modules.ts';
|
|
5
|
-
export { invocationName, invocationOf, nameFor } from './utils.ts';
|
|
6
|
-
|
|
7
|
-
// Public Types
|
|
8
|
-
export type { CompileResult } from './types';
|
package/src/browser/js.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { compileJS as compileAMD } from './cjs/index.ts';
|
|
2
|
-
import { compileJS as compileESM } from './esm/index.ts';
|
|
3
|
-
|
|
4
|
-
import type { CompileResult, ExtraModules, Options } from './types.ts';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @public
|
|
8
|
-
* Transpiles GlimmerJS (*.gjs) formatted text into and evaluates as a JS Module.
|
|
9
|
-
* The returned component can be invoked explicitly in the consuming project.
|
|
10
|
-
*
|
|
11
|
-
* SEE: README for example usage
|
|
12
|
-
*
|
|
13
|
-
* @param {string} code: the code to be compiled
|
|
14
|
-
* @param {Object} extraModules: map of import paths to modules. This isn't needed
|
|
15
|
-
* for classic ember projects, but for strict static ember projects, extraModules
|
|
16
|
-
* will need to be pasesd if compileJS is intended to be used in a styleguide or
|
|
17
|
-
* if there are additional modules that could be imported in the passed `code`.
|
|
18
|
-
*
|
|
19
|
-
* Later on, imports that are not present by default (ember/glimmer) or that
|
|
20
|
-
* are not provided by extraModules will be searched on npm to see if a package
|
|
21
|
-
* needs to be downloaded before running the `code` / invoking the component
|
|
22
|
-
*/
|
|
23
|
-
export function compileJS(
|
|
24
|
-
code: string,
|
|
25
|
-
extraModules?: ExtraModules,
|
|
26
|
-
options?: Options
|
|
27
|
-
): Promise<CompileResult> {
|
|
28
|
-
if (options?.skypack) {
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
|
-
// if (!(window as any).webpackChunkDummy) {
|
|
31
|
-
// return {
|
|
32
|
-
// component: undefined,
|
|
33
|
-
// name: undefined,
|
|
34
|
-
// error: `Your environment is using AMD utilities -- using native ESM is not allowed unless the environment is also ESM`,
|
|
35
|
-
// };
|
|
36
|
-
// }
|
|
37
|
-
|
|
38
|
-
return compileESM(code, extraModules);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return compileAMD(code, extraModules);
|
|
42
|
-
}
|
package/src/browser/types.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { availablePlugins, availablePresets, transform } from '@babel/standalone';
|
|
2
|
-
import type { ComponentLike } from '@glint/template';
|
|
3
|
-
|
|
4
|
-
export interface CompileResult {
|
|
5
|
-
component?: ComponentLike;
|
|
6
|
-
error?: Error;
|
|
7
|
-
name: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface Babel {
|
|
11
|
-
availablePlugins: typeof availablePlugins;
|
|
12
|
-
availablePresets: typeof availablePresets;
|
|
13
|
-
transform: typeof transform;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export type Options = {
|
|
17
|
-
/**
|
|
18
|
-
* @internal
|
|
19
|
-
* @deprecated do not use - not under semver
|
|
20
|
-
*/
|
|
21
|
-
skypack?: boolean;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export type ExtraModules = Record<string, unknown>;
|
package/src/build/ember-cli.cjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { stripIndents } = require('common-tags');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Builds a file with a single export, COMPONENT_MAP, that
|
|
7
|
-
* is a map of the provided paths *to* all exported identifiers
|
|
8
|
-
* from each of the provided paths.
|
|
9
|
-
*
|
|
10
|
-
* This is helpful for building a map of imports to force to be included
|
|
11
|
-
* in the build - a requirement for builds that tend to tree shake.
|
|
12
|
-
*
|
|
13
|
-
* @param {string[]} paths - list of import paths for each module that you want availableb to the REPL
|
|
14
|
-
*/
|
|
15
|
-
module.exports.buildComponentMap = function buildComponentMap(paths) {
|
|
16
|
-
const writeFile = require('broccoli-file-creator');
|
|
17
|
-
const fileContent = stripIndents`
|
|
18
|
-
${paths
|
|
19
|
-
.map((path, i) => {
|
|
20
|
-
return `import * as ComponentMapPart${i} from '${path}';`;
|
|
21
|
-
})
|
|
22
|
-
.join('\n')}
|
|
23
|
-
|
|
24
|
-
export const COMPONENT_MAP = {
|
|
25
|
-
${paths
|
|
26
|
-
.map((path, i) => {
|
|
27
|
-
return `'${path}': ComponentMapPart${i},`;
|
|
28
|
-
})
|
|
29
|
-
.join('\n')}
|
|
30
|
-
};
|
|
31
|
-
`;
|
|
32
|
-
|
|
33
|
-
const tree = writeFile('/ember-repl/component-map.js', fileContent);
|
|
34
|
-
|
|
35
|
-
return tree;
|
|
36
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|