@embroider/core 3.4.10-unstable.706d56f → 3.4.10-unstable.d7336b2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embroider/core",
3
- "version": "3.4.10-unstable.706d56f",
3
+ "version": "3.4.10-unstable.d7336b2",
4
4
  "private": false,
5
5
  "description": "A build system for EmberJS applications.",
6
6
  "repository": {
@@ -23,8 +23,8 @@
23
23
  "@babel/core": "^7.14.5",
24
24
  "@babel/parser": "^7.14.5",
25
25
  "@babel/traverse": "^7.14.5",
26
- "@embroider/macros": "1.16.2-unstable.706d56f",
27
- "@embroider/shared-internals": "2.6.1-unstable.706d56f",
26
+ "@embroider/macros": "1.16.2-unstable.d7336b2",
27
+ "@embroider/shared-internals": "2.6.1-unstable.d7336b2",
28
28
  "assert-never": "^1.2.1",
29
29
  "babel-plugin-ember-template-compilation": "^2.1.1",
30
30
  "broccoli-node-api": "^1.7.0",
@@ -43,7 +43,7 @@
43
43
  "resolve": "^1.20.0",
44
44
  "resolve-package-path": "^4.0.1",
45
45
  "resolve.exports": "^2.0.2",
46
- "@embroider/reverse-exports": "0.1.1-unstable.706d56f",
46
+ "@embroider/reverse-exports": "0.1.1-unstable.d7336b2",
47
47
  "typescript-memoize": "^1.0.1",
48
48
  "walk-sync": "^3.0.0"
49
49
  },
@@ -6,15 +6,13 @@ export interface EmberHTML {
6
6
  javascript: Node;
7
7
  styles: Node;
8
8
  implicitScripts: Node;
9
- implicitStyles: Node;
10
9
  testJavascript?: Node;
11
- implicitTestScripts?: Node;
12
- implicitTestStyles?: Node;
13
10
  }
