ember-repl 3.0.0-beta.4 → 3.0.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/declarations/browser/__PRIVATE__.d.ts +2 -0
  2. package/declarations/browser/__PRIVATE__.d.ts.map +1 -0
  3. package/declarations/browser/cjs/eval.d.ts +9 -0
  4. package/declarations/browser/cjs/eval.d.ts.map +1 -0
  5. package/declarations/browser/cjs/index.d.ts +7 -0
  6. package/declarations/browser/cjs/index.d.ts.map +1 -0
  7. package/declarations/browser/compile/formats.d.ts +18 -0
  8. package/declarations/browser/compile/formats.d.ts.map +1 -0
  9. package/declarations/browser/compile/index.d.ts +76 -0
  10. package/declarations/browser/compile/index.d.ts.map +1 -0
  11. package/declarations/browser/compile/markdown-to-ember.d.ts +21 -0
  12. package/declarations/browser/compile/markdown-to-ember.d.ts.map +1 -0
  13. package/declarations/browser/compile/types.d.ts +9 -0
  14. package/declarations/browser/compile/types.d.ts.map +1 -0
  15. package/declarations/browser/esm/index.d.ts +8 -0
  16. package/declarations/browser/esm/index.d.ts.map +1 -0
  17. package/{dist → declarations}/browser/eti/babel-plugin.d.ts +2 -2
  18. package/declarations/browser/eti/babel-plugin.d.ts.map +1 -0
  19. package/declarations/browser/eti/debug.d.ts +2 -0
  20. package/declarations/browser/eti/debug.d.ts.map +1 -0
  21. package/{dist → declarations}/browser/eti/parse-templates.d.ts +7 -7
  22. package/declarations/browser/eti/parse-templates.d.ts.map +1 -0
  23. package/{dist → declarations}/browser/eti/preprocess.d.ts +3 -2
  24. package/declarations/browser/eti/preprocess.d.ts.map +1 -0
  25. package/{dist → declarations}/browser/eti/template-tag-transform.d.ts +2 -2
  26. package/declarations/browser/eti/template-tag-transform.d.ts.map +1 -0
  27. package/declarations/browser/eti/util.d.ts +14 -0
  28. package/declarations/browser/eti/util.d.ts.map +1 -0
  29. package/declarations/browser/gjs.d.ts +4 -0
  30. package/declarations/browser/gjs.d.ts.map +1 -0
  31. package/{dist → declarations}/browser/hbs.d.ts +4 -3
  32. package/declarations/browser/hbs.d.ts.map +1 -0
  33. package/declarations/browser/index.d.ts +7 -0
  34. package/declarations/browser/index.d.ts.map +1 -0
  35. package/{dist → declarations}/browser/js.d.ts +3 -3
  36. package/declarations/browser/js.d.ts.map +1 -0
  37. package/{dist → declarations}/browser/known-modules.d.ts +6 -5
  38. package/declarations/browser/known-modules.d.ts.map +1 -0
  39. package/declarations/browser/types.d.ts +21 -0
  40. package/declarations/browser/types.d.ts.map +1 -0
  41. package/{dist → declarations}/browser/utils.d.ts +4 -4
  42. package/declarations/browser/utils.d.ts.map +1 -0
  43. package/declarations/test-support/index.d.ts +2 -0
  44. package/declarations/test-support/index.d.ts.map +1 -0
  45. package/dist/browser/__PRIVATE__.js +2 -0
  46. package/dist/browser/__PRIVATE__.js.map +1 -0
  47. package/dist/browser/cjs/eval.js.map +1 -1
  48. package/dist/browser/cjs/index.js.map +1 -1
  49. package/dist/browser/compile/formats.js +2 -1
  50. package/dist/browser/compile/formats.js.map +1 -1
  51. package/dist/browser/compile/index.js +28 -14
  52. package/dist/browser/compile/index.js.map +1 -1
  53. package/dist/browser/compile/markdown-to-ember.js +28 -10
  54. package/dist/browser/compile/markdown-to-ember.js.map +1 -1
  55. package/dist/browser/compile/types.js +1 -1
  56. package/dist/browser/esm/index.js.map +1 -1
  57. package/dist/browser/eti/babel-plugin.js.map +1 -1
  58. package/dist/browser/eti/parse-templates.js.map +1 -1
  59. package/dist/browser/eti/preprocess.js +2 -167
  60. package/dist/browser/eti/preprocess.js.map +1 -1
  61. package/dist/browser/eti/template-tag-transform.js.map +1 -1
  62. package/dist/browser/eti/util.js.map +1 -1
  63. package/dist/browser/gjs.js.map +1 -1
  64. package/dist/browser/hbs.js.map +1 -1
  65. package/dist/browser/js.js.map +1 -1
  66. package/dist/test-support/index.js.map +1 -1
  67. package/package.json +82 -58
  68. package/src/browser/__PRIVATE__.ts +1 -0
  69. package/src/browser/cjs/eval.ts +2 -2
  70. package/src/browser/cjs/index.ts +4 -4
  71. package/src/browser/compile/formats.ts +17 -11
  72. package/src/browser/compile/index.ts +64 -30
  73. package/src/browser/compile/markdown-to-ember.ts +96 -81
  74. package/src/browser/compile/types.ts +4 -0
  75. package/src/browser/esm/index.ts +4 -4
  76. package/src/browser/eti/babel-plugin.ts +2 -2
  77. package/src/browser/eti/parse-templates.ts +2 -2
  78. package/src/browser/eti/preprocess.ts +3 -3
  79. package/src/browser/eti/template-tag-transform.ts +1 -1
  80. package/src/browser/eti/util.ts +1 -1
  81. package/src/browser/gjs.ts +4 -4
  82. package/src/browser/hbs.ts +2 -2
  83. package/src/browser/index.ts +5 -5
  84. package/src/browser/js.ts +3 -3
  85. package/src/test-support/index.ts +1 -1
  86. package/dist/browser/cjs/eval.d.ts +0 -10
  87. package/dist/browser/cjs/eval.d.ts.map +0 -1
  88. package/dist/browser/cjs/index.d.ts +0 -7
  89. package/dist/browser/compile/formats.d.ts +0 -16
  90. package/dist/browser/compile/index.d.ts +0 -51
  91. package/dist/browser/compile/markdown-to-ember.d.ts +0 -18
  92. package/dist/browser/compile/types.d.ts +0 -7
  93. package/dist/browser/esm/index.d.ts +0 -8
  94. package/dist/browser/eti/debug.d.ts +0 -2
  95. package/dist/browser/eti/util.d.ts +0 -14
  96. package/dist/browser/gjs.d.ts +0 -4
  97. package/dist/browser/index.d.ts +0 -6
  98. package/dist/browser/types.d.ts +0 -21
  99. package/dist/test-support/index.d.ts +0 -2
