ember-vite-hmr 1.4.17 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -29,6 +29,19 @@ plugins: [
29
29
  ]
30
30
  ```
31
31
 
32
+ update you `babel.config.cjs`
33
+
34
+ ```js
35
+ const { hotAstProcessor } = require('ember-vite-hmr/lib/babel-plugin');
36
+ plugins: [['ember-vite-hmr/lib/babel-plugin'], ...other];
37
+ ```
38
+
39
+ and for `'babel-plugin-ember-template-compilation'`
40
+
41
+ ```js
42
+ transforms: [hotAstProcessor.transform, ...templateCompatSupport()],
43
+ ```
44
+
32
45
  ## Contributing
33
46
 
34
47
  See the [Contributing](CONTRIBUTING.md) guide for details.
package/addon-main.cjs CHANGED
@@ -1,48 +1,4 @@
1
1
  'use strict';
2
2
 
3
3
  const { addonV1Shim } = require('@embroider/addon-shim');
4
- const path = require('path');
5
4
  module.exports = addonV1Shim(__dirname);
6
- const included = module.exports.included;
7
-
8
- Object.assign(module.exports, {
9
- _getBabelOptions() {
10
- const parentOptions = this.parent && this.parent.options;
11
- const appOptions = this.app && this.app.options;
12
- const addonOptions = parentOptions || appOptions || {};
13
-
14
- addonOptions.babel = addonOptions.babel || {};
15
- addonOptions.babel.plugins = addonOptions.babel.plugins || [];
16
- return addonOptions.babel;
17
- },
18
- included(...args) {
19
- this._getBabelOptions().plugins.push([
20
- require.resolve('./dist/lib/babel-plugin.js'),
21
- { v: 4, appName: this.app.name },
22
- ]);
23
- this._super.included; // need to access this somehow? otherwise it fails later on...
24
-
25
- let astPlugin = this._buildPlugin();
26
- astPlugin.parallelBabel = {
27
- requireFile: __filename,
28
- buildUsing: '_buildPlugin',
29
- params: {},
30
- };
31
- const compatAppBuilder = require.resolve(
32
- '@embroider/compat/src/compat-app-builder',
33
- { paths: [process.cwd()] },
34
- );
35
- const CompatAppBuilder = require(compatAppBuilder).CompatAppBuilder;
36
- const etcOptions = CompatAppBuilder.prototype.etcOptions;
37
- CompatAppBuilder.prototype.etcOptions = async function (...args) {
38
- const opts = await etcOptions.call(this, ...args);
39
- opts.transforms.push(astPlugin);
40
- return opts;
41
- };
42
- included.call(this, ...args);
43
- },
44
-
45
- _buildPlugin() {
46
- return require('./dist/lib/babel-plugin').hotAstProcessor.transform;
47
- },
48
- });
@@ -0,0 +1 @@
1
+ export { default } from "ember-vite-hmr/instance-initializers/setup-hmr-manager";
@@ -0,0 +1,82 @@
1
+ import Route from '@ember/routing/route';
2
+ import Component from '@glimmer/component';
3
+ import { getInternalComponentManager } from '@glimmer/manager';
4
+ import '@glimmer/tracking';
5
+ import '@glimmer/reference';
6
+ import '@glimmer/runtime';
7
+
8
+ function findPropertyDescriptor(component, key) {
9
+ let proto = component;
10
+ while (proto) {
11
+ const desc = Object.getOwnPropertyDescriptor(proto, key);
12
+ if (desc) return desc;
13
+ proto = Object.getPrototypeOf(proto);
14
+ }
15
+ }
16
+ function getState(component, skip) {
17
+ const state = {};
18
+ if (!component) {
19
+ return state;
20
+ }
21
+ for (const key in component) {
22
+ if (skip.includes(key)) continue;
23
+ const entry = findPropertyDescriptor(component, key);
24
+ if (entry) {
25
+ if (entry.writable && !Object.prototype.toString.call(entry.value).includes('Function')) {
26
+ state[key] = component[key];
27
+ }
28
+ if (entry.set) {
29
+ state[key] = component[key];
30
+ }
31
+ }
32
+ }
33
+ return state;
34
+ }
35
+ function syncState(instance) {
36
+ if (instance.args.__hot__) {
37
+ const state = instance.__get_hot_state__?.() || instance.args.__hot__.getState?.();
38
+ for (const k in state) {
39
+ instance[k] = state[k];
40
+ }
41
+ instance.args.__hot__.getState = () => getState(instance, ['args']);
42
+ }
43
+ }
44
+ function initialize() {
45
+ const ComponentManager = getInternalComponentManager(Component);
46
+ const proto = Object.getPrototypeOf(ComponentManager);
47
+ const create = proto.create;
48
+ proto.create = function (...args) {
49
+ const instance = create.call(this, ...args);
50
+ syncState(instance.component);
51
+ return instance;
52
+ };
53
+ const setupController = Route.prototype.setupController;
54
+ const StateCache = {};
55
+ Route.prototype.setupController = function (...args) {
56
+ const controller = args[0];
57
+ // @ts-ignore
58
+ const r = setupController.call(this, ...args);
59
+ const fullRouteName = this.fullRouteName;
60
+ const state = StateCache[fullRouteName] || {};
61
+ const skip = ['_qpDelegate', 'target', 'queryParams'];
62
+ const routerState = getState(state.router, skip);
63
+ const controllerState = getState(state.controller, skip);
64
+ for (const k in routerState) {
65
+ this[k] = routerState[k];
66
+ }
67
+ for (const k in controllerState) {
68
+ controller[k] = controllerState[k];
69
+ }
70
+ StateCache[fullRouteName] = {
71
+ route: this,
72
+ controller
73
+ };
74
+ return r;
75
+ };
76
+ }
77
+ var setupHmrManager = {
78
+ initialize
79
+ };
80
+
81
+ export { setupHmrManager as default, initialize };
82
+ //# sourceMappingURL=setup-hmr-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-hmr-manager.js","sources":["../../src/instance-initializers/setup-hmr-manager.ts"],"sourcesContent":["import Route from '@ember/routing/route';\nimport Controller from '@ember/controller';\nimport Component from '@glimmer/component';\n// @ts-ignore\nimport { getInternalComponentManager } from '@glimmer/manager';\n\n// vite dep optimizer is currently broken and cannot optimize new deps, need to include this ones from start\nimport { tracked } from '@glimmer/tracking';\n// @ts-ignore\nimport { createComputeRef } from '@glimmer/reference';\n// @ts-ignore\nimport { curry } from '@glimmer/runtime';\n\n(function () {\n let run = false;\n if (run) {\n console.log(tracked, createComputeRef, curry);\n }\n})();\n\ninterface HotComponent extends Component<{ __hot__?: any }> {\n __get_hot_state__?: () => Record<string, any>;\n}\n\ntype Mutable<T> = {\n -readonly [P in keyof T]: any;\n};\n\nfunction findPropertyDescriptor(component: Object, key: string) {\n let proto = component;\n while (proto) {\n const desc = Object.getOwnPropertyDescriptor(proto, key);\n if (desc) return desc;\n proto = Object.getPrototypeOf(proto);\n }\n}\n\nfunction getState(component: HotComponent, skip: string[]) {\n const state: Record<string, any> = {};\n if (!component) {\n return state;\n }\n for (const key in component) {\n if (skip.includes(key)) continue;\n const entry = findPropertyDescriptor(component, key);\n if (entry) {\n if (\n entry.writable &&\n !Object.prototype.toString.call(entry.value).includes('Function')\n ) {\n state[key] = component[key as keyof Component];\n }\n if (entry.set) {\n state[key] = component[key as keyof Component];\n }\n }\n }\n return state;\n}\n\nfunction syncState(instance: Mutable<HotComponent>) {\n if (instance.args.__hot__) {\n const state =\n instance.__get_hot_state__?.() || instance.args.__hot__.getState?.();\n for (const k in state) {\n instance[k as keyof HotComponent] = state[k];\n }\n instance.args.__hot__.getState = () => getState(instance, ['args']);\n }\n}\n\nexport function initialize() {\n const ComponentManager = getInternalComponentManager(Component);\n const proto = Object.getPrototypeOf(ComponentManager);\n const create = proto.create;\n proto.create = function (...args: any[]) {\n const instance = create.call(this, ...args);\n syncState(instance.component);\n return instance;\n };\n\n const setupController = Route.prototype.setupController;\n\n const StateCache: Record<string, any> = {};\n\n Route.prototype.setupController = function (...args: any[]) {\n const controller = args[0];\n // @ts-ignore\n const r = setupController.call(this, ...args);\n const fullRouteName = this.fullRouteName;\n const state = StateCache[fullRouteName] || {};\n const skip = ['_qpDelegate', 'target', 'queryParams'];\n const routerState = getState(state.router, skip);\n const controllerState = getState(state.controller, skip);\n for (const k in routerState) {\n (this as any)[k] = routerState[k];\n }\n for (const k in controllerState) {\n controller[k] = controllerState[k];\n }\n StateCache[fullRouteName] = {\n route: this,\n controller,\n };\n return r;\n };\n}\n\nexport default {\n initialize,\n};\n"],"names":["findPropertyDescriptor","component","key","proto","desc","Object","getOwnPropertyDescriptor","getPrototypeOf","getState","skip","state","includes","entry","writable","prototype","toString","call","value","set","syncState","instance","args","__hot__","__get_hot_state__","k","initialize","ComponentManager","getInternalComponentManager","Component","create","setupController","Route","StateCache","controller","r","fullRouteName","routerState","router","controllerState","route"],"mappings":";;;;;;;AA4BA,SAASA,sBAAsBA,CAACC,SAAiB,EAAEC,GAAW,EAAE;EAC9D,IAAIC,KAAK,GAAGF,SAAS,CAAA;AACrB,EAAA,OA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A;IACxC,MAAMzB,KAAK,GAAGsB,UAAU,CAACG,aAAa,CAAC,IAAI,EAAE,CAAA;IAC7C,MAAM1B,IAAI,GAAG,CAAC,aAAa,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAA;IACrD,MAAM2B,WAAW,GAAG5B,QAAQ,CAACE,KAAK,CAAC2B,MAAM,EAAE5B,IAAI,CAAC,CAAA;IAChD,MAAM6B,eAAe,GAAG9B,QAAQ,CAACE,KAAK,CAACuB,UAAU,EAAExB,IAAI,CAAC,CAAA;AACxD,IAAA,KAAK,MAAMe,CAAC,IAAIY,WAAW,EAAE;AAC1B,MAAA,IAAI,CAASZ,CAAC,CAAC,GAAGY,WAAW,CAACZ,CAAC,CAAC,CAAA;AACnC,KAAA;AACA,IAAA,KAAK,MAAMA,CAAC,IAAIc,eAAe,EAAE;AAC/BL,MAAAA,UAAU,CAACT,CAAC,CAAC,GAAGc,eAAe,CAACd,CAAC,CAAC,CAAA;AACpC,KAAA;IACAQ,UAAU,CAACG,aAAa,CAAC,GAAG;AAC1BI,MAAAA,KAAK,EAAE,IAAI;AACXN,MAAAA,UAAAA;KACD,CAAA;AACD,IAAA,OAAOC,CAAC,CAAA;GACT,CAAA;AACH,CAAA;AAEA,sBAAe;AACbT,EAAAA,UAAAA;AACF,CAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"vite-hot-reload.js","sources":["../../src/instance-initializers/vite-hot-reload.ts"],"sourcesContent":["import ApplicationInstance from '@ember/application/instance';\nimport { debounce, next } from '@ember/runloop';\nimport RouterService from '@ember/routing/router-service';\nimport { Renderer } from '@ember/-internals/glimmer/lib/renderer';\n\n\nfunction patchResolver(application: ApplicationInstance) {\n application.__container__.lookup('service:vite-hot-reload');\n const resolver =\n (application.__registry__.resolver as any)?._fallback ||\n (application.__registry__.fallback?.resolver as any)._fallback ||\n (application.__registry__.fallback?.resolver as any) ||\n application.__registry__.resolver;\n const resolverResolve = resolver.resolve;\n resolver.resolve = function (name: string) {\n name = name.replace(/--hot-version--.*$/, '');\n return resolverResolve.call(this, name);\n };\n}\n\n\nfunction supportErrorRecovery(appInstance: ApplicationInstance) {\n const bodyHtml = window.document.body.cloneNode(true);\n const renderer = appInstance.__container__.lookup('renderer:-dom') as Renderer;\n const router = appInstance.__container__.lookup('service:router') as RouterService;\n const warn = console.warn;\n let scheduleRerender = false;\n async function rerender() {\n if (!scheduleRerender) return;\n scheduleRerender = false;\n const applicationRouter = appInstance.__container__.lookup('route:application') as any;\n applicationRouter._router._toplevelView.destroy();\n applicationRouter._router._toplevelView = null;\n renderer._clearAllRoots();\n window.document.body = bodyHtml.cloneNode(true) as any;\n next(() => {\n const transition = router.refresh();\n applicationRouter.setup(applicationRouter.context, transition);\n });\n }\n import.meta.hot?.on('vite:beforeUpdate', () => debounce(rerender, 100));\n console.warn = function (...args) {\n if (args[0].includes('Attempted to rerender, but the Ember application has had an unrecoverable error occur during render. You should reload the application after fixing the cause of the error.')) {\n scheduleRerender = true;\n }\n warn.call(console, ...args);\n }\n}\n\nexport function initialize(application: ApplicationInstance) {\n patchResolver(application);\n supportErrorRecovery(application);\n}\n\nexport default {\n initialize,\n};\n"],"names":["patchResolver","application","__container__","lookup","resolver","__registry__","_fallback","fallback","resolverResolve","resolve","name","replace","call","supportErrorRecovery","appInstance","bodyHtml","window","document","body","cloneNode","renderer","router","warn","console","scheduleRerender","rerender","applicationRouter","_router","_toplevelView","destroy","_clearAllRoots","next","transition","refresh","setup","context","import","meta","hot","on","debounce","args","includes","initialize"],"mappings":";;AAMA,SAASA,aAAaA,CAACC,WAAgC,EAAE;AACvDA,EAAAA,WAAW,CAACC,aAAa,CAACC,MAAM,CAAC,yBAAyB,CAAC,CAAA;AAC3D,EAAA,MAAMC,QAAQ,GACTH,WAAW,CAACI,YAAY,CAACD,QAAQ,EAAUE,SAAS,IACrD,CAACL,WAAW,CAACI,YAAY,CAACE,QAAQ,EAAEH,QAAQ,EAASE,SAAS,IAC7DL,WAAW,CAACI,YAAY,CAACE,Q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,IAAAA,IAAI,CAAC,MAAM;AACT,MAAA,MAAMC,UAAU,GAAGX,MAAM,CAACY,OAAO,EAAE,CAAA;MACnCP,iBAAiB,CAACQ,KAAK,CAACR,iBAAiB,CAACS,OAAO,EAAEH,UAAU,CAAC,CAAA;AAChE,KAAC,CAAC,CAAA;AACJ,GAAA;AACAI,EAAAA,MAAM,CAACC,IAAI,CAACC,GAAG,EAAEC,EAAE,CAAC,mBAAmB,EAAE,MAAMC,QAAQ,CAACf,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAA;AACvEF,EAAAA,OAAO,CAACD,IAAI,GAAI,UAAU,GAAGmB,IAAI,EAAE;IACjC,IAAIA,IAAI,CAAC,CAAC,CAAC,CAACC,QAAQ,CAAC,6KAA6K,CAAC,EAAE;AACnMlB,MAAAA,gBAAgB,GAAG,IAAI,CAAA;AACzB,KAAA;AACAF,IAAAA,IAAI,CAACV,IAAI,CAACW,OAAO,EAAE,GAAGkB,IAAI,CAAC,CAAA;GAC5B,CAAA;AACH,CAAA;AAEO,SAASE,UAAUA,CAAC1C,WAAgC,EAAE;EAC3DD,aAAa,CAACC,WAAW,CAAC,CAAA;EAC1BY,oBAAoB,CAACZ,WAAW,CAAC,CAAA;AACnC,CAAA;AAEA,oBAAe;AACb0C,EAAAA,UAAAA;AACF,CAAC;;;;"}
1
+ {"version":3,"file":"vite-hot-reload.js","sources":["../../src/instance-initializers/vite-hot-reload.ts"],"sourcesContent":["import ApplicationInstance from '@ember/application/instance';\nimport { debounce, next } from '@ember/runloop';\nimport RouterService from '@ember/routing/router-service';\nimport { Renderer } from '@ember/-internals/glimmer/lib/renderer';\n\nfunction patchResolver(application: ApplicationInstance) {\n application.__container__.lookup('service:vite-hot-reload');\n const resolver =\n (application.__registry__.resolver as any)?._fallback ||\n (application.__registry__.fallback?.resolver as any)._fallback ||\n (application.__registry__.fallback?.resolver as any) ||\n application.__registry__.resolver;\n const resolverResolve = resolver.resolve;\n resolver.resolve = function (name: string) {\n name = name.replace(/--hot-version--.*$/, '');\n return resolverResolve.call(this, name);\n };\n}\n\nfunction supportErrorRecovery(appInstance: ApplicationInstance) {\n const bodyHtml = window.document.body.cloneNode(true);\n const renderer = appInstance.__container__.lookup(\n 'renderer:-dom',\n ) as Renderer;\n const router = appInstance.__container__.lookup(\n 'service:router',\n ) as RouterService;\n const warn = console.warn;\n let scheduleRerender = false;\n async function rerender() {\n if (!scheduleRerender) return;\n scheduleRerender = false;\n const applicationRouter = appInstance.__container__.lookup(\n 'route:application',\n ) as any;\n applicationRouter._router._toplevelView.destroy();\n applicationRouter._router._toplevelView = null;\n renderer._clearAllRoots();\n window.document.body = bodyHtml.cloneNode(true) as any;\n next(() => {\n const transition = router.refresh();\n applicationRouter.setup(applicationRouter.context, transition);\n });\n }\n import.meta.hot?.on('vite:beforeUpdate', () => debounce(rerender, 100));\n console.warn = function (...args) {\n if (\n args[0].includes(\n 'Attempted to rerender, but the Ember application has had an unrecoverable error occur during render. You should reload the application after fixing the cause of the error.',\n )\n ) {\n scheduleRerender = true;\n }\n warn.call(console, ...args);\n };\n}\n\nexport function initialize(application: ApplicationInstance) {\n patchResolver(application);\n supportErrorRecovery(application);\n}\n\nexport default {\n initialize,\n};\n"],"names":["patchResolver","application","__container__","lookup","resolver","__registry__","_fallback","fallback","resolverResolve","resolve","name","replace","call","supportErrorRecovery","appInstance","bodyHtml","window","document","body","cloneNode","renderer","router","warn","console","scheduleRerender","rerender","applicationRouter","_router","_toplevelView","destroy","_clearAllRoots","next","transition","refresh","setup","context","import","meta","hot","on","debounce","args","includes","initialize"],"mappings":";;AAKA,SAASA,aAAaA,CAACC,WAAgC,EAAE;AACvDA,EAAAA,WAAW,CAACC,aAAa,CAACC,MAAM,CAAC,yBAAyB,CAAC,CAAA;AAC3D,EAAA,MAAMC,QAAQ,GACXH,WAAW,CAACI,YAAY,CAACD,QAAQ,EAAUE,SAAS,IACrD,CAACL,WAAW,CAACI,YAAY,CAACE,QAAQ,EAAEH,QAAQ,EAASE,SA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AAC,IAAI,CAAQ,CAAA;AACtDY,IAAAA,IAAI,CAAC,MAAM;AACT,MAAA,MAAMC,UAAU,GAAGX,MAAM,CAACY,OAAO,EAAE,CAAA;MACnCP,iBAAiB,CAACQ,KAAK,CAACR,iBAAiB,CAACS,OAAO,EAAEH,UAAU,CAAC,CAAA;AAChE,KAAC,CAAC,CAAA;AACJ,GAAA;AACAI,EAAAA,MAAM,CAACC,IAAI,CAACC,GAAG,EAAEC,EAAE,CAAC,mBAAmB,EAAE,MAAMC,QAAQ,CAACf,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAA;AACvEF,EAAAA,OAAO,CAACD,IAAI,GAAG,UAAU,GAAGmB,IAAI,EAAE;IAChC,IACEA,IAAI,CAAC,CAAC,CAAC,CAACC,QAAQ,CACd,6KACF,CAAC,EACD;AACAlB,MAAAA,gBAAgB,GAAG,IAAI,CAAA;AACzB,KAAA;AACAF,IAAAA,IAAI,CAACV,IAAI,CAACW,OAAO,EAAE,GAAGkB,IAAI,CAAC,CAAA;GAC5B,CAAA;AACH,CAAA;AAEO,SAASE,UAAUA,CAAC1C,WAAgC,EAAE;EAC3DD,aAAa,CAACC,WAAW,CAAC,CAAA;EAC1BY,oBAAoB,CAACZ,WAAW,CAAC,CAAA;AACnC,CAAA;AAEA,oBAAe;AACb0C,EAAAA,UAAAA;AACF,CAAC;;;;"}
@@ -21,7 +21,7 @@ declare class HotAstProcessor {
21
21
  constructor();
22
22
  reset(): void;
23
23
  transform(env: ASTPluginEnvironment): any;
24
- buildVisitor({ importVar, importBindings, babelProgram }: {
24
+ buildVisitor({ importVar, importBindings, babelProgram, }: {
25
25
  importVar: string;
26
26
  importBindings: Set<string>;
27
27
  babelProgram: Program;
@@ -101,26 +101,31 @@ class HotAstProcessor {
101
101
  transform(env) {
102
102
  if (process.env['EMBER_VITE_HMR_ENABLED'] !== 'true') {
103
103
  return {
104
- visitor: {}
104
+ visitor: {},
105
105
  };
106
106
  }
107
107
  const meta = this.meta;
108
- const importVar = meta.importVar || env.meta.jsutils.bindExpression('null', null, { nameHint: 'template__imports__' });
108
+ const importVar = meta.importVar ||
109
+ env.meta.jsutils.bindExpression('null', null, {
110
+ nameHint: 'template__imports__',
111
+ });
109
112
  meta.importVar = importVar;
110
113
  const findImport = function findImport(specifier) {
111
- return meta.babelProgram.body.find(b => b.type === 'ImportDeclaration' && b.specifiers.some(s => s.local.name === specifier));
114
+ return meta.babelProgram.body.find((b) => b.type === 'ImportDeclaration' &&
115
+ b.specifiers.some((s) => s.local.name === specifier));
112
116
  };
113
117
  return {
114
118
  visitor: Object.assign({}, this.buildVisitor({
115
119
  importVar,
116
120
  importBindings: meta.importBindings,
117
- babelProgram: meta.babelProgram
121
+ babelProgram: meta.babelProgram,
118
122
  })),
119
123
  };
120
124
  }
121
- buildVisitor({ importVar, importBindings, babelProgram }) {
125
+ buildVisitor({ importVar, importBindings, babelProgram, }) {
122
126
  const findImport = function findImport(specifier) {
123
- return babelProgram.body.find(b => b.type === 'ImportDeclaration' && b.specifiers.some(s => s.local.name === specifier));
127
+ return babelProgram.body.find((b) => b.type === 'ImportDeclaration' &&
128
+ b.specifiers.some((s) => s.local.name === specifier));
124
129
  };
125
130
  const findBlockParams = function (expression, p) {
126
131
  if (p.node.type === 'Template') {
@@ -161,14 +166,14 @@ class HotAstProcessor {
161
166
  if (node.original === 'helper' ||
162
167
  node.original === 'component' ||
163
168
  node.original === 'modifier') {
164
- (node.original);
169
+ node.original;
165
170
  const parent = p.parentNode;
166
- if (typeof parent.params[0].original !== 'string') {
171
+ if (typeof parent.params[0].original !==
172
+ 'string') {
167
173
  return;
168
174
  }
169
175
  const original = parent.params[0].original.split('.')[0];
170
- if (original &&
171
- findBlockParams(original, p))
176
+ if (original && findBlockParams(original, p))
172
177
  return;
173
178
  if (original === null || original === void 0 ? void 0 : original.includes('.'))
174
179
  return;
@@ -228,20 +233,26 @@ function hotReplaceAst({ types: t }) {
228
233
  }
229
234
  const util = new babel_import_util_1.ImportUtil(t, path);
230
235
  const tracked = util.import(path, '@glimmer/tracking', 'tracked');
236
+ const GlimmerComponent = util.import(path, '@glimmer/component', 'default');
231
237
  const klass = t.classExpression(path.scope.generateUidIdentifier('Imports'), null, t.classBody([]));
232
238
  const bindings = [...exports.hotAstProcessor.meta.importBindings].sort();
233
239
  for (const local of bindings) {
234
- klass.body.body.push(t.classProperty(t.identifier(local), t.identifier(local), null, [t.decorator(tracked)]));
240
+ klass.body.body.push(t.classProperty(t.identifier(local), t.identifier(local), null, [
241
+ t.decorator(tracked),
242
+ ]));
235
243
  }
236
244
  const newExp = t.newExpression(klass, []);
237
245
  const assign = t.assignmentExpression('=', t.identifier(exports.hotAstProcessor.meta.importVar), newExp);
238
- const varDeclaration = path.node.body.findIndex((e) => e.type === 'VariableDeclaration' && e.declarations[0].id.name === exports.hotAstProcessor.meta.importVar) + 1;
246
+ const varDeclaration = path.node.body.findIndex((e) => e.type === 'VariableDeclaration' &&
247
+ e.declarations[0].id.name ===
248
+ exports.hotAstProcessor.meta.importVar) + 1;
239
249
  const lastImportIndex = path.node.body.findLastIndex((e) => e.type === 'ImportDeclaration') + 1;
240
250
  path.node.body.splice(Math.max(varDeclaration, lastImportIndex), 0, assign);
241
251
  const findImport = function findImport(specifier) {
242
- return path.node.body.find(b => b.type === 'ImportDeclaration' && b.specifiers.some(s => s.local.name === specifier));
252
+ return path.node.body.find((b) => b.type === 'ImportDeclaration' &&
253
+ b.specifiers.some((s) => s.local.name === specifier));
243
254
  };
244
- const hotAccepts = [];
255
+ const ifHotStatements = [];
245
256
  for (const imp of bindings) {
246
257
  const importDeclaration = findImport(imp);
247
258
  const source = importDeclaration.source.value;
@@ -249,14 +260,21 @@ function hotReplaceAst({ types: t }) {
249
260
  const specifierName = ((_a = specifier.imported) === null || _a === void 0 ? void 0 : _a.name) ||
250
261
  ((_b = specifier.imported) === null || _b === void 0 ? void 0 : _b.value) ||
251
262
  'default';
252
- const ast = (0, core_1.parse)(`import.meta.hot.accept('${source}', (module) => (${exports.hotAstProcessor.meta.importVar}.${imp}=module['${specifierName}']))`);
253
- const impHot = ast === null || ast === void 0 ? void 0 : ast.program.body[0];
254
- hotAccepts.push(impHot);
263
+ const ast = (0, core_1.parse)(`
264
+ (async () => {
265
+ const c = await import('ember-vite-hmr/virtual/component:${source}:${specifierName}.gjs');
266
+ ${exports.hotAstProcessor.meta.importVar}.${imp} = c.default;
267
+ })()
268
+ import.meta.hot.accept('${source}');
269
+ `);
270
+ const importVirtual = ast === null || ast === void 0 ? void 0 : ast.program.body;
271
+ const ifInstanceOfComponent = t.ifStatement(t.binaryExpression('instanceof', t.memberExpression(t.identifier(imp), t.identifier('prototype')), GlimmerComponent), t.blockStatement([...importVirtual]));
272
+ ifHotStatements.push(ifInstanceOfComponent);
255
273
  }
256
- const ifHot = t.ifStatement(t.memberExpression(t.metaProperty(t.identifier('import'), t.identifier('meta')), t.identifier('hot')), t.blockStatement([...hotAccepts]));
274
+ const ifHot = t.ifStatement(t.memberExpression(t.metaProperty(t.identifier('import'), t.identifier('meta')), t.identifier('hot')), t.blockStatement([...ifHotStatements]));
257
275
  path.node.body.push(ifHot);
258
276
  path.scope.crawl();
259
- }
277
+ },
260
278
  },
261
279
  };
262
280
  }
package/dist/lib/hmr.js CHANGED
@@ -14,6 +14,39 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.hmr = hmr;
16
16
  const path_1 = __importDefault(require("path"));
17
+ const core_1 = require("@babel/core");
18
+ const getHotComponent = (imp, specifier) => `
19
+ import { ${specifier} as TargetComponent } from "${imp}";
20
+ import Component from "@glimmer/component";
21
+ import { tracked } from "@glimmer/tracking";
22
+ import { createComputeRef } from "@glimmer/reference";
23
+ import { curry } from '@glimmer/runtime';
24
+ import { CurriedTypes } from '@glimmer/vm';
25
+
26
+ export default class HotComponent extends Component {
27
+ @tracked curried;
28
+ hot = {};
29
+ constructor(owner, args) {
30
+ super(owner, args);
31
+ const named = {};
32
+ const positional = [];
33
+ for (const name of Object.keys(args)) {
34
+ named[name] = createComputeRef(() => args[name]);
35
+ }
36
+ this.curried = curry(CurriedTypes.Component, TargetComponent, owner, { positional, named});
37
+ if (import.meta.hot) {
38
+ // Rehydrate any saved state
39
+ import.meta.hot.accept('${imp}', (module) => {
40
+ this.curried = curry(CurriedTypes.Component, module.default, owner, { positional, named});
41
+ })
42
+ }
43
+ }
44
+ <template>
45
+ <this.curried @__hot__={{this.hot}}></this.curried>
46
+ </template>
47
+ }
48
+ `;
49
+ const virtualPrefix = 'ember-vite-hmr/virtual/component:';
17
50
  function hmr(enableViteHmrForModes = ['development']) {
18
51
  let conf;
19
52
  return {
@@ -25,14 +58,32 @@ function hmr(enableViteHmrForModes = ['development']) {
25
58
  .includes(config.mode)
26
59
  .toString();
27
60
  },
28
- resolveId(id) {
61
+ resolveId(id, importer) {
62
+ if (importer.startsWith(virtualPrefix)) {
63
+ importer = path_1.default.join(process.cwd(), 'package.json');
64
+ return this.resolve(id, importer);
65
+ }
66
+ if (id.startsWith(virtualPrefix)) {
67
+ return id;
68
+ }
29
69
  if (id.startsWith('/@id/embroider_virtual:')) {
30
70
  return this.resolve(id.replace('/@id/', ''), path_1.default.join(process.cwd(), 'package.json'));
31
71
  }
72
+ if (id.startsWith(`/@id/${virtualPrefix}`)) {
73
+ return this.resolve(id.replace('/@id/', ''), path_1.default.join(process.cwd(), 'package.json'));
74
+ }
32
75
  if (id === '/ember-vite-hmr/services/vite-hot-reload') {
33
76
  return this.resolve('ember-vite-hmr/services/vite-hot-reload', path_1.default.join(process.cwd(), 'package.json'));
34
77
  }
35
78
  },
79
+ load(id) {
80
+ if (id.startsWith(virtualPrefix)) {
81
+ const [imp, specifier] = id
82
+ .slice(virtualPrefix.length, -'.gts'.length)
83
+ .split(':');
84
+ return getHotComponent(imp, specifier);
85
+ }
86
+ },
36
87
  transformIndexHtml(html) {
37
88
  if (process.env['EMBER_VITE_HMR_ENABLED'] !== 'true') {
38
89
  return html;
@@ -62,7 +113,7 @@ function hmr(enableViteHmrForModes = ['development']) {
62
113
  transform(source, id) {
63
114
  return __awaiter(this, void 0, void 0, function* () {
64
115
  const resourcePath = id.replace(/\\/g, '/').split('?')[0];
65
- const supportedPaths = ['routers', 'controllers', 'routes'];
116
+ const supportedPaths = ['routers', 'controllers', 'routes', 'templates'];
66
117
  const supportedFileNames = [
67
118
  'route.js',
68
119
  'route.ts',
@@ -74,32 +125,30 @@ function hmr(enableViteHmrForModes = ['development']) {
74
125
  if (resourcePath.includes('/-components/')) {
75
126
  return source;
76
127
  }
128
+ let didReplaceSources = false;
77
129
  const name = require(`${process.cwd()}/package.json`).name;
78
130
  if (resourcePath.includes(`/assets/${name}.js`)) {
79
- const result = [
80
- ...source.matchAll(/import \* as [^ ]+ from (.*);/g),
81
- ];
82
- source += result.map(r => {
131
+ const result = [...source.matchAll(/import \* as [^ ]+ from (.*);/g)];
132
+ source += result
133
+ .map((r) => {
83
134
  if (r[1].includes('initializers')) {
84
135
  return `\nimport.meta.hot.accept(${r[1]}, () => window.location.reload());`;
85
136
  }
86
137
  return `\nimport.meta.hot.accept(${r[1]});`;
87
- }).join('');
138
+ })
139
+ .join('');
88
140
  }
89
141
  if (resourcePath.endsWith('.hbs') ||
90
142
  resourcePath.endsWith('.gjs') ||
91
143
  resourcePath.endsWith('.gts') ||
92
144
  resourcePath.includes(`/assets/${name}.js`)) {
93
- const result = [
94
- ...source.matchAll(/import.meta.hot.accept\(\'([^']+)\'/g),
95
- ];
96
- for (const resultElement of result) {
97
- const dep = resultElement[1];
145
+ const resolveDep = (dep) => __awaiter(this, void 0, void 0, function* () {
98
146
  const resolved = yield this.resolve(dep, resourcePath, {});
99
- let id = resolved.id;
147
+ let id = resolved === null || resolved === void 0 ? void 0 : resolved.id;
148
+ if (!id)
149
+ return;
100
150
  let appRoot = conf.root + '/app/';
101
- if (id.startsWith(appRoot) &&
102
- !id.startsWith('embroider_virtual:')) {
151
+ if (id.startsWith(appRoot) && !id.startsWith('embroider_virtual:')) {
103
152
  id = 'app/' + id.split(appRoot)[1];
104
153
  }
105
154
  if (id.startsWith('embroider_virtual:')) {
@@ -112,13 +161,77 @@ function hmr(enableViteHmrForModes = ['development']) {
112
161
  }
113
162
  id = '/@fs' + id;
114
163
  }
164
+ if (!id.startsWith('/') && !id.startsWith('.')) {
165
+ id = '/' + id;
166
+ }
167
+ return id;
168
+ });
169
+ const result = [
170
+ ...source.matchAll(/import.meta.hot.accept\(\'([^']+)\'/g),
171
+ ];
172
+ for (const resultElement of result) {
173
+ const dep = resultElement[1];
174
+ const id = yield resolveDep(dep);
175
+ if (!id)
176
+ continue;
177
+ if (dep === id)
178
+ continue;
179
+ didReplaceSources = true;
115
180
  source = source.replace(`import.meta.hot.accept('${dep}'`, `import.meta.hot.accept('${id}'`);
116
181
  }
182
+ const importMatches = [...source.matchAll(/import\('([^']+)'/g)];
183
+ for (const resultElement of importMatches) {
184
+ const dep = resultElement[1];
185
+ if (!dep.startsWith(virtualPrefix)) {
186
+ continue;
187
+ }
188
+ const [imp, specifier] = dep
189
+ .slice(virtualPrefix.length, -'.gts'.length)
190
+ .split(':');
191
+ const id = yield resolveDep(imp);
192
+ if (!id)
193
+ continue;
194
+ if (dep === id)
195
+ continue;
196
+ didReplaceSources = true;
197
+ source = source.replace(`import('${virtualPrefix}${imp}`, `import('${virtualPrefix}${id}`);
198
+ }
199
+ }
200
+ if (didReplaceSources) {
201
+ source = (0, core_1.transformSync)(source, {
202
+ filename: id,
203
+ babelrc: false,
204
+ plugins: [
205
+ {
206
+ name: 'cleanup',
207
+ visitor: {
208
+ CallExpression(path) {
209
+ var _a;
210
+ const node = path.node;
211
+ if (node.callee.type === 'Import' &&
212
+ ((_a = node.arguments[0]) === null || _a === void 0 ? void 0 : _a.type) === 'StringLiteral' &&
213
+ node.arguments[0].value.includes('ember-vite-hmr/virtual/component') &&
214
+ node.arguments[0].value.includes('node_modules')) {
215
+ let IfStatement = path;
216
+ while (IfStatement.type !== 'IfStatement') {
217
+ IfStatement = IfStatement.parentPath;
218
+ }
219
+ IfStatement.remove();
220
+ }
221
+ },
222
+ },
223
+ },
224
+ ],
225
+ }).code;
117
226
  }
118
227
  if (!supportedPaths.some((s) => resourcePath.includes(`/${s}/`)) &&
119
228
  !supportedFileNames.some((s) => resourcePath.endsWith(s))) {
120
229
  return source;
121
230
  }
231
+ if (supportedPaths.includes('templates') &&
232
+ supportedPaths.includes('components')) {
233
+ return source;
234
+ }
122
235
  return `${source}
123
236
  if (import.meta.hot && window.emberHotReloadPlugin) {
124
237
  const result = window.emberHotReloadPlugin.canAcceptNew(import.meta.url);
@@ -1,35 +1,23 @@
1
1
  import Service, { service } from '@ember/service';
2
2
  import { getOwner } from '@ember/owner';
3
- import Router from '@ember/routing/route';
3
+ import Route from '@ember/routing/route';
4
4
  import Controller from '@ember/controller';
5
5
 
6
- function _initializerDefineProperty(target, property, descriptor, context) {
7
- if (!descriptor) return;
8
- Object.defineProperty(target, property, {
9
- enumerable: descriptor.enumerable,
10
- configurable: descriptor.configurable,
11
- writable: descriptor.writable,
12
- value: descriptor.initializer ? descriptor.initializer.call(context) : void 0
13
- });
6
+ function _applyDecoratedDescriptor(i, e, r, n, l) {
7
+ var a = {};
8
+ return Object.keys(n).forEach(function (i) {
9
+ a[i] = n[i];
10
+ }), a.enumerable = !!a.enumerable, a.configurable = !!a.configurable, ("value" in a || a.initializer) && (a.writable = !0), a = r.slice().reverse().reduce(function (r, n) {
11
+ return n(i, e, r) || r;
12
+ }, a), void 0 === a.initializer ? (Object.defineProperty(i, e, a), null) : a;
14
13
  }
15
- function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
16
- var desc = {};
17
- Object.keys(descriptor).forEach(function (key) {
18
- desc[key] = descriptor[key];
14
+ function _initializerDefineProperty(e, i, r, l) {
15
+ r && Object.defineProperty(e, i, {
16
+ enumerable: r.enumerable,
17
+ configurable: r.configurable,
18
+ writable: r.writable,
19
+ value: r.initializer ? r.initializer.call(l) : void 0
19
20
  });
20
- desc.enumerable = !!desc.enumerable;
21
- desc.configurable = !!desc.configurable;
22
- if ('value' in desc || desc.initializer) {
23
- desc.writable = true;
24
- }
25
- desc = decorators.slice().reverse().reduce(function (desc, decorator) {
26
- return decorator(target, property, desc) || desc;
27
- }, desc);
28
- if (desc.initializer === void 0) {
29
- Object.defineProperty(target, property, desc);
30
- desc = null;
31
- }
32
- return desc;
33
21
  }
34
22
 
35
23
  var _dec, _class, _descriptor;
@@ -71,24 +59,27 @@ if (import.meta.hot) {
71
59
  };
72
60
  },
73
61
  __import(moduleUrl) {
74
- return import( /* @vite-ignore */moduleUrl);
62
+ return import(/* @vite-ignore */moduleUrl);
75
63
  },
76
64
  async canAcceptNew(moduleUrl) {
77
65
  this._accepting += 1;
78
66
  const m = await this.__import(moduleUrl);
79
67
  const module = {
80
68
  exports: m,
81
- id: moduleUrl.split('?')[0],
69
+ id: moduleUrl.split('?')[0].replace(/http:\/\/.*:[^\/]*\//, ''),
82
70
  version: 0
83
71
  };
84
72
  this._accepting -= 1;
85
73
  if (this._accepting === 0) {
86
74
  setTimeout(() => this.notifyNew(), 0);
87
75
  }
88
- let ok = module.id.includes('/routes/') || module.id.includes('/routers/') || module.id.includes('/controllers/') || module.id.match(/controller\.(js|ts)$/) || module.id.match(/route\.(js|ts|gts)$/);
76
+ let ok = module.id.includes('/routes/') || module.id.includes('/routers/') || module.id.includes('/controllers/') || module.id.includes('/templates/') || module.id.match(/controller\.(js|ts)$/) || module.id.match(/route\.(js|ts|gts)$/);
89
77
  if (!ok) {
90
78
  return false;
91
79
  }
80
+ if (module.id.includes('templates') && module.id.includes('components')) {
81
+ return false;
82
+ }
92
83
  if (ModuleMap.get(module.id)) {
93
84
  this.changed[module.id] = {
94
85
  old: ModuleMap.get(module.id),
@@ -118,7 +109,7 @@ if (import.meta.hot) {
118
109
  }
119
110
  };
120
111
  }
121
- let ViteHotReloadService = (_dec = service(), (_class = class ViteHotReloadService extends Service {
112
+ let ViteHotReloadService = (_dec = service(), _class = class ViteHotReloadService extends Service {
122
113
  constructor(...args) {
123
114
  super(...args);
124
115
  _initializerDefineProperty(this, "router", _descriptor, this);
@@ -147,13 +138,13 @@ let ViteHotReloadService = (_dec = service(), (_class = class ViteHotReloadServi
147
138
  this.container = getOwner(this)?.__container__;
148
139
  window.emberHotReloadPlugin.subscribe((oldModule, newModule) => {
149
140
  let changed = false;
150
- if (oldModule.exports.default?.prototype && oldModule.exports.default.prototype instanceof Router) {
141
+ if (oldModule.exports.default?.prototype && oldModule.exports.default.prototype instanceof Route) {
151
142
  changed = true;
152
143
  }
153
144
  if (oldModule.exports.default?.prototype && oldModule.exports.default.prototype instanceof Controller) {
154
145
  changed = true;
155
146
  }
156
- if (oldModule.id.startsWith('./templates/') && !oldModule.id.startsWith('./templates/components/')) {
147
+ if (oldModule.id.startsWith('app/templates/') && !oldModule.id.startsWith('app/templates/components/')) {
157
148
  changed = true;
158
149
  }
159
150
  if (oldModule.id.startsWith(`./${podModulePrefix}/`)) {
@@ -187,13 +178,13 @@ let ViteHotReloadService = (_dec = service(), (_class = class ViteHotReloadServi
187
178
  delete this.container.registry.registrations[k];
188
179
  }
189
180
  });
190
- if (oldModule.exports.default?.prototype && oldModule.exports.default.prototype instanceof Router) {
181
+ if (oldModule.exports.default?.prototype && oldModule.exports.default.prototype instanceof Route) {
191
182
  this.router.refresh();
192
183
  }
193
184
  if (oldModule.exports.default?.prototype && oldModule.exports.default.prototype instanceof Controller) {
194
185
  this.router.refresh();
195
186
  }
196
- if (oldModule.id.startsWith('./templates/') && !oldModule.id.startsWith('./templates/components/')) {
187
+ if (oldModule.id.startsWith('app/templates/') && !oldModule.id.startsWith('app/templates/components/')) {
197
188
  this.router.refresh();
198
189
  }
199
190
  if (oldModule.id.startsWith(`./${podModulePrefix}/`)) {
@@ -204,12 +195,12 @@ let ViteHotReloadService = (_dec = service(), (_class = class ViteHotReloadServi
204
195
  getLatestChange(obj) {
205
196
  return getLatestChange(obj);
206
197
  }
207
- }, (_descriptor = _applyDecoratedDescriptor(_class.prototype, "router", [_dec], {
198
+ }, _descriptor = _applyDecoratedDescriptor(_class.prototype, "router", [_dec], {
208
199
  configurable: true,
209
200
  enumerable: true,
210
201
  writable: true,
211
202
  initializer: null
212
- })), _class));
203
+ }), _class);
213
204
  // this service using `Owner.lookup('service:hot-reload')`, as well
214
205
  // as to check when you pass the service name as an argument to the decorator,
215
206
  // like `@service('hot-reload') declare altName: HotReloadService;`.
@@ -1 +1 @@
1
- {"version":3,"file":"vite-hot-reload.js","sources":["../../src/services/vite-hot-reload.ts"],"sourcesContent":["import Service, { service } from '@ember/service';\nimport { getOwner } from '@ember/owner';\nimport RouterService from '@ember/routing/router-service';\nimport Router from '@ember/routing/route';\nimport Controller from '@ember/controller';\nimport ApplicationInstance from '@ember/application/instance';\n\nconst ChangeMap = new WeakMap();\n\nfunction getLatestChange(obj: any) {\n while (ChangeMap.has(obj)) {\n obj = ChangeMap.get(obj);\n }\n return obj;\n}\n\nlet modulePrefix!: string;\nlet podModulePrefix!: string;\nif (import.meta.hot) {\n const ModuleMap = new Map();\n\n window.emberHotReloadPlugin = {\n _accepting: 0,\n changed: {},\n subscribers: [],\n version: 1,\n routerVersion: 1,\n moduleDepCallbacks: {},\n versionMap: {},\n\n clear(module: Module) {\n this.moduleDepCallbacks[module.id] = {};\n },\n register(module: Module, dep: string, callback: Function) {\n dep = dep.replace(new RegExp(`^${modulePrefix}/`), './');\n this.moduleDepCallbacks[module.id]![dep] =\n this.moduleDepCallbacks[module.id]![dep] || ([] as Function[]);\n this.moduleDepCallbacks[module.id]![dep]!.push(callback);\n },\n loadNew(oldModule: Module, newModule: Module) {\n this.versionMap[newModule.id] = newModule.version;\n const entry = Object.values(\n requirejs.entries as Record<string, ReqJSEntry>,\n ).find(\n (module) => module.module.exports.default === oldModule.exports.default,\n );\n if (!entry) return;\n entry.module = {\n id: newModule.id,\n exports: newModule.exports,\n version: newModule.version,\n };\n },\n\n __import(moduleUrl: string) {\n return import(/* @vite-ignore */ moduleUrl);\n },\n\n async canAcceptNew(moduleUrl: string) {\n this._accepting += 1;\n const m = await this.__import(moduleUrl);\n const module: Module = {\n exports: m,\n id: moduleUrl.split('?')[0]!,\n version: 0,\n };\n this._accepting -= 1;\n if (this._accepting === 0) {\n setTimeout(() => this.notifyNew(), 0);\n }\n let ok =\n module.id.includes('/routes/') ||\n module.id.includes('/routers/') ||\n module.id.includes('/controllers/') ||\n module.id.match(/controller\\.(js|ts)$/) ||\n module.id.match(/route\\.(js|ts|gts)$/);\n if (!ok) {\n return false;\n }\n\n if (ModuleMap.get(module.id)) {\n this.changed[module.id] = {\n old: ModuleMap.get(module.id),\n new: module,\n };\n }\n module.version = this.version;\n ModuleMap.set(module.id, module);\n return true;\n },\n notifyNew() {\n this.version += 1;\n Object.values(this.changed).forEach((change) => {\n this.loadNew(change.old, change.new);\n this.subscribers.forEach((fn: any) => fn(change.old, change.new));\n });\n this.changed = {};\n },\n subscribe(fn) {\n this.subscribers.push(fn);\n },\n unsubscribe(fn) {\n const idx = this.subscribers.indexOf(fn);\n if (idx >= 0) {\n this.subscribers.splice(idx, 1);\n }\n },\n };\n}\n\nexport default class ViteHotReloadService extends Service {\n declare container: any;\n @service() router!: RouterService;\n\n init(args: any) {\n super.init(args);\n if (!window.emberHotReloadPlugin) return;\n const app = (getOwner(this) as ApplicationInstance)!.application as any;\n modulePrefix = app.modulePrefix;\n podModulePrefix = app.podModulePrefix;\n this.router._router;\n Object.defineProperty(this.router._router, '_routerMicrolib', {\n set(v) {\n const getRoute = v.getRoute;\n v.getRoute = function (name: string) {\n const route = getRoute.call(\n this,\n `${name}--hot-version--${window.emberHotReloadPlugin.routerVersion}`,\n );\n route.fullRouteName = `route:${name}`.replace(\n /--hot-version--.*$/,\n '',\n );\n return route;\n };\n this.___routerMicrolib = v;\n },\n get() {\n return this.___routerMicrolib;\n },\n });\n this.container = (getOwner(this) as any)?.__container__;\n window.emberHotReloadPlugin.subscribe((oldModule, newModule) => {\n let changed = false;\n if (oldModule.exports.default?.prototype && oldModule.exports.default.prototype instanceof Router) {\n changed = true;\n }\n if (oldModule.exports.default?.prototype && oldModule.exports.default.prototype instanceof Controller) {\n changed = true;\n }\n if (oldModule.id.startsWith('./templates/') && !oldModule.id.startsWith('./templates/components/')) {\n changed = true;\n }\n if (oldModule.id.startsWith(`./${podModulePrefix}/`)) {\n changed = true;\n }\n if (!changed) return;\n window.emberHotReloadPlugin.routerVersion += 1;\n const types = [\n 'route',\n 'controller',\n 'template',\n 'modifier',\n 'helper',\n 'component',\n ];\n Object.keys(this.container.cache).forEach((k) => {\n if (types.some((t) => k.startsWith(`${t}:`))) {\n delete this.container.cache[k];\n }\n });\n Object.keys(this.container.factoryManagerCache).forEach((k) => {\n if (types.some((t) => k.startsWith(`${t}:`))) {\n delete this.container.factoryManagerCache[k];\n }\n });\n Object.keys(this.container.registry._resolveCache).forEach((k) => {\n if (types.some((t) => k.startsWith(`${t}:`))) {\n delete this.container.registry._resolveCache[k];\n }\n });\n Object.keys(this.container.validationCache).forEach((k) => {\n if (types.some((t) => k.startsWith(`${t}:`))) {\n delete this.container.validationCache[k];\n }\n });\n Object.keys(this.container.registry.registrations).forEach((k) => {\n if (types.some((t) => k.startsWith(`${t}:`))) {\n delete this.container.registry.registrations[k];\n }\n });\n if (\n oldModule.exports.default?.prototype &&\n oldModule.exports.default.prototype instanceof Router\n ) {\n this.router.refresh();\n }\n if (\n oldModule.exports.default?.prototype &&\n oldModule.exports.default.prototype instanceof Controller\n ) {\n this.router.refresh();\n }\n if (\n oldModule.id.startsWith('./templates/') &&\n !oldModule.id.startsWith('./templates/components/')\n ) {\n this.router.refresh();\n }\n if (oldModule.id.startsWith(`./${podModulePrefix}/`)) {\n this.router.refresh();\n }\n });\n }\n getLatestChange(obj: any) {\n return getLatestChange(obj);\n }\n}\n\n// Don't remove this declaration: this is what enables TypeScript to resolve\n// this service using `Owner.lookup('service:hot-reload')`, as well\n// as to check when you pass the service name as an argument to the decorator,\n// like `@service('hot-reload') declare altName: HotReloadService;`.\ndeclare module '@ember/service' {\n interface Registry {\n 'hot-reload': ViteHotReloadService;\n }\n}\n"],"names":["ChangeMap","WeakMap","getLatestChange","obj","has","get","modulePrefix","podModulePrefix","import","meta","hot","ModuleMap","Map","window","emberHotReloadPlugin","_accepting","changed","subscribers","version","routerVersion","moduleDepCallbacks","versionMap","clear","module","id","register","dep","callback","replace","RegExp","push","loadNew","oldModule","newModule","entry","Object","values","requirejs","entries","find","exports","default","__import","moduleUrl","canAcceptNew","m","split","setTimeout","notifyNew","ok","includes","match","old","new","set","forEach","change","fn","subscribe","unsubscribe","idx","indexOf","splice","ViteHotReloadService","_dec","service","_class","Service","constructor","args","_initializerDefineProperty","_descriptor","init","app","getOwner","application","router","_router","defineProperty","v","getRoute","name","route","call","fullRouteName","___routerMicrolib","container","__container__","prototype","Router","Controller","startsWith","types","keys","cache","k","some","t","factoryManagerCache","registry","_resolveCache","validationCache","registrations","refresh","_applyDecoratedDescriptor","configurable","enumerable","writable","initializer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAMA,SAAS,GAAG,IAAIC,OAAO,EAAE,CAAA;AAE/B,SAASC,eAAeA,CAACC,GAAQ,EAAE;AACjC,EAAA,OAAOH,SAAS,CAACI,GAAG,CAACD,GAAG,CAAC,EAAE;AACzBA,IAAAA,GAAG,GAAGH,SAAS,CAACK,GAAG,CAACF,GAAG,CAAC,CAAA;AAC1B,GAAA;AACA,EAAA,OAAOA,GAAG,CAAA;AACZ,CAAA;AAEA,IAAIG,YAAqB,CAAA;AACzB,IAAIC,eAAwB,CAAA;AAC5B,IAAIC,MAAM,CAACC,IAAI,CAACC,GAAG,EAAE;AACnB,EAAA,MAAMC,SAAS,GAAG,IAAIC,GAAG,EAAE,CAAA;EAE3BC,MAAM,CAACC,oBAAoB,GAAG;AAC5BC,IAAAA,UAAU,EAAE,CAAC;IACbC,OAAO,EAAE,EAAE;AACXC,IAAAA,WAAW,EAAE,E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E,CAAIpF,EAAAA,EAAAA,eAAgB,CAAE,CAAA,CAAA,CAAC,EAAE;AACpD,QAAA,IAAI,CAACqE,MAAM,CAAC2B,OAAO,EAAE,CAAA;AACvB,OAAA;AACF,KAAC,CAAC,CAAA;AACJ,GAAA;EACArG,eAAeA,CAACC,GAAQ,EAAE;IACxB,OAAOD,eAAe,CAACC,GAAG,CAAC,CAAA;AAC7B,GAAA;AACF,CAAC,GAAAoE,WAAA,GAAAiC,yBAAA,CAAAtC,MAAA,CAAAsB,SAAA,EAAA,QAAA,EAAA,CAAAxB,IAAA,CAAA,EAAA;EAAAyC,YAAA,EAAA,IAAA;EAAAC,UAAA,EAAA,IAAA;EAAAC,QAAA,EAAA,IAAA;EAAAC,WAAA,EAAA,IAAA;AAAA,CAAA,CAAA,GAAA1C,MAAA,CAAA,EAAA;AAGD;AACA;AACA;;;;"}
1
+ {"version":3,"file":"vite-hot-reload.js","sources":["../../src/services/vite-hot-reload.ts"],"sourcesContent":["import Service, { service } from '@ember/service';\nimport { getOwner } from '@ember/owner';\nimport RouterService from '@ember/routing/router-service';\nimport Router from '@ember/routing/route';\nimport Controller from '@ember/controller';\nimport ApplicationInstance from '@ember/application/instance';\n\nconst ChangeMap = new WeakMap();\n\nfunction getLatestChange(obj: any) {\n while (ChangeMap.has(obj)) {\n obj = ChangeMap.get(obj);\n }\n return obj;\n}\n\nlet modulePrefix!: string;\nlet podModulePrefix!: string;\nif (import.meta.hot) {\n const ModuleMap = new Map();\n\n window.emberHotReloadPlugin = {\n _accepting: 0,\n changed: {},\n subscribers: [],\n version: 1,\n routerVersion: 1,\n moduleDepCallbacks: {},\n versionMap: {},\n\n clear(module: Module) {\n this.moduleDepCallbacks[module.id] = {};\n },\n register(module: Module, dep: string, callback: Function) {\n dep = dep.replace(new RegExp(`^${modulePrefix}/`), './');\n this.moduleDepCallbacks[module.id]![dep] =\n this.moduleDepCallbacks[module.id]![dep] || ([] as Function[]);\n this.moduleDepCallbacks[module.id]![dep]!.push(callback);\n },\n loadNew(oldModule: Module, newModule: Module) {\n this.versionMap[newModule.id] = newModule.version;\n const entry = Object.values(\n requirejs.entries as Record<string, ReqJSEntry>,\n ).find(\n (module) => module.module.exports.default === oldModule.exports.default,\n );\n if (!entry) return;\n entry.module = {\n id: newModule.id,\n exports: newModule.exports,\n version: newModule.version,\n };\n },\n\n __import(moduleUrl: string) {\n return import(/* @vite-ignore */ moduleUrl);\n },\n\n async canAcceptNew(moduleUrl: string) {\n this._accepting += 1;\n const m = await this.__import(moduleUrl);\n const module: Module = {\n exports: m,\n id: moduleUrl.split('?')[0]!.replace(/http:\\/\\/.*:[^\\/]*\\//, ''),\n version: 0,\n };\n this._accepting -= 1;\n if (this._accepting === 0) {\n setTimeout(() => this.notifyNew(), 0);\n }\n let ok =\n module.id.includes('/routes/') ||\n module.id.includes('/routers/') ||\n module.id.includes('/controllers/') ||\n module.id.includes('/templates/') ||\n module.id.match(/controller\\.(js|ts)$/) ||\n module.id.match(/route\\.(js|ts|gts)$/);\n if (!ok) {\n return false;\n }\n\n if (module.id.includes('templates') && module.id.includes('components')) {\n return false;\n }\n\n if (ModuleMap.get(module.id)) {\n this.changed[module.id] = {\n old: ModuleMap.get(module.id),\n new: module,\n };\n }\n module.version = this.version;\n ModuleMap.set(module.id, module);\n return true;\n },\n notifyNew() {\n this.version += 1;\n Object.values(this.changed).forEach((change) => {\n this.loadNew(change.old, change.new);\n this.subscribers.forEach((fn: any) => fn(change.old, change.new));\n });\n this.changed = {};\n },\n subscribe(fn) {\n this.subscribers.push(fn);\n },\n unsubscribe(fn) {\n const idx = this.subscribers.indexOf(fn);\n if (idx >= 0) {\n this.subscribers.splice(idx, 1);\n }\n },\n };\n}\n\nexport default class ViteHotReloadService extends Service {\n declare container: any;\n @service() router!: RouterService;\n\n init(args: any) {\n super.init(args);\n if (!window.emberHotReloadPlugin) return;\n const app = (getOwner(this) as ApplicationInstance)!.application as any;\n modulePrefix = app.modulePrefix;\n podModulePrefix = app.podModulePrefix;\n this.router._router;\n Object.defineProperty(this.router._router, '_routerMicrolib', {\n set(v) {\n const getRoute = v.getRoute;\n v.getRoute = function (name: string) {\n const route = getRoute.call(\n this,\n `${name}--hot-version--${window.emberHotReloadPlugin.routerVersion}`,\n );\n route.fullRouteName = `route:${name}`.replace(\n /--hot-version--.*$/,\n '',\n );\n return route;\n };\n this.___routerMicrolib = v;\n },\n get() {\n return this.___routerMicrolib;\n },\n });\n this.container = (getOwner(this) as any)?.__container__;\n window.emberHotReloadPlugin.subscribe((oldModule, newModule) => {\n let changed = false;\n if (\n oldModule.exports.default?.prototype &&\n oldModule.exports.default.prototype instanceof Router\n ) {\n changed = true;\n }\n if (\n oldModule.exports.default?.prototype &&\n oldModule.exports.default.prototype instanceof Controller\n ) {\n changed = true;\n }\n if (\n oldModule.id.startsWith('app/templates/') &&\n !oldModule.id.startsWith('app/templates/components/')\n ) {\n changed = true;\n }\n if (oldModule.id.startsWith(`./${podModulePrefix}/`)) {\n changed = true;\n }\n if (!changed) return;\n window.emberHotReloadPlugin.routerVersion += 1;\n const types = [\n 'route',\n 'controller',\n 'template',\n 'modifier',\n 'helper',\n 'component',\n ];\n Object.keys(this.container.cache).forEach((k) => {\n if (types.some((t) => k.startsWith(`${t}:`))) {\n delete this.container.cache[k];\n }\n });\n Object.keys(this.container.factoryManagerCache).forEach((k) => {\n if (types.some((t) => k.startsWith(`${t}:`))) {\n delete this.container.factoryManagerCache[k];\n }\n });\n Object.keys(this.container.registry._resolveCache).forEach((k) => {\n if (types.some((t) => k.startsWith(`${t}:`))) {\n delete this.container.registry._resolveCache[k];\n }\n });\n Object.keys(this.container.validationCache).forEach((k) => {\n if (types.some((t) => k.startsWith(`${t}:`))) {\n delete this.container.validationCache[k];\n }\n });\n Object.keys(this.container.registry.registrations).forEach((k) => {\n if (types.some((t) => k.startsWith(`${t}:`))) {\n delete this.container.registry.registrations[k];\n }\n });\n if (\n oldModule.exports.default?.prototype &&\n oldModule.exports.default.prototype instanceof Router\n ) {\n this.router.refresh();\n }\n if (\n oldModule.exports.default?.prototype &&\n oldModule.exports.default.prototype instanceof Controller\n ) {\n this.router.refresh();\n }\n if (\n oldModule.id.startsWith('app/templates/') &&\n !oldModule.id.startsWith('app/templates/components/')\n ) {\n this.router.refresh();\n }\n if (oldModule.id.startsWith(`./${podModulePrefix}/`)) {\n this.router.refresh();\n }\n });\n }\n getLatestChange(obj: any) {\n return getLatestChange(obj);\n }\n}\n\n// Don't remove this declaration: this is what enables TypeScript to resolve\n// this service using `Owner.lookup('service:hot-reload')`, as well\n// as to check when you pass the service name as an argument to the decorator,\n// like `@service('hot-reload') declare altName: HotReloadService;`.\ndeclare module '@ember/service' {\n interface Registry {\n 'hot-reload': ViteHotReloadService;\n }\n}\n"],"names":["ChangeMap","WeakMap","getLatestChange","obj","has","get","modulePrefix","podModulePrefix","import","meta","hot","ModuleMap","Map","window","emberHotReloadPlugin","_accepting","changed","subscribers","version","routerVersion","moduleDepCallbacks","versionMap","clear","module","id","register","dep","callback","replace","RegExp","push","loadNew","oldModule","newModule","entry","Object","values","requirejs","entries","find","exports","default","__import","moduleUrl","canAcceptNew","m","split","setTimeout","notifyNew","ok","includes","match","old","new","set","forEach","change","fn","subscribe","unsubscribe","idx","indexOf","splice","ViteHotReloadService","_dec","service","_class","Service","constructor","args","_initializerDefineProperty","_descriptor","init","app","getOwner","application","router","_router","defineProperty","v","getRoute","name","route","call","fullRouteName","___routerMicrolib","container","__container__","prototype","Router","Controller","startsWith","types","keys","cache","k","some","t","factoryManagerCache","registry","_resolveCache","validationCache","registrations","refresh","_applyDecoratedDescriptor","configurable","enumerable","writable","initializer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAMA,SAAS,GAAG,IAAIC,OAAO,EAAE,CAAA;AAE/B,SAASC,eAAeA,CAACC,GAAQ,EAAE;AACjC,EAAA,OAAOH,SAAS,CAACI,GAAG,CAACD,GAAG,CAAC,EAAE;AACzBA,IAAAA,GAAG,GAAGH,SAAS,CAACK,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"name": "ember-vite-hmr",
3
- "version": "1.4.17",
3
+ "version": "1.5.0",
4
4
  "keywords": [
5
5
  "ember-addon"
6
6
  ],
@@ -34,7 +34,7 @@
34
34
  "start": "concurrently 'npm:start:*'",
35
35
  "start:js": "rollup --config --watch --no-watch.clearScreen",
36
36
  "start:types": "glint --declaration --watch",
37
- "test": "vitest --run",
37
+ "test": "vitest run",
38
38
  "prepack": "pnpm build || echo 'its okay'"
39
39
  },
40
40
  "dependencies": {
@@ -42,7 +42,7 @@
42
42
  "@babel/plugin-transform-typescript": "^7.22.15",
43
43
  "@babel/traverse": "^7.23.2",
44
44
  "@babel/types": "^7.24.0",
45
- "@embroider/addon-shim": "^1.0.0",
45
+ "@embroider/addon-shim": "^1.8.9",
46
46
  "@glimmer/syntax": "^0.88.1",
47
47
  "@types/supports-color": "^8.1.0",
48
48
  "babel-import-util": "^2.0.1",
@@ -51,16 +51,6 @@
51
51
  "semver": "^7.3.5"
52
52
  },
53
53
  "devDependencies": {
54
- "assert-never": "^1.2.1",
55
- "content-tag": "^2.0.1",
56
- "source-map-url": "^0.4.1",
57
- "style-loader": "^4.0.0",
58
- "supports-color": "^9.4.0",
59
- "terser": "^5.7.0",
60
- "thread-loader": "^4.0.2",
61
- "vite": "^5.2.11",
62
- "vitest": "^2.0.5",
63
- "ember-cli-htmlbars": "^6.3.0",
64
54
  "@babel/eslint-parser": "^7.19.1",
65
55
  "@babel/plugin-proposal-class-properties": "^7.16.7",
66
56
  "@babel/plugin-proposal-decorators": "^7.23.2",
@@ -83,28 +73,44 @@
83
73
  "@types/lodash": "^4.14.170",
84
74
  "@types/mini-css-extract-plugin": "^2.5.1",
85
75
  "@types/node": "^20.14.10",
86
- "@types/semver": "^7.3.6",
87
76
  "@types/rsvp": "^4.0.9",
88
- "babel-plugin-ember-template-compilation": "^2.2.2",
77
+ "@types/semver": "^7.3.6",
78
+ "assert-never": "^1.2.1",
89
79
  "babel-import-util": "2.0.3",
80
+ "babel-plugin-ember-template-compilation": "^2.2.2",
90
81
  "concurrently": "^8.0.1",
82
+ "content-tag": "^2.0.1",
83
+ "ember-cli-htmlbars": "^6.3.0",
91
84
  "ember-resolver": "^11.0.1",
92
85
  "ember-source": "^5.10.1",
86
+ "@glimmer/component": "^1.1.2",
93
87
  "ember-template-lint": "^5.11.2",
94
88
  "eslint": "^8.33.0",
95
89
  "eslint-config-prettier": "^9.0.0",
96
90
  "eslint-plugin-ember": "^12.2.0",
97
91
  "eslint-plugin-n": "^17.9.0",
98
92
  "eslint-plugin-prettier": "^5.0.0",
93
+ "execa": "^9.3.1",
94
+ "fs-extra": "^11.2.0",
95
+ "playwright-chromium": "^1.47.0",
99
96
  "prettier": "^3.0.3",
100
97
  "prettier-plugin-ember-template-tag": "^2.0.2",
98
+ "puppeteer-chromium-resolver": "^23.0.0",
101
99
  "rollup": "^4.18.1",
102
- "typescript": "^5.1.6"
100
+ "source-map-url": "^0.4.1",
101
+ "strip-ansi": "^7.1.0",
102
+ "style-loader": "^4.0.0",
103
+ "supports-color": "^9.4.0",
104
+ "terser": "^5.7.0",
105
+ "thread-loader": "^4.0.2",
106
+ "typescript": "^5.1.6",
107
+ "vite": "^5.2.11",
108
+ "vitest": "^2.0.5"
103
109
  },
104
110
  "peerDependencies": {
105
111
  "@embroider/compat": "*",
106
- "babel-plugin-ember-template-compilation": "^2.2.2",
107
- "babel-import-util": "2.0.3"
112
+ "babel-import-util": "2.0.3",
113
+ "babel-plugin-ember-template-compilation": "^2.2.2"
108
114
  },
109
115
  "engines": {
110
116
  "node": "12.* || 14.* || >= 16"
@@ -117,6 +123,7 @@
117
123
  "type": "addon",
118
124
  "main": "addon-main.cjs",
119
125
  "app-js": {
126
+ "./instance-initializers/setup-hmr-manager.js": "./dist/_app_/instance-initializers/setup-hmr-manager.js",
120
127
  "./instance-initializers/vite-hot-reload.js": "./dist/_app_/instance-initializers/vite-hot-reload.js",
121
128
  "./services/vite-hot-reload.js": "./dist/_app_/services/vite-hot-reload.js"
122
129
  }