@embroider/core 3.4.6 → 3.4.8-unstable.80f442d
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +13 -11
- package/src/app-files.d.ts +2 -3
- package/src/app-files.js +1 -1
- package/src/app-files.js.map +1 -1
- package/src/index.d.ts +1 -1
- package/src/index.js.map +1 -1
- package/src/module-resolver.d.ts +24 -15
- package/src/module-resolver.js +268 -191
- package/src/module-resolver.js.map +1 -1
- package/src/node-resolve.d.ts +33 -0
- package/src/node-resolve.js +131 -0
- package/src/node-resolve.js.map +1 -0
- package/src/virtual-content.d.ts +6 -2
- package/src/virtual-content.js +95 -38
- package/src/virtual-content.js.map +1 -1
- package/src/virtual-test-support-styles.d.ts +4 -0
- package/src/virtual-test-support-styles.js +65 -0
- package/src/virtual-test-support-styles.js.map +1 -0
- package/src/virtual-test-support.d.ts +4 -0
- package/src/virtual-test-support.js +69 -0
- package/src/virtual-test-support.js.map +1 -0
- package/src/virtual-vendor-styles.d.ts +4 -0
- package/src/virtual-vendor-styles.js +72 -0
- package/src/virtual-vendor-styles.js.map +1 -0
- package/LICENSE +0 -21
package/src/virtual-content.d.ts
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
import type { Resolver } from '.';
|
2
|
-
export
|
2
|
+
export interface VirtualContentResult {
|
3
|
+
src: string;
|
4
|
+
watches: string[];
|
5
|
+
}
|
6
|
+
export declare function virtualContent(filename: string, resolver: Resolver): VirtualContentResult;
|
3
7
|
export declare function virtualExternalESModule(specifier: string, exports: string[] | undefined): string;
|
4
8
|
export declare function virtualExternalCJSModule(specifier: string): string;
|
5
|
-
export declare function virtualPairComponent(hbsModule: string, jsModule: string |
|
9
|
+
export declare function virtualPairComponent(hbsModule: string, jsModule: string | undefined): string;
|
6
10
|
export declare function fastbootSwitch(specifier: string, fromFile: string, names: Set<string>): string;
|
7
11
|
export declare function decodeFastbootSwitch(filename: string): {
|
8
12
|
names: string[];
|
package/src/virtual-content.js
CHANGED
@@ -4,6 +4,9 @@ exports.decodeImplicitModules = exports.decodeFastbootSwitch = exports.fastbootS
|
|
4
4
|
const path_1 = require("path");
|
5
5
|
const _1 = require(".");
|
6
6
|
const js_handlebars_1 = require("./js-handlebars");
|
7
|
+
const virtual_test_support_1 = require("./virtual-test-support");
|
8
|
+
const virtual_test_support_styles_1 = require("./virtual-test-support-styles");
|
9
|
+
const virtual_vendor_styles_1 = require("./virtual-vendor-styles");
|
7
10
|
const externalESPrefix = '/@embroider/ext-es/';
|
8
11
|
const externalCJSPrefix = '/@embroider/ext-cjs/';
|
9
12
|
// Given a filename that was passed to your ModuleRequest's `virtualize()`,
|
@@ -25,12 +28,24 @@ function virtualContent(filename, resolver) {
|
|
25
28
|
}
|
26
29
|
let fb = decodeFastbootSwitch(filename);
|
27
30
|
if (fb) {
|
28
|
-
return
|
31
|
+
return renderFastbootSwitchTemplate(fb);
|
29
32
|
}
|
30
33
|
let im = decodeImplicitModules(filename);
|
31
34
|
if (im) {
|
32
35
|
return renderImplicitModules(im, resolver);
|
33
36
|
}
|
37
|
+
let isImplicitTestScripts = (0, virtual_test_support_1.decodeImplicitTestScripts)(filename);
|
38
|
+
if (isImplicitTestScripts) {
|
39
|
+
return (0, virtual_test_support_1.renderImplicitTestScripts)(filename, resolver);
|
40
|
+
}
|
41
|
+
let isVendorStyles = (0, virtual_vendor_styles_1.decodeVirtualVendorStyles)(filename);
|
42
|
+
if (isVendorStyles) {
|
43
|
+
return (0, virtual_vendor_styles_1.renderVendorStyles)(filename, resolver);
|
44
|
+
}
|
45
|
+
let isTestSupportStyles = (0, virtual_test_support_styles_1.decodeTestSupportStyles)(filename);
|
46
|
+
if (isTestSupportStyles) {
|
47
|
+
return (0, virtual_test_support_styles_1.renderTestSupportStyles)(filename, resolver);
|
48
|
+
}
|
34
49
|
throw new Error(`not an @embroider/core virtual file: ${filename}`);
|
35
50
|
}
|
36
51
|
exports.virtualContent = virtualContent;
|
@@ -51,14 +66,23 @@ export { {{#each names as |name|}}{{name}}, {{/each}} }
|
|
51
66
|
{{/if}}
|
52
67
|
{{/if}}
|
53
68
|
`);
|
54
|
-
function renderESExternalShim({ moduleName, exports }) {
|
55
|
-
return
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
69
|
+
function renderESExternalShim({ moduleName, exports, }) {
|
70
|
+
return {
|
71
|
+
src: externalESShim({
|
72
|
+
moduleName,
|
73
|
+
default: exports.includes('default'),
|
74
|
+
names: exports.filter(n => n !== 'default'),
|
75
|
+
}),
|
76
|
+
watches: [],
|
77
|
+
};
|
78
|
+
}
|
79
|
+
function pairedComponentShim(params) {
|
80
|
+
return {
|
81
|
+
src: pairedComponentShimTemplate(params),
|
82
|
+
watches: [],
|
83
|
+
};
|
60
84
|
}
|
61
|
-
const
|
85
|
+
const pairedComponentShimTemplate = (0, js_handlebars_1.compile)(`
|
62
86
|
import { setComponentTemplate } from "@ember/component";
|
63
87
|
import template from "{{{js-string-escape relativeHBSModule}}}";
|
64
88
|
{{#if relativeJSModule}}
|
@@ -156,6 +180,12 @@ function decodeFastbootSwitch(filename) {
|
|
156
180
|
}
|
157
181
|
}
|
158
182
|
exports.decodeFastbootSwitch = decodeFastbootSwitch;
|
183
|
+
function renderFastbootSwitchTemplate(params) {
|
184
|
+
return {
|
185
|
+
src: fastbootSwitchTemplate(params),
|
186
|
+
watches: [],
|
187
|
+
};
|
188
|
+
}
|
159
189
|
const fastbootSwitchTemplate = (0, js_handlebars_1.compile)(`
|
160
190
|
import { macroCondition, getGlobalConfig, importSync } from '@embroider/macros';
|
161
191
|
let mod;
|
@@ -192,8 +222,8 @@ function renderImplicitModules({ type, fromFile, }, resolver) {
|
|
192
222
|
if (!(pkg === null || pkg === void 0 ? void 0 : pkg.isV2Ember())) {
|
193
223
|
throw new Error(`bug: saw special implicit modules import in non-ember package at ${fromFile}`);
|
194
224
|
}
|
195
|
-
let
|
196
|
-
let
|
225
|
+
let ownModules = [];
|
226
|
+
let dependencyModules = [];
|
197
227
|
let deps = pkg.dependencies.sort(orderAddons);
|
198
228
|
for (let dep of deps) {
|
199
229
|
// anything that isn't a v2 ember package by this point is not an active
|
@@ -226,7 +256,7 @@ function renderImplicitModules({ type, fromFile, }, resolver) {
|
|
226
256
|
runtime = renamedModules[runtimeRenameLookup];
|
227
257
|
}
|
228
258
|
runtime = runtime.split(path_1.sep).join('/');
|
229
|
-
|
259
|
+
ownModules.push({
|
230
260
|
runtime,
|
231
261
|
buildtime: path_1.posix.join(packageName, name),
|
232
262
|
});
|
@@ -235,20 +265,32 @@ function renderImplicitModules({ type, fromFile, }, resolver) {
|
|
235
265
|
// we don't recurse across an engine boundary. Engines import their own
|
236
266
|
// implicit-modules.
|
237
267
|
if (!dep.isEngine()) {
|
238
|
-
|
268
|
+
dependencyModules.push(path_1.posix.join(dep.name, `-embroider-${type}.js`));
|
239
269
|
}
|
240
270
|
}
|
241
|
-
return implicitModulesTemplate({
|
271
|
+
return { src: implicitModulesTemplate({ ownModules, dependencyModules }), watches: [] };
|
242
272
|
}
|
243
273
|
const implicitModulesTemplate = (0, js_handlebars_1.compile)(`
|
244
|
-
|
245
|
-
|
246
|
-
{{#each
|
247
|
-
|
274
|
+
|
275
|
+
|
276
|
+
{{#each dependencyModules as |module index|}}
|
277
|
+
import dep{{index}} from "{{js-string-escape module}}";
|
248
278
|
{{/each}}
|
249
|
-
|
250
|
-
|
279
|
+
|
280
|
+
{{#each ownModules as |module index|}}
|
281
|
+
import * as own{{index}} from "{{js-string-escape module.buildtime}}";
|
251
282
|
{{/each}}
|
283
|
+
|
284
|
+
export default Object.assign({},
|
285
|
+
{{#each dependencyModules as |module index|}}
|
286
|
+
dep{{index}},
|
287
|
+
{{/each}}
|
288
|
+
{
|
289
|
+
{{#each ownModules as |module index|}}
|
290
|
+
"{{js-string-escape module.runtime}}": own{{index}},
|
291
|
+
{{/each}}
|
292
|
+
}
|
293
|
+
);
|
252
294
|
`);
|
253
295
|
// meta['renamed-modules'] has mapping from classic filename to real filename.
|
254
296
|
// This takes that and converts it to the inverst mapping from real import path
|
@@ -274,26 +316,41 @@ function orderAddons(depA, depB) {
|
|
274
316
|
}
|
275
317
|
return depAIdx - depBIdx;
|
276
318
|
}
|
277
|
-
|
278
|
-
{
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
319
|
+
function renderCJSExternalShim(params) {
|
320
|
+
return {
|
321
|
+
src: renderCJSExternalShimTemplate(params),
|
322
|
+
watches: [],
|
323
|
+
};
|
324
|
+
}
|
325
|
+
const renderCJSExternalShimTemplate = (0, js_handlebars_1.compile)(`
|
326
|
+
module.exports = new Proxy({}, {
|
327
|
+
get(target, prop) {
|
328
|
+
|
329
|
+
{{!- our proxy always presents as ES module so that we can intercept "get('default')" -}}
|
330
|
+
if (prop === '__esModule') {
|
331
|
+
return true;
|
332
|
+
}
|
287
333
|
|
288
|
-
|
289
|
-
|
290
|
-
|
334
|
+
{{#if (eq moduleName "require")}}
|
335
|
+
const m = window.requirejs;
|
336
|
+
{{else}}
|
337
|
+
const m = window.require("{{{js-string-escape moduleName}}}");
|
338
|
+
{{/if}}
|
291
339
|
|
292
|
-
|
293
|
-
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
module
|
340
|
+
{{!-
|
341
|
+
There are plenty of hand-written AMD defines floating around
|
342
|
+
that lack an __esModule declaration.
|
343
|
+
|
344
|
+
As far as I can tell, Ember's loader was already treating the Boolean(m.default)===true
|
345
|
+
case as a module, so in theory we aren't breaking anything by
|
346
|
+
treating it as such when other packagers come looking.
|
347
|
+
-}}
|
348
|
+
if (prop === 'default' && !m.__esModule && !m.default) {
|
349
|
+
return m;
|
350
|
+
}
|
351
|
+
|
352
|
+
return m[prop];
|
353
|
+
}
|
354
|
+
});
|
298
355
|
`);
|
299
356
|
//# sourceMappingURL=virtual-content.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"virtual-content.js","sourceRoot":"","sources":["virtual-content.ts"],"names":[],"mappings":";;;AAAA,+BAAoE;AAEpE,wBA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AddonPackage, Package } from '.';\nimport { explicitRelative, extensionsPattern } from '.';\nimport { compile } from './js-handlebars';\n\nconst externalESPrefix = '/@embroider/ext-es/';\nconst externalCJSPrefix = '/@embroider/ext-cjs/';\n\n// Given a filename that was passed to your ModuleRequest's `virtualize()`,\n// this produces the corresponding contents. It's a static, stateless function\n// because we recognize that that process that did resolution might not be the\n// same one that loads the content.\nexport function virtualContent(filename: string, resolver: Resolver): string {\n let cjsExtern = decodeVirtualExternalCJSModule(filename);\n if (cjsExtern) {\n return renderCJSExternalShim(cjsExtern);\n }\n\n let extern = decodeVirtualExternalESModule(filename);\n if (extern) {\n return renderESExternalShim(extern);\n }\n let match = decodeVirtualPairComponent(filename);\n if (match) {\n return pairedComponentShim(match);\n }\n\n let fb = decodeFastbootSwitch(filename);\n if (fb) {\n return fastbootSwitchTemplate(fb);\n }\n\n let im = decodeImplicitModules(filename);\n if (im) {\n return renderImplicitModules(im, resolver);\n }\n\n throw new Error(`not an @embroider/core virtual file: ${filename}`);\n}\n\nconst externalESShim = compile(`\n{{#if (eq moduleName \"require\")}}\nconst m = window.requirejs;\nexport default m;\nconst has = m.has;\nexport { has }\n{{else}}\nconst m = window.require(\"{{{js-string-escape moduleName}}}\");\n{{#if default}}\nexport default m.default;\n{{/if}}\n{{#if names}}\nconst { {{#each names as |name|}}{{name}}, {{/each}} } = m;\nexport { {{#each names as |name|}}{{name}}, {{/each}} }\n{{/if}}\n{{/if}}\n`) as (params: { moduleName: string; default: boolean; names: string[] }) => string;\n\nfunction renderESExternalShim({ moduleName, exports }: { moduleName: string; exports: string[] }): string {\n return externalESShim({\n moduleName,\n default: exports.includes('default'),\n names: exports.filter(n => n !== 'default'),\n });\n}\n\nconst pairedComponentShim = compile(`\nimport { setComponentTemplate } from \"@ember/component\";\nimport template from \"{{{js-string-escape relativeHBSModule}}}\";\n{{#if relativeJSModule}}\nimport component from \"{{{js-string-escape relativeJSModule}}}\";\nexport default setComponentTemplate(template, component);\n{{else}}\nimport templateOnlyComponent from \"@ember/component/template-only\";\nexport default setComponentTemplate(template, templateOnlyComponent(undefined, \"{{{js-string-escape debugName}}}\"));\n{{/if}}\n`) as (params: { relativeHBSModule: string; relativeJSModule: string | null; debugName: string }) => string;\n\nexport function virtualExternalESModule(specifier: string, exports: string[] | undefined): string {\n if (exports) {\n return externalESPrefix + specifier + `?exports=${exports.join(',')}`;\n } else {\n return externalESPrefix + specifier;\n }\n}\n\nexport function virtualExternalCJSModule(specifier: string): string {\n return externalCJSPrefix + specifier;\n}\n\nfunction decodeVirtualExternalESModule(filename: string): { moduleName: string; exports: string[] } | undefined {\n if (filename.startsWith(externalESPrefix)) {\n let exports: string[] = [];\n let url = new URL(filename.slice(externalESPrefix.length), 'http://example.com');\n let nameString = url.searchParams.get('exports');\n if (nameString) {\n exports = nameString.split(',');\n }\n let moduleName = url.pathname.slice(1);\n return { moduleName, exports };\n }\n}\n\nfunction decodeVirtualExternalCJSModule(filename: string) {\n if (filename.startsWith(externalCJSPrefix)) {\n return { moduleName: filename.slice(externalCJSPrefix.length) };\n }\n}\n\nconst pairComponentMarker = '-embroider-pair-component';\nconst pairComponentPattern = /^(?<hbsModule>.*)\\/(?<jsModule>[^\\/]*)-embroider-pair-component$/;\n\nexport function virtualPairComponent(hbsModule: string, jsModule: string | null): string {\n let relativeJSModule = '';\n if (jsModule) {\n relativeJSModule = explicitRelative(hbsModule, jsModule);\n }\n return `${hbsModule}/${encodeURIComponent(relativeJSModule)}${pairComponentMarker}`;\n}\n\nfunction decodeVirtualPairComponent(\n filename: string\n): { relativeHBSModule: string; relativeJSModule: string | null; debugName: string } | null {\n // Performance: avoid paying regex exec cost unless needed\n if (!filename.includes(pairComponentMarker)) {\n return null;\n }\n let match = pairComponentPattern.exec(filename);\n if (!match) {\n return null;\n }\n let { hbsModule, jsModule } = match.groups! as { hbsModule: string; jsModule: string };\n // target our real hbs module from our virtual module\n let relativeHBSModule = explicitRelative(dirname(filename), hbsModule);\n return {\n relativeHBSModule,\n relativeJSModule: decodeURIComponent(jsModule) || null,\n debugName: basename(relativeHBSModule).replace(/\\.(js|hbs)$/, ''),\n };\n}\n\nconst fastbootSwitchSuffix = '/embroider_fastboot_switch';\nconst fastbootSwitchPattern = /(?<original>.+)\\/embroider_fastboot_switch(?:\\?names=(?<names>.+))?$/;\nexport function fastbootSwitch(specifier: string, fromFile: string, names: Set<string>): string {\n let filename = `${resolve(dirname(fromFile), specifier)}${fastbootSwitchSuffix}`;\n if (names.size > 0) {\n return `${filename}?names=${[...names].join(',')}`;\n } else {\n return filename;\n }\n}\n\nexport function decodeFastbootSwitch(filename: string) {\n // Performance: avoid paying regex exec cost unless needed\n if (!filename.includes(fastbootSwitchSuffix)) {\n return;\n }\n let match = fastbootSwitchPattern.exec(filename);\n if (match) {\n let names = match.groups?.names?.split(',') ?? [];\n return {\n names: names.filter(name => name !== 'default'),\n hasDefaultExport: names.includes('default'),\n filename: match.groups!.original,\n };\n }\n}\n\nconst fastbootSwitchTemplate = compile(`\nimport { macroCondition, getGlobalConfig, importSync } from '@embroider/macros';\nlet mod;\nif (macroCondition(getGlobalConfig().fastboot?.isRunning)){\n mod = importSync('./fastboot');\n} else {\n mod = importSync('./browser');\n}\n{{#if hasDefaultExport}}\nexport default mod.default;\n{{/if}}\n{{#each names as |name|}}\nexport const {{name}} = mod.{{name}};\n{{/each}}\n`) as (params: { names: string[]; hasDefaultExport: boolean }) => string;\n\nconst implicitModulesPattern = /(?<filename>.*)[\\\\/]-embroider-implicit-(?<test>test-)?modules\\.js$/;\n\nexport function decodeImplicitModules(\n filename: string\n): { type: 'implicit-modules' | 'implicit-test-modules'; fromFile: string } | undefined {\n // Performance: avoid paying regex exec cost unless needed\n if (!filename.includes('-embroider-implicit-')) {\n return;\n }\n let m = implicitModulesPattern.exec(filename);\n if (m) {\n return {\n type: m.groups!.test ? 'implicit-test-modules' : 'implicit-modules',\n fromFile: m.groups!.filename,\n };\n }\n}\n\nfunction renderImplicitModules(\n {\n type,\n fromFile,\n }: {\n type: 'implicit-modules' | 'implicit-test-modules';\n fromFile: string;\n },\n resolver: Resolver\n): string {\n let resolvableExtensionsPattern = extensionsPattern(resolver.options.resolvableExtensions);\n\n const pkg = resolver.packageCache.ownerOfFile(fromFile);\n if (!pkg?.isV2Ember()) {\n throw new Error(`bug: saw special implicit modules import in non-ember package at ${fromFile}`);\n }\n\n let lazyModules: { runtime: string; buildtime: string }[] = [];\n let eagerModules: string[] = [];\n\n let deps = pkg.dependencies.sort(orderAddons);\n\n for (let dep of deps) {\n // anything that isn't a v2 ember package by this point is not an active\n // addon.\n if (!dep.isV2Addon()) {\n continue;\n }\n\n // we ignore peerDependencies here because classic ember-cli ignores\n // peerDependencies here, and we're implementing the implicit-modules\n // backward-comptibility feature.\n if (pkg.categorizeDependency(dep.name) === 'peerDependencies') {\n continue;\n }\n\n let implicitModules = dep.meta[type];\n if (implicitModules) {\n let renamedModules = inverseRenamedModules(dep.meta, resolvableExtensionsPattern);\n for (let name of implicitModules) {\n let packageName = dep.name;\n\n let renamedMeta = dep.meta['renamed-packages'];\n if (renamedMeta) {\n Object.entries(renamedMeta).forEach(([key, value]) => {\n if (value === dep.name) {\n packageName = key;\n }\n });\n }\n\n let runtime = join(packageName, name).replace(resolvableExtensionsPattern, '');\n let runtimeRenameLookup = runtime.split('\\\\').join('/');\n if (renamedModules && renamedModules[runtimeRenameLookup]) {\n runtime = renamedModules[runtimeRenameLookup];\n }\n runtime = runtime.split(sep).join('/');\n lazyModules.push({\n runtime,\n buildtime: posix.join(packageName, name),\n });\n }\n }\n // we don't recurse across an engine boundary. Engines import their own\n // implicit-modules.\n if (!dep.isEngine()) {\n eagerModules.push(posix.join(dep.name, `-embroider-${type}.js`));\n }\n }\n return implicitModulesTemplate({ lazyModules, eagerModules });\n}\n\nconst implicitModulesTemplate = compile(`\nimport { importSync as i } from '@embroider/macros';\nlet d = window.define;\n{{#each lazyModules as |module|}}\nd(\"{{js-string-escape module.runtime}}\", function(){ return i(\"{{js-string-escape module.buildtime}}\");});\n{{/each}}\n{{#each eagerModules as |module|}}\nimport \"{{js-string-escape module}}\";\n{{/each}}\n`) as (params: { eagerModules: string[]; lazyModules: { runtime: string; buildtime: string }[] }) => string;\n\n// meta['renamed-modules'] has mapping from classic filename to real filename.\n// This takes that and converts it to the inverst mapping from real import path\n// to classic import path.\nfunction inverseRenamedModules(meta: AddonPackage['meta'], extensions: RegExp) {\n let renamed = meta['renamed-modules'];\n if (renamed) {\n let inverted = {} as { [name: string]: string };\n for (let [classic, real] of Object.entries(renamed)) {\n inverted[real.replace(extensions, '')] = classic.replace(extensions, '');\n }\n return inverted;\n }\n}\n\nfunction orderAddons(depA: Package, depB: Package): number {\n let depAIdx = 0;\n let depBIdx = 0;\n\n if (depA && depA.meta && depA.isV2Addon()) {\n depAIdx = depA.meta['order-index'] || 0;\n }\n if (depB && depB.meta && depB.isV2Addon()) {\n depBIdx = depB.meta['order-index'] || 0;\n }\n\n return depAIdx - depBIdx;\n}\n\nconst renderCJSExternalShim = compile(`\n{{#if (eq moduleName \"require\")}}\nconst m = window.requirejs;\n{{else}}\nconst m = window.require(\"{{{js-string-escape moduleName}}}\");\n{{/if}}\n{{!-\n There are plenty of hand-written AMD defines floating around\n that lack this, and they will break when other build systems\n encounter them.\n\n As far as I can tell, Ember's loader was already treating this\n case as a module, so in theory we aren't breaking anything by\n marking it as such when other packagers come looking.\n\n todo: get review on this part.\n-}}\nif (m.default && !m.__esModule) {\n m.__esModule = true;\n}\nmodule.exports = m;\n`) as (params: { moduleName: string }) => string;\n"]}
|
1
|
+
{"version":3,"file":"virtual-content.js","sourceRoot":"","sources":["virtual-content.ts"],"names":[],"mappings":";;;AAAA,+BAAoE;AAEpE,wBAAwD;AACxD,mDAA0C;AAC1C,iEAA8F;AAC9F,+EAAiG;AACjG,mEAAwF;AAExF,MAAM,gBAAgB,GAAG,qBAAqB,CAAC;AAC/C,MAAM,iBAAiB,GAAG,sBAAsB,CAAC;AAOjD,2EAA2E;AAC3E,8EAA8E;AAC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C,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;SAC1E;QACD,OAAO,QAAQ,CAAC;KACjB;AACH,CAAC;AAED,SAAS,WAAW,CAAC,IAAa,EAAE,IAAa;IAC/C,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,OAAO,GAAG,CAAC,CAAC;IAEhB,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE,EAAE;QACzC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;KACzC;IACD,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE,EAAE;QACzC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;KACzC;IAED,OAAO,OAAO,GAAG,OAAO,CAAC;AAC3B,CAAC;AAED,SAAS,qBAAqB,CAAC,MAA8B;IAC3D,OAAO;QACL,GAAG,EAAE,6BAA6B,CAAC,MAAM,CAAC;QAC1C,OAAO,EAAE,EAAE;KACZ,CAAC;AACJ,CAAC;AAED,MAAM,6BAA6B,GAAG,IAAA,uBAAO,EAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8B7C,CAA+C,CAAC","sourcesContent":["import { dirname, basename, resolve, posix, sep, join } from 'path';\nimport type { Resolver, AddonPackage, Package } from '.';\nimport { explicitRelative, extensionsPattern } from '.';\nimport { compile } from './js-handlebars';\nimport { decodeImplicitTestScripts, renderImplicitTestScripts } from './virtual-test-support';\nimport { decodeTestSupportStyles, renderTestSupportStyles } from './virtual-test-support-styles';\nimport { decodeVirtualVendorStyles, renderVendorStyles } from './virtual-vendor-styles';\n\nconst externalESPrefix = '/@embroider/ext-es/';\nconst externalCJSPrefix = '/@embroider/ext-cjs/';\n\nexport interface VirtualContentResult {\n src: string;\n watches: string[];\n}\n\n// Given a filename that was passed to your ModuleRequest's `virtualize()`,\n// this produces the corresponding contents. It's a static, stateless function\n// because we recognize that that process that did resolution might not be the\n// same one that loads the content.\nexport function virtualContent(filename: string, resolver: Resolver): VirtualContentResult {\n let cjsExtern = decodeVirtualExternalCJSModule(filename);\n if (cjsExtern) {\n return renderCJSExternalShim(cjsExtern);\n }\n\n let extern = decodeVirtualExternalESModule(filename);\n if (extern) {\n return renderESExternalShim(extern);\n }\n let match = decodeVirtualPairComponent(filename);\n if (match) {\n return pairedComponentShim(match);\n }\n\n let fb = decodeFastbootSwitch(filename);\n if (fb) {\n return renderFastbootSwitchTemplate(fb);\n }\n\n let im = decodeImplicitModules(filename);\n if (im) {\n return renderImplicitModules(im, resolver);\n }\n\n let isImplicitTestScripts = decodeImplicitTestScripts(filename);\n if (isImplicitTestScripts) {\n return renderImplicitTestScripts(filename, resolver);\n }\n\n let isVendorStyles = decodeVirtualVendorStyles(filename);\n if (isVendorStyles) {\n return renderVendorStyles(filename, resolver);\n }\n\n let isTestSupportStyles = decodeTestSupportStyles(filename);\n if (isTestSupportStyles) {\n return renderTestSupportStyles(filename, resolver);\n }\n\n throw new Error(`not an @embroider/core virtual file: ${filename}`);\n}\n\nconst externalESShim = compile(`\n{{#if (eq moduleName \"require\")}}\nconst m = window.requirejs;\nexport default m;\nconst has = m.has;\nexport { has }\n{{else}}\nconst m = window.require(\"{{{js-string-escape moduleName}}}\");\n{{#if default}}\nexport default m.default;\n{{/if}}\n{{#if names}}\nconst { {{#each names as |name|}}{{name}}, {{/each}} } = m;\nexport { {{#each names as |name|}}{{name}}, {{/each}} }\n{{/if}}\n{{/if}}\n`) as (params: { moduleName: string; default: boolean; names: string[] }) => string;\n\nfunction renderESExternalShim({\n moduleName,\n exports,\n}: {\n moduleName: string;\n exports: string[];\n}): VirtualContentResult {\n return {\n src: externalESShim({\n moduleName,\n default: exports.includes('default'),\n names: exports.filter(n => n !== 'default'),\n }),\n watches: [],\n };\n}\n\ninterface PairedComponentShimParams {\n relativeHBSModule: string;\n relativeJSModule: string | null;\n debugName: string;\n}\n\nfunction pairedComponentShim(params: PairedComponentShimParams): VirtualContentResult {\n return {\n src: pairedComponentShimTemplate(params),\n watches: [],\n };\n}\n\nconst pairedComponentShimTemplate = compile(`\nimport { setComponentTemplate } from \"@ember/component\";\nimport template from \"{{{js-string-escape relativeHBSModule}}}\";\n{{#if relativeJSModule}}\nimport component from \"{{{js-string-escape relativeJSModule}}}\";\nexport default setComponentTemplate(template, component);\n{{else}}\nimport templateOnlyComponent from \"@ember/component/template-only\";\nexport default setComponentTemplate(template, templateOnlyComponent(undefined, \"{{{js-string-escape debugName}}}\"));\n{{/if}}\n`) as (params: PairedComponentShimParams) => string;\n\nexport function virtualExternalESModule(specifier: string, exports: string[] | undefined): string {\n if (exports) {\n return externalESPrefix + specifier + `?exports=${exports.join(',')}`;\n } else {\n return externalESPrefix + specifier;\n }\n}\n\nexport function virtualExternalCJSModule(specifier: string): string {\n return externalCJSPrefix + specifier;\n}\n\nfunction decodeVirtualExternalESModule(filename: string): { moduleName: string; exports: string[] } | undefined {\n if (filename.startsWith(externalESPrefix)) {\n let exports: string[] = [];\n let url = new URL(filename.slice(externalESPrefix.length), 'http://example.com');\n let nameString = url.searchParams.get('exports');\n if (nameString) {\n exports = nameString.split(',');\n }\n let moduleName = url.pathname.slice(1);\n return { moduleName, exports };\n }\n}\n\nfunction decodeVirtualExternalCJSModule(filename: string) {\n if (filename.startsWith(externalCJSPrefix)) {\n return { moduleName: filename.slice(externalCJSPrefix.length) };\n }\n}\n\nconst pairComponentMarker = '-embroider-pair-component';\nconst pairComponentPattern = /^(?<hbsModule>.*)\\/(?<jsModule>[^\\/]*)-embroider-pair-component$/;\n\nexport function virtualPairComponent(hbsModule: string, jsModule: string | undefined): string {\n let relativeJSModule = '';\n if (jsModule) {\n relativeJSModule = explicitRelative(hbsModule, jsModule);\n }\n return `${hbsModule}/${encodeURIComponent(relativeJSModule)}${pairComponentMarker}`;\n}\n\nfunction decodeVirtualPairComponent(\n filename: string\n): { relativeHBSModule: string; relativeJSModule: string | null; debugName: string } | null {\n // Performance: avoid paying regex exec cost unless needed\n if (!filename.includes(pairComponentMarker)) {\n return null;\n }\n let match = pairComponentPattern.exec(filename);\n if (!match) {\n return null;\n }\n let { hbsModule, jsModule } = match.groups! as { hbsModule: string; jsModule: string };\n // target our real hbs module from our virtual module\n let relativeHBSModule = explicitRelative(dirname(filename), hbsModule);\n return {\n relativeHBSModule,\n relativeJSModule: decodeURIComponent(jsModule) || null,\n debugName: basename(relativeHBSModule).replace(/\\.(js|hbs)$/, ''),\n };\n}\n\nconst fastbootSwitchSuffix = '/embroider_fastboot_switch';\nconst fastbootSwitchPattern = /(?<original>.+)\\/embroider_fastboot_switch(?:\\?names=(?<names>.+))?$/;\nexport function fastbootSwitch(specifier: string, fromFile: string, names: Set<string>): string {\n let filename = `${resolve(dirname(fromFile), specifier)}${fastbootSwitchSuffix}`;\n if (names.size > 0) {\n return `${filename}?names=${[...names].join(',')}`;\n } else {\n return filename;\n }\n}\n\nexport function decodeFastbootSwitch(filename: string) {\n // Performance: avoid paying regex exec cost unless needed\n if (!filename.includes(fastbootSwitchSuffix)) {\n return;\n }\n let match = fastbootSwitchPattern.exec(filename);\n if (match) {\n let names = match.groups?.names?.split(',') ?? [];\n return {\n names: names.filter(name => name !== 'default'),\n hasDefaultExport: names.includes('default'),\n filename: match.groups!.original,\n };\n }\n}\n\ninterface FastbootSwitchParams {\n names: string[];\n hasDefaultExport: boolean;\n}\n\nfunction renderFastbootSwitchTemplate(params: FastbootSwitchParams): VirtualContentResult {\n return {\n src: fastbootSwitchTemplate(params),\n watches: [],\n };\n}\n\nconst fastbootSwitchTemplate = compile(`\nimport { macroCondition, getGlobalConfig, importSync } from '@embroider/macros';\nlet mod;\nif (macroCondition(getGlobalConfig().fastboot?.isRunning)){\n mod = importSync('./fastboot');\n} else {\n mod = importSync('./browser');\n}\n{{#if hasDefaultExport}}\nexport default mod.default;\n{{/if}}\n{{#each names as |name|}}\nexport const {{name}} = mod.{{name}};\n{{/each}}\n`) as (params: FastbootSwitchParams) => string;\n\nconst implicitModulesPattern = /(?<filename>.*)[\\\\/]-embroider-implicit-(?<test>test-)?modules\\.js$/;\n\nexport function decodeImplicitModules(\n filename: string\n): { type: 'implicit-modules' | 'implicit-test-modules'; fromFile: string } | undefined {\n // Performance: avoid paying regex exec cost unless needed\n if (!filename.includes('-embroider-implicit-')) {\n return;\n }\n let m = implicitModulesPattern.exec(filename);\n if (m) {\n return {\n type: m.groups!.test ? 'implicit-test-modules' : 'implicit-modules',\n fromFile: m.groups!.filename,\n };\n }\n}\n\nfunction renderImplicitModules(\n {\n type,\n fromFile,\n }: {\n type: 'implicit-modules' | 'implicit-test-modules';\n fromFile: string;\n },\n resolver: Resolver\n): VirtualContentResult {\n let resolvableExtensionsPattern = extensionsPattern(resolver.options.resolvableExtensions);\n\n const pkg = resolver.packageCache.ownerOfFile(fromFile);\n if (!pkg?.isV2Ember()) {\n throw new Error(`bug: saw special implicit modules import in non-ember package at ${fromFile}`);\n }\n\n let ownModules: { runtime: string; buildtime: string }[] = [];\n let dependencyModules: string[] = [];\n\n let deps = pkg.dependencies.sort(orderAddons);\n\n for (let dep of deps) {\n // anything that isn't a v2 ember package by this point is not an active\n // addon.\n if (!dep.isV2Addon()) {\n continue;\n }\n\n // we ignore peerDependencies here because classic ember-cli ignores\n // peerDependencies here, and we're implementing the implicit-modules\n // backward-comptibility feature.\n if (pkg.categorizeDependency(dep.name) === 'peerDependencies') {\n continue;\n }\n\n let implicitModules = dep.meta[type];\n if (implicitModules) {\n let renamedModules = inverseRenamedModules(dep.meta, resolvableExtensionsPattern);\n for (let name of implicitModules) {\n let packageName = dep.name;\n\n let renamedMeta = dep.meta['renamed-packages'];\n if (renamedMeta) {\n Object.entries(renamedMeta).forEach(([key, value]) => {\n if (value === dep.name) {\n packageName = key;\n }\n });\n }\n\n let runtime = join(packageName, name).replace(resolvableExtensionsPattern, '');\n let runtimeRenameLookup = runtime.split('\\\\').join('/');\n if (renamedModules && renamedModules[runtimeRenameLookup]) {\n runtime = renamedModules[runtimeRenameLookup];\n }\n runtime = runtime.split(sep).join('/');\n ownModules.push({\n runtime,\n buildtime: posix.join(packageName, name),\n });\n }\n }\n // we don't recurse across an engine boundary. Engines import their own\n // implicit-modules.\n if (!dep.isEngine()) {\n dependencyModules.push(posix.join(dep.name, `-embroider-${type}.js`));\n }\n }\n return { src: implicitModulesTemplate({ ownModules, dependencyModules }), watches: [] };\n}\n\nconst implicitModulesTemplate = compile(`\n\n\n{{#each dependencyModules as |module index|}}\n import dep{{index}} from \"{{js-string-escape module}}\";\n{{/each}}\n\n{{#each ownModules as |module index|}}\n import * as own{{index}} from \"{{js-string-escape module.buildtime}}\";\n{{/each}}\n\nexport default Object.assign({},\n {{#each dependencyModules as |module index|}}\n dep{{index}},\n {{/each}}\n {\n {{#each ownModules as |module index|}}\n \"{{js-string-escape module.runtime}}\": own{{index}},\n {{/each}}\n }\n);\n`) as (params: { dependencyModules: string[]; ownModules: { runtime: string; buildtime: string }[] }) => string;\n\n// meta['renamed-modules'] has mapping from classic filename to real filename.\n// This takes that and converts it to the inverst mapping from real import path\n// to classic import path.\nfunction inverseRenamedModules(meta: AddonPackage['meta'], extensions: RegExp) {\n let renamed = meta['renamed-modules'];\n if (renamed) {\n let inverted = {} as { [name: string]: string };\n for (let [classic, real] of Object.entries(renamed)) {\n inverted[real.replace(extensions, '')] = classic.replace(extensions, '');\n }\n return inverted;\n }\n}\n\nfunction orderAddons(depA: Package, depB: Package): number {\n let depAIdx = 0;\n let depBIdx = 0;\n\n if (depA && depA.meta && depA.isV2Addon()) {\n depAIdx = depA.meta['order-index'] || 0;\n }\n if (depB && depB.meta && depB.isV2Addon()) {\n depBIdx = depB.meta['order-index'] || 0;\n }\n\n return depAIdx - depBIdx;\n}\n\nfunction renderCJSExternalShim(params: { moduleName: string }): VirtualContentResult {\n return {\n src: renderCJSExternalShimTemplate(params),\n watches: [],\n };\n}\n\nconst renderCJSExternalShimTemplate = compile(`\nmodule.exports = new Proxy({}, {\n get(target, prop) {\n\n {{!- our proxy always presents as ES module so that we can intercept \"get('default')\" -}}\n if (prop === '__esModule') {\n return true;\n }\n\n {{#if (eq moduleName \"require\")}}\n const m = window.requirejs;\n {{else}}\n const m = window.require(\"{{{js-string-escape moduleName}}}\");\n {{/if}}\n\n {{!-\n There are plenty of hand-written AMD defines floating around\n that lack an __esModule declaration.\n\n As far as I can tell, Ember's loader was already treating the Boolean(m.default)===true\n case as a module, so in theory we aren't breaking anything by\n treating it as such when other packagers come looking.\n -}}\n if (prop === 'default' && !m.__esModule && !m.default) {\n return m;\n }\n\n return m[prop];\n }\n});\n`) as (params: { moduleName: string }) => string;\n"]}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import type { Resolver } from './module-resolver';
|
2
|
+
import type { VirtualContentResult } from './virtual-content';
|
3
|
+
export declare function decodeTestSupportStyles(filename: string): boolean;
|
4
|
+
export declare function renderTestSupportStyles(filename: string, resolver: Resolver): VirtualContentResult;
|
@@ -0,0 +1,65 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.renderTestSupportStyles = exports.decodeTestSupportStyles = void 0;
|
7
|
+
const fs_1 = require("fs");
|
8
|
+
const lodash_1 = require("lodash");
|
9
|
+
const resolve_1 = __importDefault(require("resolve"));
|
10
|
+
function decodeTestSupportStyles(filename) {
|
11
|
+
return filename.endsWith('-embroider-test-support-styles.css');
|
12
|
+
}
|
13
|
+
exports.decodeTestSupportStyles = decodeTestSupportStyles;
|
14
|
+
function renderTestSupportStyles(filename, resolver) {
|
15
|
+
const owner = resolver.packageCache.ownerOfFile(filename);
|
16
|
+
if (!owner) {
|
17
|
+
throw new Error(`Failed to find a valid owner for ${filename}`);
|
18
|
+
}
|
19
|
+
return { src: getTestSupportStyles(owner, resolver), watches: [] };
|
20
|
+
}
|
21
|
+
exports.renderTestSupportStyles = renderTestSupportStyles;
|
22
|
+
function getTestSupportStyles(owner, resolver) {
|
23
|
+
let engineConfig = resolver.owningEngine(owner);
|
24
|
+
let engine = {
|
25
|
+
package: owner,
|
26
|
+
addons: new Map(engineConfig.activeAddons.map(addon => [
|
27
|
+
resolver.packageCache.get(addon.root),
|
28
|
+
addon.canResolveFromFile,
|
29
|
+
])),
|
30
|
+
isApp: true,
|
31
|
+
modulePrefix: resolver.options.modulePrefix,
|
32
|
+
appRelativePath: 'NOT_USED_DELETE_ME',
|
33
|
+
};
|
34
|
+
return generateTestSupportStyles(engine);
|
35
|
+
}
|
36
|
+
function generateTestSupportStyles(engine) {
|
37
|
+
let result = impliedAddonTestSupportStyles(engine).map((sourcePath) => {
|
38
|
+
let source = (0, fs_1.readFileSync)(sourcePath);
|
39
|
+
return `${source}`;
|
40
|
+
});
|
41
|
+
return result.join('');
|
42
|
+
}
|
43
|
+
function impliedAddonTestSupportStyles(engine) {
|
44
|
+
let result = [];
|
45
|
+
for (let addon of (0, lodash_1.sortBy)(Array.from(engine.addons.keys()), pkg => {
|
46
|
+
switch (pkg.name) {
|
47
|
+
case 'loader.js':
|
48
|
+
return 0;
|
49
|
+
case 'ember-source':
|
50
|
+
return 10;
|
51
|
+
default:
|
52
|
+
return 1000;
|
53
|
+
}
|
54
|
+
})) {
|
55
|
+
let implicitStyles = addon.meta['implicit-test-styles'];
|
56
|
+
if (implicitStyles) {
|
57
|
+
let options = { basedir: addon.root };
|
58
|
+
for (let mod of implicitStyles) {
|
59
|
+
result.push(resolve_1.default.sync(mod, options));
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
return result;
|
64
|
+
}
|
65
|
+
//# sourceMappingURL=virtual-test-support-styles.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"virtual-test-support-styles.js","sourceRoot":"","sources":["virtual-test-support-styles.ts"],"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iBAAY,EAAC,UAAU,CAAC,CAAC;QACtC,OAAO,GAAG,MAAM,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAW,CAAC;AACnC,CAAC;AAED,SAAS,6BAA6B,CAAC,MAAc;IACnD,IAAI,MAAM,GAAkB,EAAE,CAAC;IAC/B,KAAK,IAAI,KAAK,IAAI,IAAA,eAAM,EAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE;QAC/D,QAAQ,GAAG,CAAC,IAAI,EAAE;YAChB,KAAK,WAAW;gBACd,OAAO,CAAC,CAAC;YACX,KAAK,cAAc;gBACjB,OAAO,EAAE,CAAC;YACZ;gBACE,OAAO,IAAI,CAAC;SACf;IACH,CAAC,CAAC,EAAE;QACF,IAAI,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACxD,IAAI,cAAc,EAAE;YAClB,IAAI,OAAO,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;YACtC,KAAK,IAAI,GAAG,IAAI,cAAc,EAAE;gBAC9B,MAAM,CAAC,IAAI,CAAC,iBAAO,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;aACzC;SACF;KACF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { Package } from '@embroider/shared-internals';\nimport type { V2AddonPackage } from '@embroider/shared-internals/src/package';\nimport { readFileSync } from 'fs';\nimport { sortBy } from 'lodash';\nimport resolve from 'resolve';\nimport type { Engine } from './app-files';\nimport type { Resolver } from './module-resolver';\nimport type { VirtualContentResult } from './virtual-content';\n\nexport function decodeTestSupportStyles(filename: string): boolean {\n return filename.endsWith('-embroider-test-support-styles.css');\n}\n\nexport function renderTestSupportStyles(filename: string, resolver: Resolver): VirtualContentResult {\n const owner = resolver.packageCache.ownerOfFile(filename);\n if (!owner) {\n throw new Error(`Failed to find a valid owner for ${filename}`);\n }\n return { src: getTestSupportStyles(owner, resolver), watches: [] };\n}\n\nfunction getTestSupportStyles(owner: Package, resolver: Resolver): string {\n let engineConfig = resolver.owningEngine(owner);\n let engine: Engine = {\n package: owner,\n addons: new Map(\n engineConfig.activeAddons.map(addon => [\n resolver.packageCache.get(addon.root) as V2AddonPackage,\n addon.canResolveFromFile,\n ])\n ),\n isApp: true,\n modulePrefix: resolver.options.modulePrefix,\n appRelativePath: 'NOT_USED_DELETE_ME',\n };\n\n return generateTestSupportStyles(engine);\n}\n\nfunction generateTestSupportStyles(engine: Engine): string {\n let result: string[] = impliedAddonTestSupportStyles(engine).map((sourcePath: string): string => {\n let source = readFileSync(sourcePath);\n return `${source}`;\n });\n\n return result.join('') as string;\n}\n\nfunction impliedAddonTestSupportStyles(engine: Engine): string[] {\n let result: Array<string> = [];\n for (let addon of sortBy(Array.from(engine.addons.keys()), pkg => {\n switch (pkg.name) {\n case 'loader.js':\n return 0;\n case 'ember-source':\n return 10;\n default:\n return 1000;\n }\n })) {\n let implicitStyles = addon.meta['implicit-test-styles'];\n if (implicitStyles) {\n let options = { basedir: addon.root };\n for (let mod of implicitStyles) {\n result.push(resolve.sync(mod, options));\n }\n }\n }\n return result;\n}\n"]}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import type { Resolver } from './module-resolver';
|
2
|
+
import type { VirtualContentResult } from './virtual-content';
|
3
|
+
export declare function decodeImplicitTestScripts(filename: string): boolean;
|
4
|
+
export declare function renderImplicitTestScripts(filename: string, resolver: Resolver): VirtualContentResult;
|
@@ -0,0 +1,69 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.renderImplicitTestScripts = exports.decodeImplicitTestScripts = void 0;
|
7
|
+
const fs_1 = require("fs");
|
8
|
+
const resolve_1 = __importDefault(require("resolve"));
|
9
|
+
function decodeImplicitTestScripts(filename) {
|
10
|
+
return filename.endsWith('-embroider-test-support.js');
|
11
|
+
}
|
12
|
+
exports.decodeImplicitTestScripts = decodeImplicitTestScripts;
|
13
|
+
function renderImplicitTestScripts(filename, resolver) {
|
14
|
+
const owner = resolver.packageCache.ownerOfFile(filename);
|
15
|
+
if (!owner) {
|
16
|
+
throw new Error(`Failed to find a valid owner for ${filename}`);
|
17
|
+
}
|
18
|
+
return { src: getTestSupport(owner, resolver), watches: [] };
|
19
|
+
}
|
20
|
+
exports.renderImplicitTestScripts = renderImplicitTestScripts;
|
21
|
+
function getTestSupport(owner, resolver) {
|
22
|
+
let engineConfig = resolver.owningEngine(owner);
|
23
|
+
let engine = {
|
24
|
+
package: owner,
|
25
|
+
addons: new Map(engineConfig.activeAddons.map(addon => [
|
26
|
+
resolver.packageCache.get(addon.root),
|
27
|
+
addon.canResolveFromFile,
|
28
|
+
])),
|
29
|
+
isApp: true,
|
30
|
+
modulePrefix: resolver.options.modulePrefix,
|
31
|
+
appRelativePath: 'NOT_USED_DELETE_ME',
|
32
|
+
};
|
33
|
+
return generateTestSupport(engine);
|
34
|
+
}
|
35
|
+
function generateTestSupport(engine) {
|
36
|
+
// Add classic addons test-support
|
37
|
+
let result = impliedAddonTestSupport(engine);
|
38
|
+
let hasEmbroiderMacrosTestSupport = result.find(sourcePath => sourcePath.endsWith('embroider-macros-test-support.js'));
|
39
|
+
result = result.map((sourcePath) => {
|
40
|
+
let source = (0, fs_1.readFileSync)(sourcePath);
|
41
|
+
return `${source}`;
|
42
|
+
});
|
43
|
+
// Add _testing_suffix_.js
|
44
|
+
result.push(`
|
45
|
+
var runningTests=true;
|
46
|
+
if (typeof Testem !== 'undefined' && (typeof QUnit !== 'undefined' || typeof Mocha !== 'undefined')) {
|
47
|
+
Testem.hookIntoTestFramework();
|
48
|
+
}`);
|
49
|
+
// whether or not anybody was actually using @embroider/macros explicitly
|
50
|
+
// as an addon, we ensure its test-support file is always present.
|
51
|
+
if (!hasEmbroiderMacrosTestSupport) {
|
52
|
+
result.unshift(`${(0, fs_1.readFileSync)(require.resolve('@embroider/macros/src/vendor/embroider-macros-test-support'))}`);
|
53
|
+
}
|
54
|
+
return result.join('');
|
55
|
+
}
|
56
|
+
function impliedAddonTestSupport(engine) {
|
57
|
+
let result = [];
|
58
|
+
for (let addon of Array.from(engine.addons.keys())) {
|
59
|
+
let implicitScripts = addon.meta['implicit-test-scripts'];
|
60
|
+
if (implicitScripts) {
|
61
|
+
let options = { basedir: addon.root };
|
62
|
+
for (let mod of implicitScripts) {
|
63
|
+
result.push(resolve_1.default.sync(mod, options));
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
return result;
|
68
|
+
}
|
69
|
+
//# sourceMappingURL=virtual-test-support.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"virtual-test-support.js","sourceRoot":"","sources":["virtual-test-support.ts"],"names":[],"mappings":";;;;;;AAEA,2BAAkC;AAClC,sDAA8B;AAK9B,SAAgB,yBAAyB,CAAC,QAAgB;IACxD,OAAO,QAAQ,CAAC,QAAQ,CAAC,4BAA4B,CAAC,CAAC;AACzD,CAAC;AAFD,8DAEC;AAED,SAAgB,yBAAyB,CAAC,QAAgB,EAAE,QAAkB;IAC5E,MAAM,KAAK,GAAG,QAAQ,CAAC,YAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC1D,IAAI,CAAC,KAAK,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,oCAAoC,QAAQ,EAAE,CAAC,CAAC;KACjE;IACD,OAAO,EAAE,GAAG,EAAE,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAC/D,CAAC;AAND,8DAMC;AAED,SAAS,cAAc,CAAC,KAAc,EAAE,QAAkB;IACxD,IAAI,YAAY,GAAG,QAA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7C,IAAI,MAAM,GAAkB,EAAE,CAAC;IAC/B,KAAK,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE;QAClD,IAAI,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;QAC1D,IAAI,eAAe,EAAE;YACnB,IAAI,OAAO,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;YACtC,KAAK,IAAI,GAAG,IAAI,eAAe,EAAE;gBAC/B,MAAM,CAAC,IAAI,CAAC,iBAAO,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;aACzC;SACF;KACF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { Package } from '@embroider/shared-internals';\nimport type { V2AddonPackage } from '@embroider/shared-internals/src/package';\nimport { readFileSync } from 'fs';\nimport resolve from 'resolve';\nimport type { Engine } from './app-files';\nimport type { Resolver } from './module-resolver';\nimport type { VirtualContentResult } from './virtual-content';\n\nexport function decodeImplicitTestScripts(filename: string): boolean {\n return filename.endsWith('-embroider-test-support.js');\n}\n\nexport function renderImplicitTestScripts(filename: string, resolver: Resolver): VirtualContentResult {\n const owner = resolver.packageCache.ownerOfFile(filename);\n if (!owner) {\n throw new Error(`Failed to find a valid owner for ${filename}`);\n }\n return { src: getTestSupport(owner, resolver), watches: [] };\n}\n\nfunction getTestSupport(owner: Package, resolver: Resolver): string {\n let engineConfig = resolver.owningEngine(owner);\n let engine: Engine = {\n package: owner,\n addons: new Map(\n engineConfig.activeAddons.map(addon => [\n resolver.packageCache.get(addon.root) as V2AddonPackage,\n addon.canResolveFromFile,\n ])\n ),\n isApp: true,\n modulePrefix: resolver.options.modulePrefix,\n appRelativePath: 'NOT_USED_DELETE_ME',\n };\n\n return generateTestSupport(engine);\n}\n\nfunction generateTestSupport(engine: Engine): string {\n // Add classic addons test-support\n let result: string[] = impliedAddonTestSupport(engine);\n let hasEmbroiderMacrosTestSupport = result.find(sourcePath =>\n sourcePath.endsWith('embroider-macros-test-support.js')\n );\n result = result.map((sourcePath: string): string => {\n let source = readFileSync(sourcePath);\n return `${source}`;\n });\n\n // Add _testing_suffix_.js\n result.push(`\nvar runningTests=true;\nif (typeof Testem !== 'undefined' && (typeof QUnit !== 'undefined' || typeof Mocha !== 'undefined')) {\n Testem.hookIntoTestFramework();\n}`);\n\n // whether or not anybody was actually using @embroider/macros explicitly\n // as an addon, we ensure its test-support file is always present.\n if (!hasEmbroiderMacrosTestSupport) {\n result.unshift(`${readFileSync(require.resolve('@embroider/macros/src/vendor/embroider-macros-test-support'))}`);\n }\n\n return result.join('') as string;\n}\n\nfunction impliedAddonTestSupport(engine: Engine): string[] {\n let result: Array<string> = [];\n for (let addon of Array.from(engine.addons.keys())) {\n let implicitScripts = addon.meta['implicit-test-scripts'];\n if (implicitScripts) {\n let options = { basedir: addon.root };\n for (let mod of implicitScripts) {\n result.push(resolve.sync(mod, options));\n }\n }\n }\n return result;\n}\n"]}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import type { Resolver } from './module-resolver';
|
2
|
+
import type { VirtualContentResult } from './virtual-content';
|
3
|
+
export declare function decodeVirtualVendorStyles(filename: string): boolean;
|
4
|
+
export declare function renderVendorStyles(filename: string, resolver: Resolver): VirtualContentResult;
|
@@ -0,0 +1,72 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.renderVendorStyles = exports.decodeVirtualVendorStyles = void 0;
|
7
|
+
const fs_1 = require("fs");
|
8
|
+
const lodash_1 = require("lodash");
|
9
|
+
const resolve_1 = __importDefault(require("resolve"));
|
10
|
+
function decodeVirtualVendorStyles(filename) {
|
11
|
+
return filename.endsWith('-embroider-vendor-styles.css');
|
12
|
+
}
|
13
|
+
exports.decodeVirtualVendorStyles = decodeVirtualVendorStyles;
|
14
|
+
function renderVendorStyles(filename, resolver) {
|
15
|
+
const owner = resolver.packageCache.ownerOfFile(filename);
|
16
|
+
if (!owner) {
|
17
|
+
throw new Error(`Failed to find a valid owner for ${filename}`);
|
18
|
+
}
|
19
|
+
return { src: getVendorStyles(owner, resolver), watches: [] };
|
20
|
+
}
|
21
|
+
exports.renderVendorStyles = renderVendorStyles;
|
22
|
+
function getVendorStyles(owner, resolver) {
|
23
|
+
let engineConfig = resolver.owningEngine(owner);
|
24
|
+
let engine = {
|
25
|
+
package: owner,
|
26
|
+
addons: new Map(engineConfig.activeAddons.map(addon => [
|
27
|
+
resolver.packageCache.get(addon.root),
|
28
|
+
addon.canResolveFromFile,
|
29
|
+
])),
|
30
|
+
isApp: true,
|
31
|
+
modulePrefix: resolver.options.modulePrefix,
|
32
|
+
appRelativePath: 'NOT_USED_DELETE_ME',
|
33
|
+
};
|
34
|
+
return generateVendorStyles(engine);
|
35
|
+
}
|
36
|
+
function generateVendorStyles(engine) {
|
37
|
+
let result = impliedAddonVendorStyles(engine).map((sourcePath) => {
|
38
|
+
let source = (0, fs_1.readFileSync)(sourcePath);
|
39
|
+
return `${source}`;
|
40
|
+
});
|
41
|
+
return result.join('');
|
42
|
+
}
|
43
|
+
function impliedAddonVendorStyles(engine) {
|
44
|
+
let result = [];
|
45
|
+
for (let addon of (0, lodash_1.sortBy)(Array.from(engine.addons.keys()), pkg => {
|
46
|
+
switch (pkg.name) {
|
47
|
+
case 'loader.js':
|
48
|
+
return 0;
|
49
|
+
case 'ember-source':
|
50
|
+
return 10;
|
51
|
+
default:
|
52
|
+
return 1000;
|
53
|
+
}
|
54
|
+
})) {
|
55
|
+
let implicitStyles = addon.meta['implicit-styles'];
|
56
|
+
if (implicitStyles) {
|
57
|
+
let styles = [];
|
58
|
+
let options = { basedir: addon.root };
|
59
|
+
for (let mod of implicitStyles) {
|
60
|
+
// exclude engines because they will handle their own css importation
|
61
|
+
if (!addon.isLazyEngine()) {
|
62
|
+
styles.push(resolve_1.default.sync(mod, options));
|
63
|
+
}
|
64
|
+
}
|
65
|
+
if (styles.length) {
|
66
|
+
result = [...styles, ...result];
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
return result;
|
71
|
+
}
|
72
|
+
//# sourceMappingURL=virtual-vendor-styles.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"virtual-vendor-styles.js","sourceRoot":"","sources":["virtual-vendor-styles.ts"],"names":[],"mappings":";;;;;;AAEA,2BAAkC;AAClC,mCAAgC;AAChC,sDAA8B;AAK9B,SAAgB,yBAAyB,CAAC,QAAgB;IACxD,OAAO,QAAQ,CAAC,QAAQ,CAAC,8BAA8B,CAAC,CAAC;AAC3D,CAAC;AAFD,8DAEC;AAED,SAAgB,kBAAkB,CAAC,QAAgB,EAAE,QAAkB;IACrE,MAAM,KAAK,GAAG,QAAQ,CAAC,YAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC1D,IAAI,CAAC,KAAK,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,oCAAoC,QAAQ,EAAE,CAAC,CAAC;KACjE;IACD,OAAO,EAAE,GAAG,EAAE,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AAChE,CAAC;AAND,gDAMC;AAED,SAAS,eAAe,CAAC,KAAc,EAAE,QAAkB;IACzD,IAAI,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAChD,IAAI,MAAM,GAAW;QACnB,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,IAAI,GAAG,CACb,YAAY,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACrC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAmB;YACvD,KAAK,CAAC,kBAAkB;SACzB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AC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;iBACzC;aACF;YACD,IAAI,MAAM,CAAC,MAAM,EAAE;gBACjB,MAAM,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC;aACjC;SACF;KACF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { Package } from '@embroider/shared-internals';\nimport type { V2AddonPackage } from '@embroider/shared-internals/src/package';\nimport { readFileSync } from 'fs';\nimport { sortBy } from 'lodash';\nimport resolve from 'resolve';\nimport type { Resolver } from './module-resolver';\nimport type { VirtualContentResult } from './virtual-content';\nimport type { Engine } from './app-files';\n\nexport function decodeVirtualVendorStyles(filename: string): boolean {\n return filename.endsWith('-embroider-vendor-styles.css');\n}\n\nexport function renderVendorStyles(filename: string, resolver: Resolver): VirtualContentResult {\n const owner = resolver.packageCache.ownerOfFile(filename);\n if (!owner) {\n throw new Error(`Failed to find a valid owner for ${filename}`);\n }\n return { src: getVendorStyles(owner, resolver), watches: [] };\n}\n\nfunction getVendorStyles(owner: Package, resolver: Resolver): string {\n let engineConfig = resolver.owningEngine(owner);\n let engine: Engine = {\n package: owner,\n addons: new Map(\n engineConfig.activeAddons.map(addon => [\n resolver.packageCache.get(addon.root) as V2AddonPackage,\n addon.canResolveFromFile,\n ])\n ),\n isApp: true,\n modulePrefix: resolver.options.modulePrefix,\n appRelativePath: 'NOT_USED_DELETE_ME',\n };\n\n return generateVendorStyles(engine);\n}\n\nfunction generateVendorStyles(engine: Engine): string {\n let result: string[] = impliedAddonVendorStyles(engine).map((sourcePath: string): string => {\n let source = readFileSync(sourcePath);\n return `${source}`;\n });\n\n return result.join('') as string;\n}\n\nfunction impliedAddonVendorStyles(engine: Engine): string[] {\n let result: Array<string> = [];\n for (let addon of sortBy(Array.from(engine.addons.keys()), pkg => {\n switch (pkg.name) {\n case 'loader.js':\n return 0;\n case 'ember-source':\n return 10;\n default:\n return 1000;\n }\n })) {\n let implicitStyles = addon.meta['implicit-styles'];\n if (implicitStyles) {\n let styles = [];\n let options = { basedir: addon.root };\n for (let mod of implicitStyles) {\n // exclude engines because they will handle their own css importation\n if (!addon.isLazyEngine()) {\n styles.push(resolve.sync(mod, options));\n }\n }\n if (styles.length) {\n result = [...styles, ...result];\n }\n }\n }\n return result;\n}\n"]}
|
package/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2018 Edward Faulkner
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|