@@ -1 +1 @@
1
- {"version":3,"file":"preprocess.js","sources":["../../../../../../node_modules/.pnpm/isarray@1.0.0/node_modules/isarray/index.js","../../../../../../node_modules/.pnpm/isobject@2.1.0/node_modules/isobject/index.js","../../../../../../node_modules/.pnpm/line-column@1.0.2/node_modules/line-column/lib/line-column.js","../../../src/browser/eti/preprocess.ts"],"sourcesContent":["var toString = {}.toString;\n\nmodule.exports = Array.isArray || function (arr) {\n return toString.call(arr) == '[object Array]';\n};\n","/*!\n * isobject <https://github.com/jonschlinkert/isobject>\n *\n * Copyright (c) 2014-2015, Jon Schlinkert.\n * Licensed under the MIT License.\n */\n\n'use strict';\n\nvar isArray = require('isarray');\n\nmodule.exports = function isObject(val) {\n return val != null && typeof val === 'object' && isArray(val) === false;\n};\n","/**\n * line-column - Convert efficiently index to/from line-column in a string\n * @module lineColumn\n * @license MIT\n */\n\"use strict\";\n\nvar isArray = require(\"isarray\");\nvar isObject = require(\"isobject\");\nvar slice = Array.prototype.slice;\n\nmodule.exports = LineColumnFinder;\n\n/**\n * Finder for index and line-column from given string.\n *\n * You can call this without `new` operator as it returns an instance anyway.\n *\n * @class\n * @param {string} str - A string to be parsed.\n * @param {Object|number} [options] - Options.\n * This can be an index in the string for shorthand of `lineColumn(str, index)`.\n * @param {number} [options.origin=1] - The origin value of line and column.\n */\nfunction LineColumnFinder(str, options) {\n if (!(this instanceof LineColumnFinder)) {\n if (typeof options === \"number\") {\n return (new LineColumnFinder(str)).fromIndex(options);\n }\n return new LineColumnFinder(str, options);\n }\n\n this.str = str || \"\";\n this.lineToIndex = buildLineToIndex(this.str);\n\n options = options || {};\n this.origin = typeof options.origin === \"undefined\" ? 1 : options.origin;\n}\n\n/**\n * Find line and column from index in the string.\n *\n * @param {number} index - Index in the string. (0-origin)\n * @return {Object|null}\n * Found line number and column number in object `{ line: X, col: Y }`.\n * If the given index is out of range, it returns `null`.\n */\nLineColumnFinder.prototype.fromIndex = function (index) {\n if (index < 0 || index >= this.str.length || isNaN(index)) {\n return null;\n }\n\n var line = findLowerIndexInRangeArray(index, this.lineToIndex);\n return {\n line: line + this.origin,\n col: index - this.lineToIndex[line] + this.origin\n };\n}\n\n/**\n * Find index from line and column in the string.\n *\n * @param {number|Object|Array} line - Line number in the string.\n * This can be an Object of `{ line: X, col: Y }`, or\n * an Array of `[line, col]`.\n * @param {number} [column] - Column number in the string.\n * This must be omitted or undefined when Object or Array is given\n * to the first argument.\n * @return {number}\n * Found index in the string. (always 0-origin)\n * If the given line or column is out of range, it returns `-1`.\n */\nLineColumnFinder.prototype.toIndex = function (line, column) {\n if (typeof column === \"undefined\") {\n if (isArray(line) && line.length >= 2) {\n return this.toIndex(line[0], line[1]);\n }\n if (isObject(line) && \"line\" in line && (\"col\" in line || \"column\" in line)) {\n return this.toIndex(line.line, (\"col\" in line ? line.col : line.column));\n }\n return -1;\n }\n if (isNaN(line) || isNaN(column)) {\n return -1;\n }\n\n line -= this.origin;\n column -= this.origin;\n\n if (line >= 0 && column >= 0 && line < this.lineToIndex.length) {\n var lineIndex = this.lineToIndex[line];\n var nextIndex = (\n line === this.lineToIndex.length - 1\n ? this.str.length\n : this.lineToIndex[line + 1]\n );\n\n if (column < nextIndex - lineIndex) {\n return lineIndex + column;\n }\n }\n return -1;\n}\n\n/**\n * Build an array of indexes of each line from a string.\n *\n * @private\n * @param str {string} An input string.\n * @return {number[]} Built array of indexes. The key is line number.\n */\nfunction buildLineToIndex(str) {\n var lines = str.split(\"\\n\"),\n lineToIndex = new Array(lines.length),\n index = 0;\n\n for (var i = 0, l = lines.length; i < l; i++) {\n lineToIndex[i] = index;\n index += lines[i].length + /* \"\\n\".length */ 1;\n }\n return lineToIndex;\n}\n\n/**\n * Find a lower-bound index of a value in a sorted array of ranges.\n *\n * Assume `arr = [0, 5, 10, 15, 20]` and\n * this returns `1` for `value = 7` (5 <= value < 10),\n * and returns `3` for `value = 18` (15 <= value < 20).\n *\n * @private\n * @param arr {number[]} An array of values representing ranges.\n * @param value {number} A value to be searched.\n * @return {number} Found index. If not found `-1`.\n */\nfunction findLowerIndexInRangeArray(value, arr) {\n if (value >= arr[arr.length - 1]) {\n return arr.length - 1;\n }\n\n var min = 0, max = arr.length - 2, mid;\n while (min < max) {\n mid = min + ((max - min) >> 1);\n\n if (value < arr[mid]) {\n max = mid - 1;\n } else if (value >= arr[mid + 1]) {\n min = mid + 1;\n } else { // value >= arr[mid] && value < arr[mid + 1]\n min = mid;\n break;\n }\n }\n return min;\n}\n","// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { getTemplateLocals } from '@glimmer/syntax';\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport lineColumn from 'line-column';\nimport MagicString from 'magic-string';\n\nimport { expect } from './debug';\nimport { parseTemplates } from './parse-templates';\n\nimport type { ParseTemplatesOptions, TemplateMatch } from './parse-templates';\n\ninterface PreprocessOptionsEager {\n importIdentifier?: string;\n importPath?: string;\n templateTag?: string;\n templateTagReplacement?: string;\n\n relativePath: string;\n includeSourceMaps: boolean;\n includeTemplateTokens: boolean;\n}\n\ninterface PreprocessOptionsLazy {\n importIdentifier?: string;\n importPath?: string;\n templateTag?: string;\n templateTagReplacement?: string;\n\n relativePath: string;\n includeSourceMaps: boolean;\n includeTemplateTokens: boolean;\n}\n\ntype PreprocessOptions = PreprocessOptionsLazy | PreprocessOptionsEager;\n\ninterface PreprocessedOutput {\n output: string;\n replacements: Replacement[];\n}\n\ninterface Replacement {\n type: 'start' | 'end';\n index: number;\n oldLength: number;\n newLength: number;\n originalLine: number;\n originalCol: number;\n}\n\nfunction getMatchStartAndEnd(match: RegExpMatchArray) {\n return {\n start: expect(match.index, 'Expected regular expression match to have an index'),\n end:\n expect(match.index, 'Expected regular expression match to have an index') + match[0].length,\n };\n}\n\nfunction replacementFrom(\n template: string,\n index: number,\n oldLength: number,\n newLength: number,\n type: 'start' | 'end'\n): Replacement {\n const loc = expect(\n lineColumn(template).fromIndex(index),\n 'BUG: expected to find a line/column based on index'\n );\n\n return {\n type,\n index,\n oldLength,\n newLength,\n originalCol: loc.col,\n originalLine: loc.line,\n };\n}\n\nfunction replaceMatch(\n s: MagicString,\n match: TemplateMatch,\n startReplacement: string,\n endReplacement: string,\n template: string,\n includeTemplateTokens: boolean\n): Replacement[] {\n const { start: openStart, end: openEnd } = getMatchStartAndEnd(match.start);\n const { start: closeStart, end: closeEnd } = getMatchStartAndEnd(match.end);\n\n let options = '';\n\n if (includeTemplateTokens) {\n const tokensString = getTemplateLocals(template.slice(openEnd, closeStart))\n .filter((local: string) => local.match(/^[$A-Z_][0-9A-Z_$]*$/i))\n .join(',');\n\n if (tokensString.length > 0) {\n options = `, scope: () => ({${tokensString}})`;\n }\n }\n\n const newStart = `${startReplacement}\\``;\n const newEnd = `\\`, { strictMode: true${options} }${endReplacement}`;\n\n s.overwrite(openStart, openEnd, newStart);\n s.overwrite(closeStart, closeEnd, newEnd);\n ensureBackticksEscaped(s, openEnd + 1, closeStart - 1);\n\n return [\n replacementFrom(template, openStart, openEnd - openStart, newStart.length, 'start'),\n replacementFrom(template, closeStart, closeEnd - closeStart, newEnd.length, 'end'),\n ];\n}\n\n/**\n * Preprocesses all embedded templates within a JavaScript or TypeScript file.\n * This function replaces all embedded templates that match our template syntax\n * with valid, parseable JS. Optionally, it can also include a source map, and\n * it can also include all possible values used within the template.\n *\n * Input:\n *\n * <template><MyComponent/><template>\n *\n * Output:\n *\n * [GLIMMER_TEMPLATE(`<MyComponent/>`, { scope() { return {MyComponent}; } })];\n *\n * It can also be used with template literals to provide the in scope values:\n *\n * Input:\n *\n * hbs`<MyComponent/>`;\n *\n * Output\n *\n * hbs(`<MyComponent/>`, { scope() { return {MyComponent}; } });\n */\nexport function preprocessEmbeddedTemplates(\n template: string,\n options: PreprocessOptions\n): PreprocessedOutput {\n const { templateTag, templateTagReplacement, includeTemplateTokens, relativePath } = options;\n\n const parseTemplatesOptions: ParseTemplatesOptions = {\n templateTag,\n };\n\n const matches = parseTemplates(template, relativePath, parseTemplatesOptions);\n const replacements: Replacement[] = [];\n const s = new MagicString(template);\n\n for (const match of matches) {\n if (match.type === 'template-tag') {\n replacements.push(\n ...replaceMatch(\n s,\n match,\n `[${templateTagReplacement}(`,\n ')]',\n template,\n includeTemplateTokens\n )\n );\n }\n }\n\n let output = s.toString();\n\n return {\n output,\n replacements,\n };\n}\n\nfunction ensureBackticksEscaped(s: MagicString, start: number, end: number) {\n if (start >= end) return;\n\n let content = s.slice(start, end);\n\n content = content.replace(/(?<!\\\\)`/g, '\\\\`');\n s.overwrite(start, end, content, false);\n}\n"],"names":["toString","module","Array","isArray","arr","call","require","isObject","val","LineColumnFinder","str","options","fromIndex","lineToIndex","buildLineToIndex","origin","prototype","index","length","isNaN","line","findLowerIndexInRangeArray","col","toIndex","column","lineIndex","nextIndex","lines","split","i","l","value","min","max","mid","getMatchStartAndEnd","match","start","expect","end","replacementFrom","template","oldLength","newLength","type","loc","lineColumn","originalCol","originalLine","replaceMatch","s","startReplacement","endReplacement","includeTemplateTokens","openStart","openEnd","closeStart","closeEnd","tokensString","getTemplateLocals","slice","filter","local","join","newStart","newEnd","overwrite","ensureBackticksEscaped","preprocessEmbeddedTemplates","templateTag","templateTagReplacement","relativePath","parseTemplatesOptions","matches","parseTemplates","replacements","MagicString","push","output","content","replace"],"mappings":";;;;;;;;;AAAA,IAAIA,QAAQ,GAAG,EAAE,CAACA,QAAQ,CAAA;AAE1BC,IAAAA,OAAc,GAAGC,KAAK,CAACC,OAAO,IAAI,UAAUC,GAAG,EAAE;AAC/C,EAAA,OAAOJ,QAAQ,CAACK,IAAI,CAACD,GAAG,CAAC,IAAI,gBAAgB,CAAA;AAC/C,CAAC;;;;;;;;;ACKD,IAAID,SAAO,GAAGG,OAAkB,CAAA;AAEhCL,IAAAA,QAAc,GAAG,SAASM,QAAQA,CAACC,GAAG,EAAE;AACtC,EAAA,OAAOA,GAAG,IAAI,IAAI,IAAI,OAAOA,GAAG,KAAK,QAAQ,IAAIL,SAAO,CAACK,GAAG,CAAC,KAAK,KAAK,CAAA;AACzE,CAAC;;;;;;;;ACND,IAAIL,OAAO,GAAIG,OAAkB,CAAA;AACjC,IAAIC,QAAQ,GAAGD,QAAmB,CAAA;IAGlCL,UAAc,GAAGQ,gBAAgB,CAAA;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,gBAAgBA,CAACC,GAAG,EAAEC,OAAO,EAAE;AACtC,EAAA,IAA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AAW,EAAE;EAC1E,IAAIF,KAAK,IAAIE,GAAG,EAAE,OAAA;EAElB,IAAIwC,OAAO,GAAG7B,CAAC,CAACU,KAAK,CAACvB,KAAK,EAAEE,GAAG,CAAC,CAAA;EAEjCwC,OAAO,GAAGA,OAAO,CAACC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;EAC7C9B,CAAC,CAACgB,SAAS,CAAC7B,KAAK,EAAEE,GAAG,EAAEwC,OAAO,EAAE,KAAK,CAAC,CAAA;AACzC;;;;","x_google_ignoreList":[0,1,2]}
1
+ {"version":3,"file":"preprocess.js","sources":["../../../src/browser/eti/preprocess.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { getTemplateLocals } from '@glimmer/syntax';\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport lineColumn from 'line-column';\nimport MagicString from 'magic-string';\n\nimport { expect } from './debug.ts';\nimport { parseTemplates } from './parse-templates.ts';\n\nimport type { ParseTemplatesOptions, TemplateMatch } from './parse-templates.ts';\n\ninterface PreprocessOptionsEager {\n importIdentifier?: string;\n importPath?: string;\n templateTag?: string;\n templateTagReplacement?: string;\n\n relativePath: string;\n includeSourceMaps: boolean;\n includeTemplateTokens: boolean;\n}\n\ninterface PreprocessOptionsLazy {\n importIdentifier?: string;\n importPath?: string;\n templateTag?: string;\n templateTagReplacement?: string;\n\n relativePath: string;\n includeSourceMaps: boolean;\n includeTemplateTokens: boolean;\n}\n\ntype PreprocessOptions = PreprocessOptionsLazy | PreprocessOptionsEager;\n\ninterface PreprocessedOutput {\n output: string;\n replacements: Replacement[];\n}\n\ninterface Replacement {\n type: 'start' | 'end';\n index: number;\n oldLength: number;\n newLength: number;\n originalLine: number;\n originalCol: number;\n}\n\nfunction getMatchStartAndEnd(match: RegExpMatchArray) {\n return {\n start: expect(match.index, 'Expected regular expression match to have an index'),\n end:\n expect(match.index, 'Expected regular expression match to have an index') + match[0].length,\n };\n}\n\nfunction replacementFrom(\n template: string,\n index: number,\n oldLength: number,\n newLength: number,\n type: 'start' | 'end'\n): Replacement {\n const loc = expect(\n lineColumn(template).fromIndex(index),\n 'BUG: expected to find a line/column based on index'\n );\n\n return {\n type,\n index,\n oldLength,\n newLength,\n originalCol: loc.col,\n originalLine: loc.line,\n };\n}\n\nfunction replaceMatch(\n s: MagicString,\n match: TemplateMatch,\n startReplacement: string,\n endReplacement: string,\n template: string,\n includeTemplateTokens: boolean\n): Replacement[] {\n const { start: openStart, end: openEnd } = getMatchStartAndEnd(match.start);\n const { start: closeStart, end: closeEnd } = getMatchStartAndEnd(match.end);\n\n let options = '';\n\n if (includeTemplateTokens) {\n const tokensString = getTemplateLocals(template.slice(openEnd, closeStart))\n .filter((local: string) => local.match(/^[$A-Z_][0-9A-Z_$]*$/i))\n .join(',');\n\n if (tokensString.length > 0) {\n options = `, scope: () => ({${tokensString}})`;\n }\n }\n\n const newStart = `${startReplacement}\\``;\n const newEnd = `\\`, { strictMode: true${options} }${endReplacement}`;\n\n s.overwrite(openStart, openEnd, newStart);\n s.overwrite(closeStart, closeEnd, newEnd);\n ensureBackticksEscaped(s, openEnd + 1, closeStart - 1);\n\n return [\n replacementFrom(template, openStart, openEnd - openStart, newStart.length, 'start'),\n replacementFrom(template, closeStart, closeEnd - closeStart, newEnd.length, 'end'),\n ];\n}\n\n/**\n * Preprocesses all embedded templates within a JavaScript or TypeScript file.\n * This function replaces all embedded templates that match our template syntax\n * with valid, parseable JS. Optionally, it can also include a source map, and\n * it can also include all possible values used within the template.\n *\n * Input:\n *\n * <template><MyComponent/><template>\n *\n * Output:\n *\n * [GLIMMER_TEMPLATE(`<MyComponent/>`, { scope() { return {MyComponent}; } })];\n *\n * It can also be used with template literals to provide the in scope values:\n *\n * Input:\n *\n * hbs`<MyComponent/>`;\n *\n * Output\n *\n * hbs(`<MyComponent/>`, { scope() { return {MyComponent}; } });\n */\nexport function preprocessEmbeddedTemplates(\n template: string,\n options: PreprocessOptions\n): PreprocessedOutput {\n const { templateTag, templateTagReplacement, includeTemplateTokens, relativePath } = options;\n\n const parseTemplatesOptions: ParseTemplatesOptions = {\n templateTag,\n };\n\n const matches = parseTemplates(template, relativePath, parseTemplatesOptions);\n const replacements: Replacement[] = [];\n const s = new MagicString(template);\n\n for (const match of matches) {\n if (match.type === 'template-tag') {\n replacements.push(\n ...replaceMatch(\n s,\n match,\n `[${templateTagReplacement}(`,\n ')]',\n template,\n includeTemplateTokens\n )\n );\n }\n }\n\n let output = s.toString();\n\n return {\n output,\n replacements,\n };\n}\n\nfunction ensureBackticksEscaped(s: MagicString, start: number, end: number) {\n if (start >= end) return;\n\n let content = s.slice(start, end);\n\n content = content.replace(/(?<!\\\\)`/g, '\\\\`');\n s.overwrite(start, end, content, false);\n}\n"],"names":["getMatchStartAndEnd","match","start","expect","index","end","length","replacementFrom","template","oldLength","newLength","type","loc","lineColumn","fromIndex","originalCol","col","originalLine","line","replaceMatch","s","startReplacement","endReplacement","includeTemplateTokens","openStart","openEnd","closeStart","closeEnd","options","tokensString","getTemplateLocals","slice","filter","local","join","newStart","newEnd","overwrite","ensureBackticksEscaped","preprocessEmbeddedTemplates","templateTag","templateTagReplacement","relativePath","parseTemplatesOptions","matches","parseTemplates","replacements","MagicString","push","output","toString","content","replace"],"mappings":";;;;;;AAAA;AACA;AAmDA,SAASA,mBAAmBA,CAACC,KAAuB,EAAE;EACpD,OAAO;IACLC,KAAK,EAAEC,MAAM,CAACF,KAAK,CAACG,KAAK,EAAE,oDAAoD,CAAC;AAChFC,IAAAA,GAAG,EACDF,MAAM,CAACF,KAAK,CAACG,KAAK,EAAE,oDAAoD,CAAC,GAAGH,KAAK,CAAC,CAAC,CAAC,CAACK,MAAAA;GACxF,CAAA;AACH,CAAA;AAEA,SAASC,eAAeA,CACtBC,QAAgB,EAChBJ,KAAa,EACbK,SAAiB,EACjBC,SAAiB,EACjBC,IAAqB,EACR;AACb,EAAA,MAAMC,GAAG,GAAGT,MAA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KAAK,cAAc,EAAE;MACjCmC,YAAY,CAACE,IAAI,CACf,GAAG7B,YAAY,CACbC,CAAC,EACDnB,KAAK,EACJ,IAAGwC,sBAAuB,CAAA,CAAA,CAAE,EAC7B,IAAI,EACJjC,QAAQ,EACRe,qBACF,CACF,CAAC,CAAA;AACH,KAAA;AACF,GAAA;AAEA,EAAA,IAAI0B,MAAM,GAAG7B,CAAC,CAAC8B,QAAQ,EAAE,CAAA;EAEzB,OAAO;IACLD,MAAM;AACNH,IAAAA,YAAAA;GACD,CAAA;AACH,CAAA;AAEA,SAASR,sBAAsBA,CAAClB,CAAc,EAAElB,KAAa,EAAEG,GAAW,EAAE;EAC1E,IAAIH,KAAK,IAAIG,GAAG,EAAE,OAAA;EAElB,IAAI8C,OAAO,GAAG/B,CAAC,CAACW,KAAK,CAAC7B,KAAK,EAAEG,GAAG,CAAC,CAAA;EAEjC8C,OAAO,GAAGA,OAAO,CAACC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;EAC7ChC,CAAC,CAACiB,SAAS,CAACnC,KAAK,EAAEG,GAAG,EAAE8C,OAAO,EAAE,KAAK,CAAC,CAAA;AACzC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"template-tag-transform.js","sources":["../../../src/browser/eti/template-tag-transform.ts"],"sourcesContent":["import { buildPrecompileTemplateCall, registerRefs, TEMPLATE_TAG_NAME } from './util';\n\n/**\n * Supports the following syntaxes:\n *\n * const Foo = [GLIMMER_TEMPLATE('hello')];\n *\n * export const Foo = [GLIMMER_TEMPLATE('hello')];\n *\n * export default [GLIMMER_TEMPLATE('hello')];\n *\n * class Foo {\n * [GLIMMER_TEMPLATE('hello')];\n * }\n */\nexport const transformTemplateTag = function (t: any, templatePath: any, state: any) {\n let compiled = buildPrecompileTemplateCall(t, templatePath, state);\n let path = templatePath.parentPath;\n\n if (path.type === 'ArrayExpression') {\n let arrayParentPath = path.parentPath;\n let varId = arrayParentPath.node.id || path.scope.generateUidIdentifier(templatePath);\n\n const templateOnlyComponentExpression = t.callExpression(\n buildSetComponentTemplate(path, state),\n [\n compiled,\n t.callExpression(\n state.importUtil.import(\n templatePath,\n '@ember/component/template-only',\n 'default',\n 'templateOnly'\n ),\n [t.stringLiteral('dynamic-runtime-file.js'), t.stringLiteral(varId.name)]\n ),\n ]\n );\n\n if (\n arrayParentPath.type === 'ExpressionStatement' &&\n arrayParentPath.parentPath.type === 'Program'\n ) {\n registerRefs(\n arrayParentPath.replaceWith(t.exportDefaultDeclaration(templateOnlyComponentExpression)),\n (newPath: any) => [\n newPath.get('declaration.callee'),\n newPath.get('declaration.arguments.0.callee'),\n newPath.get('declaration.arguments.1.callee'),\n ]\n );\n } else {\n registerRefs(path.replaceWith(templateOnlyComponentExpression), (newPath: any) => [\n newPath.get('callee'),\n newPath.get('arguments.0.callee'),\n newPath.get('arguments.1.callee'),\n ]);\n }\n } else if (path.type === 'ClassProperty') {\n let classPath = path.parentPath.parentPath;\n\n if (classPath.node.type === 'ClassDeclaration') {\n registerRefs(\n classPath.insertAfter(\n t.expressionStatement(\n t.callExpression(buildSetComponentTemplate(path, state), [compiled, classPath.node.id])\n )\n ),\n (newPath: any) => [\n newPath.get('expression.callee'),\n newPath.get('expression.arguments.0.callee'),\n ]\n );\n } else {\n registerRefs(\n classPath.replaceWith(\n t.expressionStatement(\n t.callExpression(buildSetComponentTemplate(path, state), [compiled, classPath.node])\n )\n ),\n (newPath: any) => [\n newPath.parentPath.get('callee'),\n newPath.parentPath.get('arguments.0.callee'),\n ]\n );\n }\n\n path.remove();\n\n return;\n } else {\n throw path.buildCodeFrameError(\n `Attempted to use \\`<${TEMPLATE_TAG_NAME}>\\` to define a template in an unsupported way. Templates defined using this syntax must be:\\n\\n1. Assigned to a variable declaration OR\\n2. The default export of a file OR\\n2. In the top level of the file on their own (sugar for \\`export default\\`) OR\\n4. Used directly within a named class body`\n );\n }\n};\n\nfunction buildSetComponentTemplate(path: any, state: any) {\n return state.importUtil.import(path, '@ember/component', 'setComponentTemplate');\n}\n"],"names":["transformTemplateTag","t","templatePath","state","compiled","buildPrecompileTemplateCall","path","parentPath","type","arrayParentPath","varId","node","id","scope","generateUidIdentifier","templateOnlyComponentExpression","callExpression","buildSetComponentTemplate","importUtil","import","stringLiteral","name","registerRefs","replaceWith","exportDefaultDeclaration","newPath","get","classPath","insertAfter","expressionStatement","remove","buildCodeFrameError","TEMPLATE_TAG_NAME"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,oBAAoB,GAAG,UAAUC,CAAM,EAAEC,YAAiB,EAAEC,KAAU,EAAE;EACnF,IAAIC,QAAQ,GAAGC,2BAA2B,CAACJ,CAAC,EAAEC,YAAY,EAAEC,KAAK,CAAC,CAAA;AAClE,EAAA,IAAIG,IAAI,GAAGJ,YAAY,CAACK,UAAU,CAAA;AAElC,EAAA,IAAID,IAAI,CAACE,IAAI,KAAK,iBAAiB,EAAE;AACnC,IAAA,IAAIC,eAAe,GAAGH,IAAI,CAACC,UAAU,CAAA;AACrC,IAAA,IAAIG,KAAK,GAAGD,eAAe,CAACE,IAAI,CAACC,EAAE,IAAIN,IAAI,CAACO,KAAK,CAACC,qBAAqB,CAACZ,YAAY,CAAC,CAAA;IAErF,MAAMa,+BAA+B,GAAGd,CAAC,CAACe,cAAc,CACtDC,yBAAyB,CAACX,IAAI,EAAEH,KAAK,CAAC,EACtC,CACEC,QAAQ,EACRH,CAAC,CAACe,cAAc,CACdb,KAAK,CAACe,UAAU,CAACC,MAAM,CACrBjB,YAAY,EACZ,gCAAgC,EAChC,SAAS,EACT,cACF,CAAC,EACD,CAACD,CAAC,CAACmB,aAAa,CAAC,yBAAyB,CAAC,EAAEnB,CAAC,CAACmB,aAAa,CAACV,KAAK,CAACW,IAAI,CAAC,CAC1E,CAAC,CAEL,CAAC,CAAA;AAED,IAAA,IACEZ,eAAe,CAACD,IAAI,KAAK,qBAAqB,IAC9CC,eAAe,CAACF,UAA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CAAC,CAACe,cAAc,CAACC,yBAAyB,CAACX,IAAI,EAAEH,KAAK,CAAC,EAAE,CAACC,QAAQ,EAAEuB,SAAS,CAAChB,IAAI,CAAC,CACrF,CACF,CAAC,EACAc,OAAY,IAAK,CAChBA,OAAO,CAAClB,UAAU,CAACmB,GAAG,CAAC,QAAQ,CAAC,EAChCD,OAAO,CAAClB,UAAU,CAACmB,GAAG,CAAC,oBAAoB,CAAC,CAEhD,CAAC,CAAA;AACH,KAAA;IAEApB,IAAI,CAACwB,MAAM,EAAE,CAAA;AAEb,IAAA,OAAA;AACF,GAAC,MAAM;AACL,IAAA,MAAMxB,IAAI,CAACyB,mBAAmB,CAC3B,CAAsBC,oBAAAA,EAAAA,iBAAkB,0SAC3C,CAAC,CAAA;AACH,GAAA;AACF,EAAC;AAED,SAASf,yBAAyBA,CAACX,IAAS,EAAEH,KAAU,EAAE;EACxD,OAAOA,KAAK,CAACe,UAAU,CAACC,MAAM,CAACb,IAAI,EAAE,kBAAkB,EAAE,sBAAsB,CAAC,CAAA;AAClF;;;;"}
1
+ {"version":3,"file":"template-tag-transform.js","sources":["../../../src/browser/eti/template-tag-transform.ts"],"sourcesContent":["import { buildPrecompileTemplateCall, registerRefs, TEMPLATE_TAG_NAME } from './util.ts';\n\n/**\n * Supports the following syntaxes:\n *\n * const Foo = [GLIMMER_TEMPLATE('hello')];\n *\n * export const Foo = [GLIMMER_TEMPLATE('hello')];\n *\n * export default [GLIMMER_TEMPLATE('hello')];\n *\n * class Foo {\n * [GLIMMER_TEMPLATE('hello')];\n * }\n */\nexport const transformTemplateTag = function (t: any, templatePath: any, state: any) {\n let compiled = buildPrecompileTemplateCall(t, templatePath, state);\n let path = templatePath.parentPath;\n\n if (path.type === 'ArrayExpression') {\n let arrayParentPath = path.parentPath;\n let varId = arrayParentPath.node.id || path.scope.generateUidIdentifier(templatePath);\n\n const templateOnlyComponentExpression = t.callExpression(\n buildSetComponentTemplate(path, state),\n [\n compiled,\n t.callExpression(\n state.importUtil.import(\n templatePath,\n '@ember/component/template-only',\n 'default',\n 'templateOnly'\n ),\n [t.stringLiteral('dynamic-runtime-file.js'), t.stringLiteral(varId.name)]\n ),\n ]\n );\n\n if (\n arrayParentPath.type === 'ExpressionStatement' &&\n arrayParentPath.parentPath.type === 'Program'\n ) {\n registerRefs(\n arrayParentPath.replaceWith(t.exportDefaultDeclaration(templateOnlyComponentExpression)),\n (newPath: any) => [\n newPath.get('declaration.callee'),\n newPath.get('declaration.arguments.0.callee'),\n newPath.get('declaration.arguments.1.callee'),\n ]\n );\n } else {\n registerRefs(path.replaceWith(templateOnlyComponentExpression), (newPath: any) => [\n newPath.get('callee'),\n newPath.get('arguments.0.callee'),\n newPath.get('arguments.1.callee'),\n ]);\n }\n } else if (path.type === 'ClassProperty') {\n let classPath = path.parentPath.parentPath;\n\n if (classPath.node.type === 'ClassDeclaration') {\n registerRefs(\n classPath.insertAfter(\n t.expressionStatement(\n t.callExpression(buildSetComponentTemplate(path, state), [compiled, classPath.node.id])\n )\n ),\n (newPath: any) => [\n newPath.get('expression.callee'),\n newPath.get('expression.arguments.0.callee'),\n ]\n );\n } else {\n registerRefs(\n classPath.replaceWith(\n t.expressionStatement(\n t.callExpression(buildSetComponentTemplate(path, state), [compiled, classPath.node])\n )\n ),\n (newPath: any) => [\n newPath.parentPath.get('callee'),\n newPath.parentPath.get('arguments.0.callee'),\n ]\n );\n }\n\n path.remove();\n\n return;\n } else {\n throw path.buildCodeFrameError(\n `Attempted to use \\`<${TEMPLATE_TAG_NAME}>\\` to define a template in an unsupported way. Templates defined using this syntax must be:\\n\\n1. Assigned to a variable declaration OR\\n2. The default export of a file OR\\n2. In the top level of the file on their own (sugar for \\`export default\\`) OR\\n4. Used directly within a named class body`\n );\n }\n};\n\nfunction buildSetComponentTemplate(path: any, state: any) {\n return state.importUtil.import(path, '@ember/component', 'setComponentTemplate');\n}\n"],"names":["transformTemplateTag","t","templatePath","state","compiled","buildPrecompileTemplateCall","path","parentPath","type","arrayParentPath","varId","node","id","scope","generateUidIdentifier","templateOnlyComponentExpression","callExpression","buildSetComponentTemplate","importUtil","import","stringLiteral","name","registerRefs","replaceWith","exportDefaultDeclaration","newPath","get","classPath","insertAfter","expressionStatement","remove","buildCodeFrameError","TEMPLATE_TAG_NAME"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,oBAAoB,GAAG,UAAUC,CAAM,EAAEC,YAAiB,EAAEC,KAAU,EAAE;EACnF,IAAIC,QAAQ,GAAGC,2BAA2B,CAACJ,CAAC,EAAEC,YAAY,EAAEC,KAAK,CAAC,CAAA;AAClE,EAAA,IAAIG,IAAI,GAAGJ,YAAY,CAACK,UAAU,CAAA;AAElC,EAAA,IAAID,IAAI,CAACE,IAAI,KAAK,iBAAiB,EAAE;AACnC,IAAA,IAAIC,eAAe,GAAGH,IAAI,CAACC,UAAU,CAAA;AACrC,IAAA,IAAIG,KAAK,GAAGD,eAAe,CAACE,IAAI,CAACC,EAAE,IAAIN,IAAI,CAACO,KAAK,CAACC,qBAAqB,CAACZ,YAAY,CAAC,CAAA;IAErF,MAAMa,+BAA+B,GAAGd,CAAC,CAACe,cAAc,CACtDC,yBAAyB,CAACX,IAAI,EAAEH,KAAK,CAAC,EACtC,CACEC,QAAQ,EACRH,CAAC,CAACe,cAAc,CACdb,KAAK,CAACe,UAAU,CAACC,MAAM,CACrBjB,YAAY,EACZ,gCAAgC,EAChC,SAAS,EACT,cACF,CAAC,EACD,CAACD,CAAC,CAACmB,aAAa,CAAC,yBAAyB,CAAC,EAAEnB,CAAC,CAACmB,aAAa,CAACV,KAAK,CAACW,IAAI,CAAC,CAC1E,CAAC,CAEL,CAAC,CAAA;AAED,IAAA,IACEZ,eAAe,CAACD,IAAI,KAAK,qBAAqB,IAC9CC,eAAe,CAACF,UAAU,CAACC,IAAI,KAAK,SAAS,EAC7C;AACAc,MAAAA,YAAY,CACVb,eAAe,CAACc,WAAW,CA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Q,EAAEuB,SAAS,CAAChB,IAAI,CAAC,CACrF,CACF,CAAC,EACAc,OAAY,IAAK,CAChBA,OAAO,CAAClB,UAAU,CAACmB,GAAG,CAAC,QAAQ,CAAC,EAChCD,OAAO,CAAClB,UAAU,CAACmB,GAAG,CAAC,oBAAoB,CAAC,CAEhD,CAAC,CAAA;AACH,KAAA;IAEApB,IAAI,CAACwB,MAAM,EAAE,CAAA;AAEb,IAAA,OAAA;AACF,GAAC,MAAM;AACL,IAAA,MAAMxB,IAAI,CAACyB,mBAAmB,CAC3B,CAAsBC,oBAAAA,EAAAA,iBAAkB,0SAC3C,CAAC,CAAA;AACH,GAAA;AACF,EAAC;AAED,SAASf,yBAAyBA,CAACX,IAAS,EAAEH,KAAU,EAAE;EACxD,OAAOA,KAAK,CAACe,UAAU,CAACC,MAAM,CAACb,IAAI,EAAE,kBAAkB,EAAE,sBAAsB,CAAC,CAAA;AAClF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sources":["../../../src/browser/eti/util.ts"],"sourcesContent":["import type { TemplateMatch } from './parse-templates';\nimport type { NodePath } from '@babel/traverse';\nimport type { CallExpression } from '@babel/types';\nimport type { ImportUtil } from 'babel-import-util';\n\n// const Greeting = <template>Hello</template>\nexport const TEMPLATE_TAG_NAME = 'template';\nexport const TEMPLATE_TAG_PLACEHOLDER = '__GLIMMER_TEMPLATE';\n\nexport function isTemplateTag(callExpressionPath: NodePath<CallExpression>) {\n const callee = callExpressionPath.get('callee');\n\n return (\n !Array.isArray(callee) && callee.isIdentifier() && callee.node.name === TEMPLATE_TAG_PLACEHOLDER\n );\n}\n\nexport function buildPrecompileTemplateCall(\n t: any,\n callExpressionPath: NodePath<CallExpression>,\n state: {\n importUtil: ImportUtil;\n }\n): CallExpression {\n const callee = callExpressionPath.get('callee');\n\n return t.callExpression(\n state.importUtil.import(callee, '@ember/template-compilation', 'precompileTemplate'),\n callExpressionPath.node.arguments\n );\n}\n\nexport function registerRefs(\n newPath: string | string[],\n getRefPaths: (path: string) => NodePath[]\n) {\n if (Array.isArray(newPath)) {\n if (newPath.length > 1) {\n throw new Error(\n 'registerRefs is only meant to handle single node transformations. Received more than one path node.'\n );\n }\n\n newPath = newPath[0] as string;\n }\n\n const refPaths = getRefPaths(newPath);\n\n for (const ref of refPaths) {\n if (!ref.isIdentifier()) {\n throw new Error(\n 'ember-template-imports internal assumption that refPath should of type identifier. Please open an issue.'\n );\n }\n\n const binding = ref.scope.getBinding(ref.node.name);\n\n if (binding !== undefined) {\n binding.reference(ref);\n }\n }\n}\n\nconst SUPPORTED_EXTENSIONS = ['.js', '.ts', '.gjs', '.gts'];\n\nexport function isSupportedScriptFileExtension(filePath: string) {\n return SUPPORTED_EXTENSIONS.some((ext) => filePath.endsWith(ext));\n}\n\nexport function isStrictMode(templateInfo: TemplateMatch): boolean {\n return templateInfo.type === 'template-tag';\n}\n"],"names":["TEMPLATE_TAG_NAME","TEMPLATE_TAG_PLACEHOLDER","isTemplateTag","callExpressionPath","callee","get","Array","isArray","isIdentifier","node","name","buildPrecompileTemplateCall","t","state","callExpression","importUtil","import","arguments","registerRefs","newPath","getRefPaths","length","Error","refPaths","ref","binding","scope","getBinding","undefined","reference","SUPPORTED_EXTENSIONS","isSupportedScriptFileExtension","filePath","some","ext","endsWith","isStrictMode","templateInfo","type"],"mappings":"AAKA;AACO,MAAMA,iBAAiB,GAAG,WAAU;AACpC,MAAMC,wBAAwB,GAAG,qBAAoB;AAErD,SAASC,aAAaA,CAACC,kBAA4C,EAAE;AAC1E,EAAA,MAAMC,MAAM,GAAGD,kBAAkB,CAACE,GAAG,CAAC,QAAQ,CAAC,CAAA;EAE/C,OACE,CAACC,KAAK,CAACC,OAAO,CAACH,MAAM,CAAC,IAAIA,MAAM,CAACI,YAAY,EAAE,IAAIJ,MAAM,CAACK,IAAI,CAACC,IAAI,KAAKT,wBAAwB,CAAA;AAEpG,CAAA;AAEO,SAASU,2BAA2BA,CACzCC,CAAM,EACNT,kBAA4C,EAC5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AEC,GAAG,IAAKF,QAAQ,CAACG,QAAQ,CAACD,GAAG,CAAC,CAAC,CAAA;AACnE,CAAA;AAEO,SAASE,YAAYA,CAACC,YAA2B,EAAW;AACjE,EAAA,OAAOA,YAAY,CAACC,IAAI,KAAK,cAAc,CAAA;AAC7C;;;;"}
1
+ {"version":3,"file":"util.js","sources":["../../../src/browser/eti/util.ts"],"sourcesContent":["import type { TemplateMatch } from './parse-templates.ts';\nimport type { NodePath } from '@babel/traverse';\nimport type { CallExpression } from '@babel/types';\nimport type { ImportUtil } from 'babel-import-util';\n\n// const Greeting = <template>Hello</template>\nexport const TEMPLATE_TAG_NAME = 'template';\nexport const TEMPLATE_TAG_PLACEHOLDER = '__GLIMMER_TEMPLATE';\n\nexport function isTemplateTag(callExpressionPath: NodePath<CallExpression>) {\n const callee = callExpressionPath.get('callee');\n\n return (\n !Array.isArray(callee) && callee.isIdentifier() && callee.node.name === TEMPLATE_TAG_PLACEHOLDER\n );\n}\n\nexport function buildPrecompileTemplateCall(\n t: any,\n callExpressionPath: NodePath<CallExpression>,\n state: {\n importUtil: ImportUtil;\n }\n): CallExpression {\n const callee = callExpressionPath.get('callee');\n\n return t.callExpression(\n state.importUtil.import(callee, '@ember/template-compilation', 'precompileTemplate'),\n callExpressionPath.node.arguments\n );\n}\n\nexport function registerRefs(\n newPath: string | string[],\n getRefPaths: (path: string) => NodePath[]\n) {\n if (Array.isArray(newPath)) {\n if (newPath.length > 1) {\n throw new Error(\n 'registerRefs is only meant to handle single node transformations. Received more than one path node.'\n );\n }\n\n newPath = newPath[0] as string;\n }\n\n const refPaths = getRefPaths(newPath);\n\n for (const ref of refPaths) {\n if (!ref.isIdentifier()) {\n throw new Error(\n 'ember-template-imports internal assumption that refPath should of type identifier. Please open an issue.'\n );\n }\n\n const binding = ref.scope.getBinding(ref.node.name);\n\n if (binding !== undefined) {\n binding.reference(ref);\n }\n }\n}\n\nconst SUPPORTED_EXTENSIONS = ['.js', '.ts', '.gjs', '.gts'];\n\nexport function isSupportedScriptFileExtension(filePath: string) {\n return SUPPORTED_EXTENSIONS.some((ext) => filePath.endsWith(ext));\n}\n\nexport function isStrictMode(templateInfo: TemplateMatch): boolean {\n return templateInfo.type === 'template-tag';\n}\n"],"names":["TEMPLATE_TAG_NAME","TEMPLATE_TAG_PLACEHOLDER","isTemplateTag","callExpressionPath","callee","get","Array","isArray","isIdentifier","node","name","buildPrecompileTemplateCall","t","state","callExpression","importUtil","import","arguments","registerRefs","newPath","getRefPaths","length","Error","refPaths","ref","binding","scope","getBinding","undefined","reference","SUPPORTED_EXTENSIONS","isSupportedScriptFileExtension","filePath","some","ext","endsWith","isStrictMode","templateInfo","type"],"mappings":"AAKA;AACO,MAAMA,iBAAiB,GAAG,WAAU;AACpC,MAAMC,wBAAwB,GAAG,qBAAoB;AAErD,SAASC,aAAaA,CAACC,kBAA4C,EAAE;AAC1E,EAAA,MAAMC,MAAM,GAAGD,kBAAkB,CAACE,GAAG,CAAC,QAAQ,CAAC,CAAA;EAE/C,OACE,CAACC,KAAK,CAACC,OAAO,CAACH,MAAM,CAAC,IAAIA,MAAM,CAACI,YAAY,EAAE,IAAIJ,MAAM,CAACK,IAAI,CAACC,IAAI,KAAKT,wBAAwB,CAAA;AAEpG,CAAA;AAEO,SAASU,2BAA2BA,CACzCC,CAAM,EACNT,kBAA4C,EAC5CU,KAEC,EACe;AAChB,EAAA,MAAMT,MAAM,GAAGD,kBAAkB,CAACE,GAAG,CAAC,QAAQ,CAAC,CAAA;EAE/C,OAAOO,CAAC,CAACE,cAAc,CACrBD,KAAK,CAACE,UAAU,CAACC,MAAM,CAACZ,MAAM,EAAE,6BAA6B,EAAE,oBAAoB,CAAC,EACpFD,kBAAkB,CAACM,IAAI,CAACQ,SAC1B,CAAC,CAAA;AACH,CAAA;AAEO,SAASC,YAAYA,CAC1BC,OAA0B,EAC1BC,WAAyC,EACzC;AACA,EAAA,IAAId,KAAK,CAACC,OAAO,CAACY,OAAO,CAAC,EAAE;AAC1B,IAAA,IAAIA,OAAO,CAACE,MAAM,GAAG,CAAC,EAAE;AACtB,MAAA,MAAM,IAAIC,KAAK,CACb,qGACF,CAAC,CAAA;AACH,KAAA;AAEAH,IAAAA,OAAO,GAAGA,OAAO,CAAC,CAAC,CAAW,CAAA;AAChC,GAAA;AAEA,EAAA,MAAMI,QAAQ,GAAGH,WAAW,CAACD,OAAO,CAAC,CAAA;AAErC,EAAA,KAAK,MAAMK,GAAG,IAAID,QAAQ,EAAE;AAC1B,IAAA,IAAI,CAACC,GAAG,CAAChB,YAAY,EAAE,EAAE;AACvB,MAAA,MAAM,IAAIc,KAAK,CACb,0GACF,CAAC,CAAA;AACH,KAAA;AAEA,IAAA,MAAMG,OAAO,GAAGD,GAAG,CAACE,KAAK,CAACC,UAAU,CAACH,GAAG,CAACf,IAAI,CAACC,IAAI,CAAC,CAAA;IAEnD,IAAIe,OAAO,KAAKG,SAAS,EAAE;AACzBH,MAAAA,OAAO,CAACI,SAAS,CAACL,GAAG,CAAC,CAAA;AACxB,KAAA;AACF,GAAA;AACF,CAAA;AAEA,MAAMM,oBAAoB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;AAEpD,SAASC,8BAA8BA,CAACC,QAAgB,EAAE;AAC/D,EAAA,OAAOF,oBAAoB,CAACG,IAAI,CAAEC,GAAG,IAAKF,QAAQ,CAACG,QAAQ,CAACD,GAAG,CAAC,CAAC,CAAA;AACnE,CAAA;AAEO,SAASE,YAAYA,CAACC,YAA2B,EAAW;AACjE,EAAA,OAAOA,YAAY,CAACC,IAAI,KAAK,cAAc,CAAA;AAC7C;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"gjs.js","sources":["../../src/browser/gjs.ts"],"sourcesContent":["import { importSync } from '@embroider/macros';\n\nimport babelPluginEmberTemplateCompilation from 'babel-plugin-ember-template-compilation';\n\n// TODO: use real packages, and not these copied files from ember-template-imports\nimport babelPluginIntermediateGJS from './eti/babel-plugin';\nimport { preprocessEmbeddedTemplates } from './eti/preprocess';\nimport { TEMPLATE_TAG_NAME, TEMPLATE_TAG_PLACEHOLDER } from './eti/util';\n\nimport type { Babel } from './types';\n\nconst compiler = importSync('ember-source/dist/ember-template-compiler.js');\n\nexport function preprocess(input: string, name: string) {\n let preprocessed = preprocessEmbeddedTemplates(input, {\n relativePath: `${name}.js`,\n includeSourceMaps: false,\n includeTemplateTokens: true,\n templateTag: TEMPLATE_TAG_NAME,\n templateTagReplacement: TEMPLATE_TAG_PLACEHOLDER,\n });\n\n return preprocessed.output;\n}\n\nexport async function transform(\n intermediate: string,\n name: string,\n options: any = {}\n): Promise<ReturnType<Babel['transform']>> {\n let babel = (await import('@babel/standalone')) as Babel;\n\n return babel.transform(intermediate, {\n filename: `${name}.js`,\n plugins: [\n [babelPluginIntermediateGJS],\n [\n babelPluginEmberTemplateCompilation,\n {\n compiler,\n },\n ],\n [babel.availablePlugins['proposal-decorators'], { legacy: true }],\n [babel.availablePlugins['proposal-class-properties']],\n ],\n presets: [\n [\n babel.availablePresets['env'],\n {\n // false -- keeps ES Modules\n modules: 'cjs',\n targets: { esmodules: true },\n forceAllTransforms: false,\n ...options,\n },\n ],\n ],\n });\n}\n"],"names":["compiler","importSync","preprocess","input","name","preprocessed","preprocessEmbeddedTemplates","relativePath","includeSourceMaps","includeTemplateTokens","templateTag","TEMPLATE_TAG_NAME","templateTagReplacement","TEMPLATE_TAG_PLACEHOLDER","output","transform","intermediate","options","babel","filename","plugins","babelPluginIntermediateGJS","babelPluginEmberTemplateCompilation","availablePlugins","legacy","presets","availablePresets","modules","targets","esmodules","forceAllTransforms"],"mappings":";;;;;;AAWA,MAAMA,QAAQ,GAAGC,UAAU,CAAC,8CAA8C,CAAC,CAAA;AAEpE,SAASC,UAAUA,CAACC,KAAa,EAAEC,IAAY,EAAE;AACtD,EAAA,IAAIC,YAAY,GAAGC,2BAA2B,CAACH,KAAK,EAAE;IACpDI,YAAY,EAAG,CAAEH,EAAAA,IAAK,CAAI,GAAA,CAAA;AAC1BI,IAAAA,iBAAiB,EAAE,KAAK;AACxBC,IAAAA,qBAAqB,EAAE,IAAI;AAC3BC,IAAAA,WAAW,EAAEC,iBAAiB;AAC9BC,IAAAA,sBAAsB,EAAEC,wBAAAA;AAC1B,GAAC,CAAC,CAAA;EAEF,OAAOR,YAAY,CAACS,MAAM,CAAA;AAC5B,CAAA;AAEO,eAAeC,SAASA,CAC7BC,YAAoB,EACpBZ,IAAY,EACZa,OAAY,GAAG,EAAE,EACwB;AACzC,EAAA,IAAIC,KAAK,GAAI,MAAM,OAAO,mBAAmB,CAAW,CAAA;AAExD,EAAA,OAAOA,KAAK,CAACH,SAAS,CAACC,YAAY,EAAE;IACnCG,QAAQ,EAAG,CAAEf,EAAAA,IAAK,CAAI,GAAA,CAAA;IACtBgB,OAAO,EAAE,CACP,CAACC,0BAA0B,CAAC,EAC5B,CACEC,mCAAmC,EACnC;AACEtB,MAAAA,QAAAA;KACD,CACF,EACD,CAACkB,KAAK,CAACK,gBAAgB,CAAC,qBAAqB,CAAC,EAAE;AAAEC,MAAAA,MAAM,EAAE,IAAA;KAAM,CAAC,EACjE,CAACN,KAAK,CAACK,gBAAgB,CAAC,2BAA2B,CAAC,CAAC,CACtD;IACDE,OAAO,EAAE,CACP,CACEP,KAAK,CAACQ,gBAAgB,CAAC,KAAK,CAAC,EAC7B;AACE;AACAC,MAAAA,OAAO,EAAE,KAAK;AACdC,MAAAA,OAAO,EAAE;AAAEC,QAAAA,SAAS,EAAE,IAAA;OAAM;AAC5BC,MAAAA,kBAAkB,EAAE,KAAK;MACzB,GAAGb,OAAAA;AACL,KAAC,CACF,CAAA;AAEL,GAAC,CAAC,CAAA;AACJ;;;;"}
1
+ {"version":3,"file":"gjs.js","sources":["../../src/browser/gjs.ts"],"sourcesContent":["import { importSync } from '@embroider/macros';\n\nimport babelPluginEmberTemplateCompilation from 'babel-plugin-ember-template-compilation';\n\n// TODO: use real packages, and not these copied files from ember-template-imports\nimport babelPluginIntermediateGJS from './eti/babel-plugin.ts';\nimport { preprocessEmbeddedTemplates } from './eti/preprocess.ts';\nimport { TEMPLATE_TAG_NAME, TEMPLATE_TAG_PLACEHOLDER } from './eti/util.ts';\n\nimport type { Babel } from './types.ts';\n\nconst compiler = importSync('ember-source/dist/ember-template-compiler.js');\n\nexport function preprocess(input: string, name: string) {\n let preprocessed = preprocessEmbeddedTemplates(input, {\n relativePath: `${name}.js`,\n includeSourceMaps: false,\n includeTemplateTokens: true,\n templateTag: TEMPLATE_TAG_NAME,\n templateTagReplacement: TEMPLATE_TAG_PLACEHOLDER,\n });\n\n return preprocessed.output;\n}\n\nexport async function transform(\n intermediate: string,\n name: string,\n options: any = {}\n): Promise<ReturnType<Babel['transform']>> {\n let babel = (await import('@babel/standalone')) as Babel;\n\n return babel.transform(intermediate, {\n filename: `${name}.js`,\n plugins: [\n [babelPluginIntermediateGJS],\n [\n babelPluginEmberTemplateCompilation,\n {\n compiler,\n },\n ],\n [babel.availablePlugins['proposal-decorators'], { legacy: true }],\n [babel.availablePlugins['proposal-class-properties']],\n ],\n presets: [\n [\n babel.availablePresets['env'],\n {\n // false -- keeps ES Modules\n modules: 'cjs',\n targets: { esmodules: true },\n forceAllTransforms: false,\n ...options,\n },\n ],\n ],\n });\n}\n"],"names":["compiler","importSync","preprocess","input","name","preprocessed","preprocessEmbeddedTemplates","relativePath","includeSourceMaps","includeTemplateTokens","templateTag","TEMPLATE_TAG_NAME","templateTagReplacement","TEMPLATE_TAG_PLACEHOLDER","output","transform","intermediate","options","babel","filename","plugins","babelPluginIntermediateGJS","babelPluginEmberTemplateCompilation","availablePlugins","legacy","presets","availablePresets","modules","targets","esmodules","forceAllTransforms"],"mappings":";;;;;;AAWA,MAAMA,QAAQ,GAAGC,UAAU,CAAC,8CAA8C,CAAC,CAAA;AAEpE,SAASC,UAAUA,CAACC,KAAa,EAAEC,IAAY,EAAE;AACtD,EAAA,IAAIC,YAAY,GAAGC,2BAA2B,CAACH,KAAK,EAAE;IACpDI,YAAY,EAAG,CAAEH,EAAAA,IAAK,CAAI,GAAA,CAAA;AAC1BI,IAAAA,iBAAiB,EAAE,KAAK;AACxBC,IAAAA,qBAAqB,EAAE,IAAI;AAC3BC,IAAAA,WAAW,EAAEC,iBAAiB;AAC9BC,IAAAA,sBAAsB,EAAEC,wBAAAA;AAC1B,GAAC,CAAC,CAAA;EAEF,OAAOR,YAAY,CAACS,MAAM,CAAA;AAC5B,CAAA;AAEO,eAAeC,SAASA,CAC7BC,YAAoB,EACpBZ,IAAY,EACZa,OAAY,GAAG,EAAE,EACwB;AACzC,EAAA,IAAIC,KAAK,GAAI,MAAM,OAAO,mBAAmB,CAAW,CAAA;AAExD,EAAA,OAAOA,KAAK,CAACH,SAAS,CAACC,YAAY,EAAE;IACnCG,QAAQ,EAAG,CAAEf,EAAAA,IAAK,CAAI,GAAA,CAAA;IACtBgB,OAAO,EAAE,CACP,CAACC,0BAA0B,CAAC,EAC5B,CACEC,mCAAmC,EACnC;AACEtB,MAAAA,QAAAA;KACD,CACF,EACD,CAACkB,KAAK,CAACK,gBAAgB,CAAC,qBAAqB,CAAC,EAAE;AAAEC,MAAAA,MAAM,EAAE,IAAA;KAAM,CAAC,EACjE,CAACN,KAAK,CAACK,gBAAgB,CAAC,2BAA2B,CAAC,CAAC,CACtD;IACDE,OAAO,EAAE,CACP,CACEP,KAAK,CAACQ,gBAAgB,CAAC,KAAK,CAAC,EAC7B;AACE;AACAC,MAAAA,OAAO,EAAE,KAAK;AACdC,MAAAA,OAAO,EAAE;AAAEC,QAAAA,SAAS,EAAE,IAAA;OAAM;AAC5BC,MAAAA,kBAAkB,EAAE,KAAK;MACzB,GAAGb,OAAAA;AACL,KAAC,CACF,CAAA;AAEL,GAAC,CAAC,CAAA;AACJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"hbs.js","sources":["../../src/browser/hbs.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n// import { precompileJSON } from '@glimmer/compiler';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { setComponentTemplate } from '@ember/component';\nimport templateOnlyComponent from '@ember/component/template-only';\nimport { array, concat, fn, get, hash } from '@ember/helper';\nimport { on } from '@ember/modifier';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { createTemplateFactory } from '@ember/template-factory';\nimport { importSync } from '@embroider/macros';\n\nimport { nameFor } from './utils';\n\nimport type { CompileResult } from './types';\nimport type { ComponentLike } from '@glint/template';\n\n// These things are pre-bundled in the old system.\n// ember-template-compiler defines them in AMD/requirejs\nconst { precompileJSON } = importSync('@glimmer/compiler') as any;\nconst { getTemplateLocals } = importSync('@glimmer/syntax') as any;\n\n/**\n * compile a template with an empty scope\n * to use components, helpers, etc, you will need to compile with JS\n *\n * (templates alone do not have a way to import / define complex structures)\n */\nexport function compileHBS(template: string, options: CompileTemplateOptions = {}): CompileResult {\n let name = nameFor(template);\n let component: undefined | ComponentLike;\n let error: undefined | Error;\n\n try {\n component = setComponentTemplate(\n compileTemplate(template, { moduleName: options.moduleName || name, ...options }),\n templateOnlyComponent(options.moduleName || name)\n ) as ComponentLike;\n } catch (e) {\n error = e as Error | undefined;\n }\n\n return { name, component, error };\n}\n\ninterface CompileTemplateOptions {\n /**\n * Used for debug viewing\n */\n moduleName?: string;\n scope?: Record<string, unknown>;\n}\n\n/**\n * The reason why we can't use precompile directly is because of this:\n * https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/compiler/lib/compiler.ts#L132\n *\n * Support for dynamically compiling templates in strict mode doesn't seem to be fully their yet.\n * That JSON.stringify (and the lines after) prevent us from easily setting the scope function,\n * which means that *everything* is undefined.\n */\nfunction compileTemplate(source: string, { moduleName, scope = {} }: CompileTemplateOptions) {\n let localScope = { array, concat, fn, get, hash, on, ...scope } as any;\n let locals = getTemplateLocals(source);\n\n let options = {\n strictMode: true,\n moduleName,\n locals,\n isProduction: false,\n meta: { moduleName },\n };\n\n // Copied from @glimmer/compiler/lib/compiler#precompile\n let [block, usedLocals] = precompileJSON(source, options);\n\n let usedScope = usedLocals.map((key: string) => localScope[key]);\n\n let blockJSON = JSON.stringify(block);\n let templateJSONObject = {\n id: moduleName,\n block: blockJSON,\n moduleName: moduleName ?? '(unknown template module)',\n scope: () => usedScope,\n isStrictMode: true,\n };\n\n let factory = createTemplateFactory(templateJSONObject);\n\n return factory;\n}\n"],"names":["precompileJSON","importSync","getTemplateLocals","compileHBS","template","options","name","nameFor","component","error","setComponentTemplate","compileTemplate","moduleName","templateOnlyComponent","e","source","scope","localScope","array","concat","fn","get","hash","on","locals","strictMode","isProduction","meta","block","usedLocals","usedScope","map","key","blockJSON","JSON","stringify","templateJSONObject","id","isStrictMode","factory","createTemplateFactory"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AAeA;AACA;AACA,MAAM;AAAEA,EAAAA,cAAAA;AAAe,CAAC,GAAGC,UAAU,CAAC,mBAAmB,CAAQ,CAAA;AACjE,MAAM;AAAEC,EAAAA,iBAAAA;AAAkB,CAAC,GAAGD,UAAU,CAAC,iBAAiB,CAAQ,CAAA;;AAElE;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,UAAUA,CAACC,QAAgB,EAAEC,OAA+B,GAAG,EAAE,EAAiB;AAChG,EAAA,IAAIC,IAAI,GAAGC,OAAO,CAACH,QAAQ,CAAC,CAAA;AAC5B,EAAA,IAAII,SAAoC,CAAA;AACxC,EAAA,IAAIC,KAAwB,CAAA;EAE5B,IAAI;AACFD,IAAAA,SAAS,GAAGE,oBAAoB,CAC9BC,eAAe,CAACP,QAAQ,EAAE;AAAEQ,MAAAA,UAAU,EAAEP,OAAO,CAACO,UAAU,IAAIN,IAAI;MAAE,GAAGD,OAAAA;KAAS,CAAC,EACjFQ,GAAqB,CAACR,OAAO,CAACO,UAAU,IAAIN,IAAI,CAClD,CAAkB,CAAA;GACnB,CAAC,OAAOQ,CAAC,EAAE;AACVL,IAAAA,KAAK,GA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AAA;AAEvD,EAAA,OAAOG,OAAO,CAAA;AAChB;;;;"}
1
+ {"version":3,"file":"hbs.js","sources":["../../src/browser/hbs.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n// import { precompileJSON } from '@glimmer/compiler';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { setComponentTemplate } from '@ember/component';\nimport templateOnlyComponent from '@ember/component/template-only';\nimport { array, concat, fn, get, hash } from '@ember/helper';\nimport { on } from '@ember/modifier';\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { createTemplateFactory } from '@ember/template-factory';\nimport { importSync } from '@embroider/macros';\n\nimport { nameFor } from './utils.ts';\n\nimport type { CompileResult } from './types.ts';\nimport type { ComponentLike } from '@glint/template';\n\n// These things are pre-bundled in the old system.\n// ember-template-compiler defines them in AMD/requirejs\nconst { precompileJSON } = importSync('@glimmer/compiler') as any;\nconst { getTemplateLocals } = importSync('@glimmer/syntax') as any;\n\n/**\n * compile a template with an empty scope\n * to use components, helpers, etc, you will need to compile with JS\n *\n * (templates alone do not have a way to import / define complex structures)\n */\nexport function compileHBS(template: string, options: CompileTemplateOptions = {}): CompileResult {\n let name = nameFor(template);\n let component: undefined | ComponentLike;\n let error: undefined | Error;\n\n try {\n component = setComponentTemplate(\n compileTemplate(template, { moduleName: options.moduleName || name, ...options }),\n templateOnlyComponent(options.moduleName || name)\n ) as ComponentLike;\n } catch (e) {\n error = e as Error | undefined;\n }\n\n return { name, component, error };\n}\n\ninterface CompileTemplateOptions {\n /**\n * Used for debug viewing\n */\n moduleName?: string;\n scope?: Record<string, unknown>;\n}\n\n/**\n * The reason why we can't use precompile directly is because of this:\n * https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/compiler/lib/compiler.ts#L132\n *\n * Support for dynamically compiling templates in strict mode doesn't seem to be fully their yet.\n * That JSON.stringify (and the lines after) prevent us from easily setting the scope function,\n * which means that *everything* is undefined.\n */\nfunction compileTemplate(source: string, { moduleName, scope = {} }: CompileTemplateOptions) {\n let localScope = { array, concat, fn, get, hash, on, ...scope } as any;\n let locals = getTemplateLocals(source);\n\n let options = {\n strictMode: true,\n moduleName,\n locals,\n isProduction: false,\n meta: { moduleName },\n };\n\n // Copied from @glimmer/compiler/lib/compiler#precompile\n let [block, usedLocals] = precompileJSON(source, options);\n\n let usedScope = usedLocals.map((key: string) => localScope[key]);\n\n let blockJSON = JSON.stringify(block);\n let templateJSONObject = {\n id: moduleName,\n block: blockJSON,\n moduleName: moduleName ?? '(unknown template module)',\n scope: () => usedScope,\n isStrictMode: true,\n };\n\n let factory = createTemplateFactory(templateJSONObject);\n\n return factory;\n}\n"],"names":["precompileJSON","importSync","getTemplateLocals","compileHBS","template","options","name","nameFor","component","error","setComponentTemplate","compileTemplate","moduleName","templateOnlyComponent","e","source","scope","localScope","array","concat","fn","get","hash","on","locals","strictMode","isProduction","meta","block","usedLocals","usedScope","map","key","blockJSON","JSON","stringify","templateJSONObject","id","isStrictMode","factory","createTemplateFactory"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AAeA;AACA;AACA,MAAM;AAAEA,EAAAA,cAAAA;AAAe,CAAC,GAAGC,UAAU,CAAC,mBAAmB,CAAQ,CAAA;AACjE,MAAM;AAAEC,EAAAA,iBAAAA;AAAkB,CAAC,GAAGD,UAAU,CAAC,iBAAiB,CAAQ,CAAA;;AAElE;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,UAAUA,CAACC,QAAgB,EAAEC,OAA+B,GAAG,EAAE,EAAiB;AAChG,EAAA,IAAIC,IAAI,GAAGC,OAAO,CAACH,QAAQ,CAAC,CAAA;AAC5B,EAAA,IAAII,SAAoC,CAAA;AACxC,EAAA,IAAIC,KAAwB,CAAA;EAE5B,IAAI;AACFD,IAAAA,SAAS,GAAGE,oBAAoB,CAC9BC,eAAe,CAACP,QAAQ,EAAE;AAAEQ,MAAAA,UAAU,EAAEP,OAAO,CAACO,UAAU,IA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,EAAEA,UAAU,IAAI,2BAA2B;IACrDI,KAAK,EAAEA,MAAMc,SAAS;AACtBQ,IAAAA,YAAY,EAAE,IAAA;GACf,CAAA;AAED,EAAA,IAAIC,OAAO,GAAGC,qBAAqB,CAACJ,kBAAkB,CAAC,CAAA;AAEvD,EAAA,OAAOG,OAAO,CAAA;AAChB;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"js.js","sources":["../../src/browser/js.ts"],"sourcesContent":["import { compileJS as compileAMD } from './cjs';\nimport { compileJS as compileESM } from './esm';\n\nimport type { CompileResult, ExtraModules, Options } from './types';\n\n/**\n * @public\n * Transpiles GlimmerJS (*.gjs) formatted text into and evaluates as a JS Module.\n * The returned component can be invoked explicitly in the consuming project.\n *\n * SEE: README for example usage\n *\n * @param {string} code: the code to be compiled\n * @param {Object} extraModules: map of import paths to modules. This isn't needed\n * for classic ember projects, but for strict static ember projects, extraModules\n * will need to be pasesd if compileJS is intended to be used in a styleguide or\n * if there are additional modules that could be imported in the passed `code`.\n *\n * Later on, imports that are not present by default (ember/glimmer) or that\n * are not provided by extraModules will be searched on npm to see if a package\n * needs to be downloaded before running the `code` / invoking the component\n */\nexport function compileJS(\n code: string,\n extraModules?: ExtraModules,\n options?: Options\n): Promise<CompileResult> {\n if (options?.skypack) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n // if (!(window as any).webpackChunkDummy) {\n // return {\n // component: undefined,\n // name: undefined,\n // error: `Your environment is using AMD utilities -- using native ESM is not allowed unless the environment is also ESM`,\n // };\n // }\n\n return compileESM(code, extraModules);\n }\n\n return compileAMD(code, extraModules);\n}\n"],"names":["compileJS","code","extraModules","options","skypack","compileESM","compileAMD"],"mappings":";;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,SAASA,CACvBC,IAAY,EACZC,YAA2B,EAC3BC,OAAiB,EACO;EACxB,IAAIA,OAAO,EAAEC,OAAO,EAAE;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAA,OAAOC,WAAU,CAACJ,IAAI,EAAEC,YAAY,CAAC,CAAA;AACvC,GAAA;AAEA,EAAA,OAAOI,WAAU,CAACL,IAAI,EAAEC,YAAY,CAAC,CAAA;AACvC;;;;"}
1
+ {"version":3,"file":"js.js","sources":["../../src/browser/js.ts"],"sourcesContent":["import { compileJS as compileAMD } from './cjs/index.ts';\nimport { compileJS as compileESM } from './esm/index.ts';\n\nimport type { CompileResult, ExtraModules, Options } from './types.ts';\n\n/**\n * @public\n * Transpiles GlimmerJS (*.gjs) formatted text into and evaluates as a JS Module.\n * The returned component can be invoked explicitly in the consuming project.\n *\n * SEE: README for example usage\n *\n * @param {string} code: the code to be compiled\n * @param {Object} extraModules: map of import paths to modules. This isn't needed\n * for classic ember projects, but for strict static ember projects, extraModules\n * will need to be pasesd if compileJS is intended to be used in a styleguide or\n * if there are additional modules that could be imported in the passed `code`.\n *\n * Later on, imports that are not present by default (ember/glimmer) or that\n * are not provided by extraModules will be searched on npm to see if a package\n * needs to be downloaded before running the `code` / invoking the component\n */\nexport function compileJS(\n code: string,\n extraModules?: ExtraModules,\n options?: Options\n): Promise<CompileResult> {\n if (options?.skypack) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n // if (!(window as any).webpackChunkDummy) {\n // return {\n // component: undefined,\n // name: undefined,\n // error: `Your environment is using AMD utilities -- using native ESM is not allowed unless the environment is also ESM`,\n // };\n // }\n\n return compileESM(code, extraModules);\n }\n\n return compileAMD(code, extraModules);\n}\n"],"names":["compileJS","code","extraModules","options","skypack","compileESM","compileAMD"],"mappings":";;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,SAASA,CACvBC,IAAY,EACZC,YAA2B,EAC3BC,OAAiB,EACO;EACxB,IAAIA,OAAO,EAAEC,OAAO,EAAE;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAA,OAAOC,WAAU,CAACJ,IAAI,EAAEC,YAAY,CAAC,CAAA;AACvC,GAAA;AAEA,EAAA,OAAOI,WAAU,CAACL,IAAI,EAAEC,YAAY,CAAC,CAAA;AACvC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/test-support/index.ts"],"sourcesContent":["import { CACHE } from '../browser/compile/index';\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;;;;"}
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/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "ember-repl",
3
- "version": "3.0.0-beta.4",
3
+ "version": "3.0.0-beta.6",
4
4
  "description": "Addon for enabling REPL and Playground creation with Ember/Glimmer",
5
5
  "keywords": [
6
6
  "ember-addon"
7
7
  ],
8
8
  "repository": {
9
- "type": "https",
10
- "url": "https://github.com/NullVoxPopuli/limber",
9
+ "type": "git",
10
+ "url": "https://github.com/NullVoxPopuli/limber.git",
11
11
  "directory": "packages/ember-repl/addon"
12
12
  },
13
13
  "license": "MIT",
@@ -15,63 +15,80 @@
15
15
  "typesVersions": {
16
16
  "*": {
17
17
  "test-support": [
18
- "dist/test-support/index.d.ts"
18
+ "declarations/test-support/index.d.ts"
19
19
  ],
20
20
  "markdown/parse": [
21
- "./dist/browser/compile/markdown-to-ember.d.ts"
21
+ "./declarations/browser/compile/markdown-to-ember.d.ts"
22
22
  ],
23
23
  "*": [
24
- "dist/browser/*",
25
- "dist/browser/*/index.d.ts"
24
+ "declarations/browser/*",
25
+ "declarations/browser/*/index.d.ts"
26
26
  ]
27
27
  }
28
28
  },
29
29
  "exports": {
30
- ".": "./dist/browser/index.js",
31
- "./esm": "./dist/browser/esm/index.js",
32
- "./markdown/parse": "./dist/browser/compile/markdown-to-ember.js",
30
+ ".": {
31
+ "types": "./declarations/browser/index.d.ts",
32
+ "default": "./dist/browser/index.js"
33
+ },
34
+ "./esm": {
35
+ "types": "./declarations/browser/esm/index.d.ts",
36
+ "default": "./dist/browser/esm/index.js"
37
+ },
38
+ "./markdown/parse": {
39
+ "types": "./declarations/browser/compile/markdown-to-ember.d.ts",
40
+ "default": "./dist/browser/compile/markdown-to-ember.js"
41
+ },
33
42
  "./ember-cli": {
34
43
  "require": "./src/build/ember-cli.cjs"
35
44
  },
36
- "./test-support": "./dist/test-support/index.js",
45
+ "./test-support": {
46
+ "types": "./declarations/test-support/index.d.ts",
47
+ "default": "./dist/test-support/index.js"
48
+ },
49
+ "./__PRIVATE__DO_NOT_USE__": {
50
+ "types": "./declarations/browser/__PRIVATE__.d.ts",
51
+ "default": "./dist/browser/__PRIVATE__.js"
52
+ },
37
53
  "./addon-main.js": "./addon-main.cjs"
38
54
  },
39
55
  "files": [
40
56
  "src",
41
57
  "dist",
58
+ "declarations",
42
59
  "addon-main.cjs"
43
60
  ],
44
61
  "dependencies": {
45
62
  "@babel/helper-plugin-utils": "^7.22.5",
46
- "@babel/standalone": "^7.22.5",
47
- "@embroider/addon-shim": "1.8.5",
48
- "@embroider/macros": "1.11.1",
49
- "babel-import-util": "^1.3.0",
50
- "babel-plugin-ember-template-compilation": "^2.0.3",
63
+ "@babel/standalone": "^7.22.14",
64
+ "@embroider/addon-shim": "1.8.6",
65
+ "@embroider/macros": "1.13.1",
66
+ "babel-import-util": "^1.4.1",
67
+ "babel-plugin-ember-template-compilation": "^2.2.0",
51
68
  "broccoli-file-creator": "^2.1.1",
52
69
  "change-case": "^4.1.2",
53
70
  "common-tags": "^1.8.2",
54
71
  "line-column": "^1.0.2",
55
- "magic-string": "^0.30.0",
72
+ "magic-string": "^0.30.3",
56
73
  "mdast": "^3.0.0",
57
74
  "parse-static-imports": "^1.1.0",
58
75
  "rehype-raw": "^6.1.1",
59
- "rehype-stringify": "^9.0.3",
76
+ "rehype-stringify": "^9.0.4",
60
77
  "remark-gfm": "^3.0.1",
61
78
  "remark-parse": "^10.0.2",
62
79
  "remark-rehype": "^10.1.0",
63
80
  "unified": "^10.1.2",
64
- "unist-util-visit": "^4.1.2",
81
+ "unist-util-visit": "^5.0.0",
65
82
  "uuid": "^9.0.0",
66
- "vfile": "^6.0.0"
83
+ "vfile": "^6.0.1"
67
84
  },
68
85
  "devDependencies": {
69
- "@babel/core": "^7.22.5",
70
- "@babel/preset-typescript": "^7.22.5",
71
- "@babel/types": "^7.22.5",
72
- "@ember/test-helpers": "^3.1.0",
86
+ "@babel/core": "^7.22.11",
87
+ "@babel/preset-typescript": "^7.22.11",
88
+ "@babel/types": "^7.22.11",
89
+ "@ember/test-helpers": "^3.2.0",
73
90
  "@ember/test-waiters": "^3.0.2",
74
- "@embroider/addon-dev": "3.1.1",
91
+ "@embroider/addon-dev": "4.1.0",
75
92
  "@glimmer/compiler": "^0.84.3",
76
93
  "@glimmer/component": "^1.1.2",
77
94
  "@glimmer/interfaces": "^0.84.3",
@@ -79,39 +96,39 @@
79
96
  "@glimmer/syntax": "^0.84.3",
80
97
  "@glimmer/tracking": "^1.1.2",
81
98
  "@glimmer/util": "^0.84.3",
82
- "@glint/core": "^1.0.2",
83
- "@glint/environment-ember-loose": "^1.0.2",
84
- "@glint/environment-ember-template-imports": "^1.0.2",
85
- "@glint/template": "^1.0.2",
86
- "@nullvoxpopuli/eslint-configs": "^3.1.3",
87
- "@rollup/plugin-commonjs": "^25.0.2",
88
- "@tsconfig/ember": "^2.0.0",
89
- "@types/babel__core": "^7.20.0",
99
+ "@glint/core": "^1.1.0",
100
+ "@glint/environment-ember-loose": "^1.1.0",
101
+ "@glint/environment-ember-template-imports": "^1.1.0",
102
+ "@glint/template": "^1.1.0",
103
+ "@nullvoxpopuli/eslint-configs": "^3.2.2",
104
+ "@rollup/plugin-babel": "^6.0.3",
105
+ "@rollup/plugin-commonjs": "^25.0.4",
106
+ "@tsconfig/ember": "^3.0.0",
107
+ "@types/babel__core": "^7.20.1",
90
108
  "@types/babel__standalone": "^7.1.4",
91
- "@types/babel__traverse": "^7.18.5",
92
- "@types/hast": "^2.3.4",
93
- "@types/mdast": "^3.0.11",
94
- "@types/unist": "^2.0.6",
95
- "@types/uuid": "^9.0.1",
96
- "@typescript-eslint/eslint-plugin": "^5.59.11",
97
- "@typescript-eslint/parser": "^5.59.11",
98
- "concurrently": "^8.2.0",
99
- "ember-resources": "^6.1.0",
100
- "ember-source": "^5.0.0",
109
+ "@types/babel__traverse": "^7.20.1",
110
+ "@types/hast": "^3.0.0",
111
+ "@types/mdast": "^4.0.0",
112
+ "@types/unist": "^3.0.0",
113
+ "@types/uuid": "^9.0.3",
114
+ "@typescript-eslint/eslint-plugin": "^6.5.0",
115
+ "@typescript-eslint/parser": "^6.5.0",
116
+ "concurrently": "^8.2.1",
117
+ "ember-resources": "^6.4.0",
118
+ "ember-source": "^5.2.0",
101
119
  "ember-template-imports": "^3.4.2",
102
- "ember-template-lint": "^5.10.3",
103
- "eslint": "^8.43.0",
104
- "eslint-plugin-ember": "^11.8.0",
120
+ "ember-template-lint": "^5.11.2",
121
+ "eslint": "^8.48.0",
122
+ "eslint-plugin-ember": "^11.11.1",
105
123
  "eslint-plugin-node": "^11.1.0",
106
- "eslint-plugin-prettier": "^4.2.1",
107
- "prettier": "^2.8.8",
108
- "prettier-plugin-ember-template-tag": "^0.3.2",
109
- "publint": "^0.1.12",
110
- "rollup": "~3.25.1",
124
+ "eslint-plugin-prettier": "^5.0.0",
125
+ "prettier": "^3.0.3",
126
+ "prettier-plugin-ember-template-tag": "^1.0.2",
127
+ "publint": "^0.2.2",
128
+ "rollup": "~3.28.1",
111
129
  "rollup-plugin-copy": "^3.4.0",
112
130
  "rollup-plugin-glimmer-template-tag": "^0.4.1",
113
- "rollup-plugin-ts": "^3.2.0",
114
- "typescript": "^5.0.4",
131
+ "typescript": "^5.2.2",
115
132
  "@nullvoxpopuli/limber-untyped": "0.0.0"
116
133
  },
117
134
  "volta": {
@@ -130,13 +147,20 @@
130
147
  "@glimmer/compiler": "^0.84.3",
131
148
  "@glimmer/component": "^1.1.2",
132
149
  "@glimmer/syntax": "^0.84.3",
133
- "@glint/template": "^1.0.2",
134
- "ember-resources": "^6.1.0",
135
- "ember-source": "^5.0.0"
150
+ "@glint/template": "^1.1.0",
151
+ "ember-resources": "^6.4.0",
152
+ "ember-source": "^5.2.0"
153
+ },
154
+ "engines": {
155
+ "node": ">= v16",
156
+ "npm": "use pnpm",
157
+ "yarn": "use pnpm"
136
158
  },
137
159
  "scripts": {
138
- "build": "rollup --config",
139
- "lint:types": "glint",
160
+ "build": "concurrently 'npm:build:*'",
161
+ "build:js": "rollup --config",
162
+ "build:types": "tsc --emitDeclarationOnly --noEmit false",
163
+ "lint:types": "tsc --noEmit",
140
164
  "lint:fix": "pnpm -w exec lint fix",
141
165
  "start": "rollup --config --watch",
142
166
  "lint": "pnpm -w exec lint",
@@ -0,0 +1 @@
1
+ export { CACHE } from './compile/index.ts';
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/no-unused-vars */
2
- import { modules } from '../known-modules';
2
+ import { modules } from '../known-modules.ts';
3
3
 
4
- import type { ExtraModules } from '../types';
4
+ import type { ExtraModules } from '../types.ts';
5
5
  import type Component from '@glimmer/component';
6
6
 
7
7
  export function evalSnippet(
@@ -1,8 +1,8 @@
1
- import { preprocess, transform } from '../gjs';
2
- import { nameFor } from '../utils';
3
- import { evalSnippet } from './eval';
1
+ import { preprocess, transform } from '../gjs.ts';
2
+ import { nameFor } from '../utils.ts';
3
+ import { evalSnippet } from './eval.ts';
4
4
 
5
- import type { CompileResult, ExtraModules } from '../types';
5
+ import type { CompileResult, ExtraModules } from '../types.ts';
6
6
  import type { ComponentLike } from '@glint/template';
7
7
 
8
8
  export interface Info {
@@ -1,8 +1,9 @@
1
- import { invocationName } from '../utils';
1
+ import { invocationName } from '../utils.ts';
2
2
 
3
- import type { CompileResult } from '../types';
4
- import type { ExtractedCode } from './markdown-to-ember';
5
- import type { EvalImportMap, ScopeMap } from './types';
3
+ import type { CompileResult } from '../types.ts';
4
+ import type { ExtractedCode } from './markdown-to-ember.ts';
5
+ import type { UnifiedPlugin } from './types.ts';
6
+ import type { EvalImportMap, ScopeMap } from './types.ts';
6
7
 
7
8
  async function compileAll(js: { code: string }[], importMap?: EvalImportMap) {
8
9
  let modules = await Promise.all(
@@ -19,7 +20,7 @@ export async function compileGJS(
19
20
  importMap?: EvalImportMap
20
21
  ): Promise<CompileResult> {
21
22
  try {
22
- let { compileJS } = await import('../js');
23
+ let { compileJS } = await import('../js.ts');
23
24
 
24
25
  return await compileJS(gjsInput, importMap);
25
26
  } catch (error) {
@@ -35,7 +36,7 @@ export async function compileHBS(
35
36
  }
36
37
  ): Promise<CompileResult> {
37
38
  try {
38
- let { compileHBS } = await import('../hbs');
39
+ let { compileHBS } = await import('../hbs.ts');
39
40
 
40
41
  return compileHBS(hbsInput, options);
41
42
  } catch (error) {
@@ -86,6 +87,7 @@ export async function compileMD(
86
87
  options?: {
87
88
  importMap?: EvalImportMap;
88
89
  topLevelScope?: ScopeMap;
90
+ remarkPlugins?: UnifiedPlugin[];
89
91
  CopyComponent?: string;
90
92
  ShadowComponent?: string;
91
93
  }
@@ -106,10 +108,11 @@ export async function compileMD(
106
108
  * compiled rootTemplate can invoke them
107
109
  */
108
110
  try {
109
- let { parseMarkdown } = await import('./markdown-to-ember');
111
+ let { parseMarkdown } = await import('./markdown-to-ember.ts');
110
112
  let { templateOnlyGlimdown, blocks } = await parseMarkdown(glimdownInput, {
111
113
  CopyComponent: options?.CopyComponent,
112
114
  ShadowComponent: options?.ShadowComponent,
115
+ remarkPlugins: options?.remarkPlugins,
113
116
  });
114
117
 
115
118
  rootTemplate = templateOnlyGlimdown;
@@ -151,11 +154,14 @@ export async function compileMD(
151
154
  * Step 4: Compile the Ember Template
152
155
  */
153
156
  try {
154
- let localScope = scope.reduce((accum, { component, name }) => {
155
- accum[invocationName(name)] = component;
157
+ let localScope = scope.reduce(
158
+ (accum, { component, name }) => {
159
+ accum[invocationName(name)] = component;
156
160
 
157
- return accum;
158
- }, {} as Record<string, unknown>);
161
+ return accum;
162
+ },
163
+ {} as Record<string, unknown>
164
+ );
159
165
 
160
166
  return await compileHBS(rootTemplate, {
161
167
  moduleName: 'DynamicRootTemplate',