14
11
  declare class Placeholder {
15
12
  readonly start: Node;
16
13
  readonly end: Node;
17
14
  readonly reference: Node;
15
+ static find(node: Node): Placeholder;
18
16
  static replacing(node: Node): Placeholder;
19
17
  static immediatelyAfter(node: Node): Placeholder;
20
18
  readonly parent: HTMLElement;
@@ -28,10 +26,7 @@ export declare class PreparedEmberHTML {
28
26
  javascript: Placeholder;
29
27
  styles: Placeholder;
30
28
  implicitScripts: Placeholder;
31
- implicitStyles: Placeholder;
32
29
  testJavascript: Placeholder;
33
- implicitTestScripts: Placeholder;
34
- implicitTestStyles: Placeholder;
35
30
  constructor(asset: EmberAsset);
36
31
  private placeholders;
37
32
  clear(): void;
package/src/ember-html.js CHANGED
@@ -5,6 +5,10 @@ const jsdom_1 = require("jsdom");
5
5
  const fs_1 = require("fs");
6
6
  const html_placeholder_1 = require("./html-placeholder");
7
7
  class Placeholder {
8
+ static find(node) {
9
+ let placeholder = this.immediatelyAfter(node);
10
+ return placeholder;
11
+ }
8
12
  static replacing(node) {
9
13
  let placeholder = this.immediatelyAfter(node);
10
14
  node.parentElement.removeChild(node);
@@ -51,28 +55,13 @@ class PreparedEmberHTML {
51
55
  let html = asset.prepare(this.dom);
52
56
  this.javascript = Placeholder.replacing(html.javascript);
53
57
  this.styles = Placeholder.replacing(html.styles);
54
- this.implicitScripts = Placeholder.replacing(html.implicitScripts);
55
- this.implicitStyles = Placeholder.replacing(html.implicitStyles);
58
+ this.implicitScripts = Placeholder.find(html.implicitScripts);
56
59
  this.testJavascript = html.testJavascript
57
60
  ? Placeholder.replacing(html.testJavascript)
58
61
  : Placeholder.immediatelyAfter(this.javascript.end);
59
- this.implicitTestScripts = html.implicitTestScripts
60
- ? Placeholder.replacing(html.implicitTestScripts)
61
- : Placeholder.immediatelyAfter(this.implicitScripts.end);
62
- this.implicitTestStyles = html.implicitTestStyles
63
- ? Placeholder.replacing(html.implicitTestStyles)
64
- : Placeholder.immediatelyAfter(this.implicitStyles.end);
65
62
  }
66
63
  placeholders() {
67
- return [
68
- this.javascript,
69
- this.styles,
70
- this.implicitScripts,
71
- this.implicitStyles,
72
- this.implicitTestScripts,
73
- this.implicitTestStyles,
74
- this.testJavascript,
75
- ];
64
+ return [this.javascript, this.styles, this.implicitScripts, this.testJavascript];
76
65
  }
77
66
  clear() {
78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,EAAQ;IACpC,EAAE,CAAC,aAAc,CAAC,YAAY,CAAC,EAAE,CAAC,aAAc,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;AAC7E,CAAC;AAFD,sCAEC","sourcesContent":["import { JSDOM } from 'jsdom';\nimport { readFileSync } from 'fs';\nimport type { EmberAsset } from './asset';\nimport { makeTag, normalizeStyleLink } from './html-placeholder';\n\nexport interface EmberHTML {\n // each of the Nodes in here points at where we should insert the\n // corresponding parts of the ember app. The Nodes themselves will be\n // replaced, so provide placeholders.\n\n // these are mandatory, the Ember app may need to put things into them.\n javascript: Node;\n styles: Node;\n implicitScripts: Node;\n implicitStyles: Node;\n\n // these are optional because you *may* choose to stick your implicit test\n // things into specific locations (which we need for backward-compat). But you\n // can leave these off and we will simply put them in the same places as the\n // non-test things.\n //\n // Do not confuse these with controlling whether or not we will insert tests.\n // That is separately controlled via `includeTests`.\n testJavascript?: Node;\n implicitTestScripts?: Node;\n implicitTestStyles?: Node;\n}\n\nclass Placeholder {\n static replacing(node: Node): Placeholder {\n let placeholder = this.immediatelyAfter(node);\n node.parentElement!.removeChild(node);\n return placeholder;\n }\n\n static immediatelyAfter(node: Node): Placeholder {\n let document = node.ownerDocument;\n let parent = node.parentElement;\n\n if (!document || !parent) {\n throw new Error('Cannot make Placeholder out of detached node');\n }\n\n let nextSibling = node.nextSibling;\n let start = document.createTextNode('');\n let end = document.createTextNode('');\n\n parent.insertBefore(start, nextSibling);\n parent.insertBefore(end, nextSibling);\n return new Placeholder(start, end, node);\n }\n\n readonly parent: HTMLElement;\n\n constructor(readonly start: Node, readonly end: Node, readonly reference: Node) {\n if (start.parentElement && start.parentElement === end.parentElement) {\n this.parent = start.parentElement;\n } else {\n throw new Error('Cannot make Placeholder out of detached node');\n }\n }\n\n clear() {\n let { start, end, parent } = this;\n while (start.nextSibling && start.nextSibling !== end) {\n parent.removeChild(start.nextSibling);\n }\n }\n\n insert(node: Node) {\n this.parent.insertBefore(node, this.end);\n }\n}\n\nexport class PreparedEmberHTML {\n dom: JSDOM;\n javascript: Placeholder;\n styles: Placeholder;\n implicitScripts: Placeholder;\n implicitStyles: Placeholder;\n testJavascript: Placeholder;\n implicitTestScripts: Placeholder;\n implicitTestStyles: Placeholder;\n\n constructor(private asset: EmberAsset) {\n this.dom = new JSDOM(readFileSync(asset.sourcePath, 'utf8'));\n let html = asset.prepare(this.dom);\n this.javascript = Placeholder.replacing(html.javascript);\n this.styles = Placeholder.replacing(html.styles);\n this.implicitScripts = Placeholder.replacing(html.implicitScripts);\n this.implicitStyles = Placeholder.replacing(html.implicitStyles);\n this.testJavascript = html.testJavascript\n ? Placeholder.replacing(html.testJavascript)\n : Placeholder.immediatelyAfter(this.javascript.end);\n this.implicitTestScripts = html.implicitTestScripts\n ? Placeholder.replacing(html.implicitTestScripts)\n : Placeholder.immediatelyAfter(this.implicitScripts.end);\n this.implicitTestStyles = html.implicitTestStyles\n ? Placeholder.replacing(html.implicitTestStyles)\n : Placeholder.immediatelyAfter(this.implicitStyles.end);\n }\n\n private placeholders(): Placeholder[] {\n return [\n this.javascript,\n this.styles,\n this.implicitScripts,\n this.implicitStyles,\n this.implicitTestScripts,\n this.implicitTestStyles,\n this.testJavascript,\n ];\n }\n\n clear() {\n for (let range of this.placeholders()) {\n range.clear();\n }\n }\n\n // this takes the src relative to the application root, we adjust it so it's\n // root-relative via the configured rootURL\n insertScriptTag(\n placeholder: Placeholder,\n relativeSrc: string,\n { type, tag = 'script' }: { type?: string; tag?: string } = {}\n ) {\n let document = this.dom.window.document;\n let from = placeholder.reference.nodeType === 1 ? (placeholder.reference as HTMLElement) : undefined;\n let src = this.asset.rootURL + relativeSrc;\n let attributes: Record<string, string> = type ? { src, type } : { src };\n let newTag = makeTag(document, { from, tag, attributes });\n placeholder.insert(this.dom.window.document.createTextNode('\\n'));\n placeholder.insert(newTag);\n }\n\n // this takes the href relative to the application root, we adjust it so it's\n // root-relative via the configured rootURL\n insertStyleLink(placeholder: Placeholder, relativeHref: string) {\n let document = this.dom.window.document;\n let from = placeholder.reference.nodeType === 1 ? (placeholder.reference as HTMLElement) : undefined;\n let href = this.asset.rootURL + relativeHref;\n let newTag = makeTag(document, { from, tag: 'link', attributes: { href } });\n normalizeStyleLink(newTag);\n placeholder.insert(this.dom.window.document.createTextNode('\\n'));\n placeholder.insert(newTag);\n }\n}\n\nexport function insertNewline(at: Node) {\n at.parentElement!.insertBefore(at.ownerDocument!.createTextNode('\\n'), at);\n}\n"]}
1
+ {"version":3,"file":"ember-html.js","sourceRoot":"","sources":["ember-html.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAC9B,2BAAkC;AAElC,yDAAiE;AAsBjE,MAAM,WAAW;IACf,MAAM,CAAC,IAAI,CAAC,IAAU;QACpB,IAAI,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC9C,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,IAAU;QACzB,IAAI,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,CAAC,aAAc,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACtC,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,IAAU;QAChC,IAAI,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC;QAClC,IAAI,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC;QAEhC,IAAI,CAAC,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAClE,CAAC;QAED,IAAI,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACnC,IAAI,KAAK,GAAG,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;QACxC,IAAI,GAAG,GAAG,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;QAEtC,MAAM,CAA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OM } from 'jsdom';\nimport { readFileSync } from 'fs';\nimport type { EmberAsset } from './asset';\nimport { makeTag, normalizeStyleLink } from './html-placeholder';\n\nexport interface EmberHTML {\n // each of the Nodes in here points at where we should insert the\n // corresponding parts of the ember app. The Nodes themselves will be\n // replaced, so provide placeholders.\n\n // these are mandatory, the Ember app may need to put things into them.\n javascript: Node;\n styles: Node;\n implicitScripts: Node;\n\n // these are optional because you *may* choose to stick your implicit test\n // things into specific locations (which we need for backward-compat). But you\n // can leave these off and we will simply put them in the same places as the\n // non-test things.\n //\n // Do not confuse these with controlling whether or not we will insert tests.\n // That is separately controlled via `includeTests`.\n testJavascript?: Node;\n}\n\nclass Placeholder {\n static find(node: Node): Placeholder {\n let placeholder = this.immediatelyAfter(node);\n return placeholder;\n }\n\n static replacing(node: Node): Placeholder {\n let placeholder = this.immediatelyAfter(node);\n node.parentElement!.removeChild(node);\n return placeholder;\n }\n\n static immediatelyAfter(node: Node): Placeholder {\n let document = node.ownerDocument;\n let parent = node.parentElement;\n\n if (!document || !parent) {\n throw new Error('Cannot make Placeholder out of detached node');\n }\n\n let nextSibling = node.nextSibling;\n let start = document.createTextNode('');\n let end = document.createTextNode('');\n\n parent.insertBefore(start, nextSibling);\n parent.insertBefore(end, nextSibling);\n return new Placeholder(start, end, node);\n }\n\n readonly parent: HTMLElement;\n\n constructor(readonly start: Node, readonly end: Node, readonly reference: Node) {\n if (start.parentElement && start.parentElement === end.parentElement) {\n this.parent = start.parentElement;\n } else {\n throw new Error('Cannot make Placeholder out of detached node');\n }\n }\n\n clear() {\n let { start, end, parent } = this;\n while (start.nextSibling && start.nextSibling !== end) {\n parent.removeChild(start.nextSibling);\n }\n }\n\n insert(node: Node) {\n this.parent.insertBefore(node, this.end);\n }\n}\n\nexport class PreparedEmberHTML {\n dom: JSDOM;\n javascript: Placeholder;\n styles: Placeholder;\n implicitScripts: Placeholder;\n testJavascript: Placeholder;\n\n constructor(private asset: EmberAsset) {\n this.dom = new JSDOM(readFileSync(asset.sourcePath, 'utf8'));\n let html = asset.prepare(this.dom);\n this.javascript = Placeholder.replacing(html.javascript);\n this.styles = Placeholder.replacing(html.styles);\n this.implicitScripts = Placeholder.find(html.implicitScripts);\n this.testJavascript = html.testJavascript\n ? Placeholder.replacing(html.testJavascript)\n : Placeholder.immediatelyAfter(this.javascript.end);\n }\n\n private placeholders(): Placeholder[] {\n return [this.javascript, this.styles, this.implicitScripts, this.testJavascript];\n }\n\n clear() {\n for (let range of this.placeholders()) {\n range.clear();\n }\n }\n\n // this takes the src relative to the application root, we adjust it so it's\n // root-relative via the configured rootURL\n insertScriptTag(\n placeholder: Placeholder,\n relativeSrc: string,\n { type, tag = 'script' }: { type?: string; tag?: string } = {}\n ) {\n let document = this.dom.window.document;\n let from = placeholder.reference.nodeType === 1 ? (placeholder.reference as HTMLElement) : undefined;\n let src = this.asset.rootURL + relativeSrc;\n let attributes: Record<string, string> = type ? { src, type } : { src };\n let newTag = makeTag(document, { from, tag, attributes });\n placeholder.insert(this.dom.window.document.createTextNode('\\n'));\n placeholder.insert(newTag);\n }\n\n // this takes the href relative to the application root, we adjust it so it's\n // root-relative via the configured rootURL\n insertStyleLink(placeholder: Placeholder, relativeHref: string) {\n let document = this.dom.window.document;\n let from = placeholder.reference.nodeType === 1 ? (placeholder.reference as HTMLElement) : undefined;\n let href = this.asset.rootURL + relativeHref;\n let newTag = makeTag(document, { from, tag: 'link', attributes: { href } });\n normalizeStyleLink(newTag);\n placeholder.insert(this.dom.window.document.createTextNode('\\n'));\n placeholder.insert(newTag);\n }\n}\n\nexport function insertNewline(at: Node) {\n at.parentElement!.insertBefore(at.ownerDocument!.createTextNode('\\n'), at);\n}\n"]}