ember-native 2.2.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dom/native/NativeElementNode.js +3 -0
- package/dist/utils/babel-plugin.js +1 -1
- package/dist/utils/babel-plugin.ts +1 -1
- package/dist/utils/embroider-template-tag-loader.js +50 -0
- package/dist/utils/embroider-webpack-adapter.js +174 -0
- package/dist/utils/webpack.config.js +15 -43
- package/package.json +9 -14
- package/dist/utils/content-tag-loader.js +0 -9
|
@@ -283,6 +283,9 @@ class NativeElementNode extends ElementNode {
|
|
|
283
283
|
parentView._removeView(childView);
|
|
284
284
|
}
|
|
285
285
|
} else if (parentView instanceof View) {
|
|
286
|
+
if (childNode.parentNode !== parentNode) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
286
289
|
parentView._removeView(childView);
|
|
287
290
|
} else ;
|
|
288
291
|
}
|
|
@@ -152,7 +152,7 @@ export default function hotReplaceAst(babel) {
|
|
|
152
152
|
visitor: {
|
|
153
153
|
Program(path, state) {
|
|
154
154
|
var _a;
|
|
155
|
-
if (!hotAstProcessor.meta.importVar) {
|
|
155
|
+
if (!hotAstProcessor.meta.importVar || !hotAstProcessor.meta.importBindings) {
|
|
156
156
|
return;
|
|
157
157
|
}
|
|
158
158
|
if (process.env['EMBER_HMR_ENABLED'] !== 'true') {
|
|
@@ -198,7 +198,7 @@ export default function hotReplaceAst(babel: typeof Babel) {
|
|
|
198
198
|
},
|
|
199
199
|
visitor: {
|
|
200
200
|
Program(path, state) {
|
|
201
|
-
if (!hotAstProcessor.meta.importVar) {
|
|
201
|
+
if (!hotAstProcessor.meta.importVar || !hotAstProcessor.meta.importBindings) {
|
|
202
202
|
return;
|
|
203
203
|
}
|
|
204
204
|
if (process.env['EMBER_HMR_ENABLED'] !== 'true') {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webpack loader that uses @embroider/vite's templateTag plugin
|
|
3
|
+
* to transform .gts/.gjs files
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
let templateTagPlugin;
|
|
7
|
+
|
|
8
|
+
try {
|
|
9
|
+
const { templateTag } = require('@embroider/vite');
|
|
10
|
+
templateTagPlugin = templateTag();
|
|
11
|
+
} catch (e) {
|
|
12
|
+
console.warn('Failed to load @embroider/vite templateTag plugin:', e.message);
|
|
13
|
+
console.warn('Falling back to content-tag-loader');
|
|
14
|
+
// Fallback to content-tag-loader
|
|
15
|
+
module.exports = require('./content-tag-loader.js');
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
module.exports = function embroiderTemplateTagLoader(source) {
|
|
20
|
+
const callback = this.async();
|
|
21
|
+
const id = this.resourcePath;
|
|
22
|
+
|
|
23
|
+
// Create a minimal context for the plugin
|
|
24
|
+
const context = {
|
|
25
|
+
parse: (code) => ({ code }),
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Call the transform hook from the templateTag plugin
|
|
29
|
+
Promise.resolve()
|
|
30
|
+
.then(() => {
|
|
31
|
+
if (templateTagPlugin.transform) {
|
|
32
|
+
return templateTagPlugin.transform.call(context, source, id);
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
})
|
|
36
|
+
.then((result) => {
|
|
37
|
+
if (result && result.code) {
|
|
38
|
+
// Return just the code, like content-tag-loader does
|
|
39
|
+
// This avoids the .inputSourceMap error with babel-loader
|
|
40
|
+
callback(null, result.code);
|
|
41
|
+
} else {
|
|
42
|
+
// If no transformation, pass through
|
|
43
|
+
callback();
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
.catch((error) => {
|
|
47
|
+
console.error('Template tag transformation error:', error);
|
|
48
|
+
callback(error);
|
|
49
|
+
});
|
|
50
|
+
};
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Webpack adapter for @embroider/vite plugins
|
|
3
|
+
*
|
|
4
|
+
* This adapter allows using @embroider/vite's resolver() and templateTag() plugins
|
|
5
|
+
* in webpack builds, similar to how they're used in rollup.config.mjs
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
const { existsSync, statSync } = require("fs");
|
|
11
|
+
const { resolve: resolvePath } = require("path");
|
|
12
|
+
|
|
13
|
+
function tryExtensions(basePath, extensions = ['js', 'ts', 'gts', '.gjs']) {
|
|
14
|
+
// Try with extensions first
|
|
15
|
+
basePath = basePath
|
|
16
|
+
.replace('.js', '')
|
|
17
|
+
.replace('.ts', '')
|
|
18
|
+
.replace('.gjs', '')
|
|
19
|
+
.replace('.gts', '')
|
|
20
|
+
.replace('file://', '');
|
|
21
|
+
for (const ext of extensions) {
|
|
22
|
+
const fullPath = `${basePath}.${ext}`;
|
|
23
|
+
if (existsSync(fullPath)) {
|
|
24
|
+
try {
|
|
25
|
+
const stats = statSync(fullPath);
|
|
26
|
+
if (stats.isFile()) {
|
|
27
|
+
return fs.realpathSync(fullPath);
|
|
28
|
+
}
|
|
29
|
+
// eslint-disable-next-line no-unused-vars
|
|
30
|
+
} catch (e) {
|
|
31
|
+
// Continue to next extension
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Try index files
|
|
37
|
+
for (const ext of extensions) {
|
|
38
|
+
const indexPath = resolvePath(basePath, `index.${ext}`);
|
|
39
|
+
if (existsSync(indexPath)) {
|
|
40
|
+
try {
|
|
41
|
+
const stats = statSync(indexPath);
|
|
42
|
+
if (stats.isFile()) {
|
|
43
|
+
return indexPath;
|
|
44
|
+
}
|
|
45
|
+
// eslint-disable-next-line no-unused-vars
|
|
46
|
+
} catch (e) {
|
|
47
|
+
// Continue to next extension
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Creates a webpack resolver plugin that uses @embroider/vite's resolver
|
|
56
|
+
*/
|
|
57
|
+
function createResolverPlugin() {
|
|
58
|
+
let resolverPlugin;
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
const { resolver } = require('@embroider/vite');
|
|
62
|
+
resolverPlugin = resolver();
|
|
63
|
+
} catch (e) {
|
|
64
|
+
console.warn('Failed to load @embroider/vite resolver plugin:', e.message);
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return class EmbroiderResolverPlugin {
|
|
69
|
+
apply(resolver) {
|
|
70
|
+
const target = resolver.ensureHook('resolved');
|
|
71
|
+
|
|
72
|
+
resolver
|
|
73
|
+
.getHook('described-resolve')
|
|
74
|
+
.tapAsync('EmbroiderResolverPlugin', (request, resolveContext, callback) => {
|
|
75
|
+
const issuer = request.context?.issuer || request.path;
|
|
76
|
+
|
|
77
|
+
if (!request.context?.issuer) {
|
|
78
|
+
callback();
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Create a context compatible with vite plugins
|
|
83
|
+
// The resolver expects a context with a resolve method
|
|
84
|
+
const context = {
|
|
85
|
+
resolve: async (spec, from) => {
|
|
86
|
+
// Return a simple object with id property
|
|
87
|
+
// Let webpack handle the actual resolution
|
|
88
|
+
const res = tryExtensions(spec);
|
|
89
|
+
if (res) {
|
|
90
|
+
return { id: res };
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
if (spec.startsWith('ember-source')) {
|
|
94
|
+
return { id: fs.realpathSync(require.resolve(spec)) };
|
|
95
|
+
}
|
|
96
|
+
from = fs.realpathSync(from);
|
|
97
|
+
return { id: fs.realpathSync(require.resolve(spec, { paths: [path.dirname(from)] })) };
|
|
98
|
+
// eslint-disable-next-line no-unused-vars
|
|
99
|
+
} catch (e) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// Call resolveId from the resolver plugin
|
|
106
|
+
Promise.resolve()
|
|
107
|
+
.then(() => {
|
|
108
|
+
if (resolverPlugin.resolveId) {
|
|
109
|
+
return resolverPlugin.resolveId.call(context, request.request, issuer, {});
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
})
|
|
113
|
+
.then((result) => {
|
|
114
|
+
if (result && result.id) {
|
|
115
|
+
// Embroider resolved it - continue with the resolved path
|
|
116
|
+
const obj = {
|
|
117
|
+
...request,
|
|
118
|
+
request: result.id,
|
|
119
|
+
path: result.id
|
|
120
|
+
};
|
|
121
|
+
resolver.doResolve(target, obj, null, resolveContext, callback);
|
|
122
|
+
} else {
|
|
123
|
+
// Embroider couldn't resolve it - let the next plugin try
|
|
124
|
+
callback();
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
// eslint-disable-next-line no-unused-vars
|
|
128
|
+
.catch((error) => {
|
|
129
|
+
callback();
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Configures webpack to use @embroider/vite plugins via adapters
|
|
138
|
+
*/
|
|
139
|
+
module.exports = function configureEmbroiderWebpackAdapter(webpack) {
|
|
140
|
+
const ResolverPlugin = createResolverPlugin();
|
|
141
|
+
|
|
142
|
+
webpack.chainWebpack((config) => {
|
|
143
|
+
// Add resolver plugin if available
|
|
144
|
+
if (ResolverPlugin) {
|
|
145
|
+
config.resolve
|
|
146
|
+
.plugin('embroider-resolver')
|
|
147
|
+
.use(ResolverPlugin);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Configure .gts/.gjs file handling using the embroider-template-tag-loader
|
|
151
|
+
// This loader wraps @embroider/vite's templateTag() plugin
|
|
152
|
+
const loaderPath = path.resolve(__dirname, 'embroider-template-tag-loader.js');
|
|
153
|
+
|
|
154
|
+
config.module
|
|
155
|
+
.rule('gts/gjs')
|
|
156
|
+
.test(/\.g[jt]s$/)
|
|
157
|
+
.use('babel-loader')
|
|
158
|
+
.loader('babel-loader')
|
|
159
|
+
.end()
|
|
160
|
+
.use('embroider-template-tag-loader')
|
|
161
|
+
.loader(loaderPath)
|
|
162
|
+
.end();
|
|
163
|
+
|
|
164
|
+
// Configure regular .js/.ts files
|
|
165
|
+
config.module
|
|
166
|
+
.rule('js/ts')
|
|
167
|
+
.test(/\.([jt]s)$/)
|
|
168
|
+
.use('babel-loader')
|
|
169
|
+
.loader('babel-loader')
|
|
170
|
+
.end();
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
module.exports.createResolverPlugin = createResolverPlugin;
|
|
@@ -1,55 +1,27 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
1
|
|
|
2
|
+
/**
|
|
3
|
+
* Configures webpack for ember-native using @embroider/vite adapter
|
|
4
|
+
*
|
|
5
|
+
* This configuration uses @embroider/vite plugins via the webpack adapter
|
|
6
|
+
* with automatic fallback to custom loaders if unavailable.
|
|
7
|
+
*/
|
|
4
8
|
module.exports = (webpack) => {
|
|
9
|
+
try {
|
|
10
|
+
const configureAdapter = require('./embroider-webpack-adapter.js');
|
|
11
|
+
configureAdapter(webpack);
|
|
12
|
+
console.log('✓ Using @embroider/vite webpack adapter');
|
|
13
|
+
} catch (e) {
|
|
14
|
+
console.warn('⚠ Failed to load embroider adapter, using fallback loaders:', e.message);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Configure @glimmer/env alias (still needed)
|
|
5
18
|
webpack.chainWebpack((config) => {
|
|
6
|
-
const glimmerDirs = fs.readdirSync(
|
|
7
|
-
path.resolve(
|
|
8
|
-
process.cwd(),
|
|
9
|
-
'./node_modules/ember-source/dist/packages/@glimmer',
|
|
10
|
-
),
|
|
11
|
-
);
|
|
12
|
-
for (const glimmerDir of glimmerDirs) {
|
|
13
|
-
config.resolve.alias.set(
|
|
14
|
-
`@glimmer/${glimmerDir}`,
|
|
15
|
-
`ember-source/dist/packages/@glimmer/${glimmerDir}`,
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
// change the "@" alias to "app/libs"
|
|
19
|
-
config.resolve.alias.set('@ember', 'ember-source/dist/packages/@ember');
|
|
20
|
-
config.resolve.alias.set('ember', 'ember-source/dist/packages/ember');
|
|
21
|
-
config.resolve.alias.set(
|
|
22
|
-
'@glimmer/component',
|
|
23
|
-
'@glimmer/component/addon/index.ts',
|
|
24
|
-
);
|
|
25
19
|
config.resolve.alias.set(
|
|
26
20
|
'@glimmer/env',
|
|
27
21
|
require.resolve('./glimmer-env.js'),
|
|
28
22
|
);
|
|
29
23
|
});
|
|
30
24
|
|
|
31
|
-
webpack.chainWebpack((config) => {
|
|
32
|
-
// add a new rule for *.something files
|
|
33
|
-
config.module
|
|
34
|
-
.rule('gts/gjs')
|
|
35
|
-
.test(/\.g[jt]s$/)
|
|
36
|
-
.use('babel-loader')
|
|
37
|
-
.loader('babel-loader')
|
|
38
|
-
.end()
|
|
39
|
-
.use('gjs-loader')
|
|
40
|
-
.loader(require.resolve('./content-tag-loader.js'))
|
|
41
|
-
.end();
|
|
42
|
-
|
|
43
|
-
config.module
|
|
44
|
-
.rule('js/ts')
|
|
45
|
-
.test(/\.([jt]s)$/)
|
|
46
|
-
.use('fix-glimmer-content-owner')
|
|
47
|
-
.loader(require.resolve('./fix-glimmer-content-owner.js'))
|
|
48
|
-
.end()
|
|
49
|
-
.use('babel-loader')
|
|
50
|
-
.loader('babel-loader');
|
|
51
|
-
});
|
|
52
|
-
|
|
53
25
|
webpack.chainWebpack((config) => {
|
|
54
26
|
config.plugin('DefinePlugin').tap((args) => {
|
|
55
27
|
Object.assign(args[0], {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-native",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "the Ember framework with Nativescript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -19,10 +19,6 @@
|
|
|
19
19
|
],
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"@glimmer/component": "*",
|
|
22
|
-
"@glimmer/reference": "*",
|
|
23
|
-
"@glimmer/runtime": "*",
|
|
24
|
-
"@glimmer/tracking": "*",
|
|
25
|
-
"@glimmer/validator": "*",
|
|
26
22
|
"@nativescript/core": "*",
|
|
27
23
|
"ember-modifier": "*",
|
|
28
24
|
"ember-source": "*",
|
|
@@ -34,10 +30,9 @@
|
|
|
34
30
|
"@ember/render-modifiers": "^3.0.0",
|
|
35
31
|
"@ember/string": "^4.0.0",
|
|
36
32
|
"@ember/test-waiters": "^4.1.1",
|
|
37
|
-
"@embroider/addon-shim": "^1.10.
|
|
33
|
+
"@embroider/addon-shim": "^1.10.2",
|
|
38
34
|
"@eslint/js": "^9.28.0",
|
|
39
35
|
"@glimmer/component": "^2.0.0",
|
|
40
|
-
"@glimmer/tracking": "^1.1.2",
|
|
41
36
|
"@rollup/plugin-alias": "^5.1.0",
|
|
42
37
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
43
38
|
"@types/node": "^24.1.0",
|
|
@@ -58,19 +53,17 @@
|
|
|
58
53
|
},
|
|
59
54
|
"devDependencies": {
|
|
60
55
|
"@babel/types": "^7.28.5",
|
|
56
|
+
"@babel/eslint-parser": "^7.28.5",
|
|
61
57
|
"@ember/optional-features": "^2.0.0",
|
|
62
58
|
"@embroider/addon-dev": "^8.1.0",
|
|
63
59
|
"@embroider/compat": "^4.1.0",
|
|
64
|
-
"@embroider/core": "^4.
|
|
60
|
+
"@embroider/core": "^4.2.8",
|
|
65
61
|
"@embroider/macros": "^1.18.1",
|
|
66
62
|
"@embroider/shared-internals": "^3.0.0",
|
|
63
|
+
"@embroider/vite": "^1.4.2",
|
|
67
64
|
"@embroider/util": "^1.13.3",
|
|
68
65
|
"@embroider/webpack": "^4.1.1",
|
|
69
|
-
"@glimmer/interfaces": "^0.94.6",
|
|
70
|
-
"@glimmer/reference": "^0.94.8",
|
|
71
|
-
"@glimmer/runtime": "^0.94.10",
|
|
72
66
|
"@glimmer/syntax": "^0.94.9",
|
|
73
|
-
"@glimmer/validator": "^0.95.0",
|
|
74
67
|
"@glint/core": "^1.5.0",
|
|
75
68
|
"@glint/environment-ember-loose": "^1.5.0",
|
|
76
69
|
"@glint/environment-ember-template-imports": "^1.5.0",
|
|
@@ -85,6 +78,7 @@
|
|
|
85
78
|
"@types/qunit-dom": "^0.7.0",
|
|
86
79
|
"@typescript-eslint/eslint-plugin": "^8.13.0",
|
|
87
80
|
"@typescript-eslint/parser": "^8.38.0",
|
|
81
|
+
"typescript-eslint": "^8.38.0",
|
|
88
82
|
"babel-import-util": "^3.0.0",
|
|
89
83
|
"babel-plugin-ember-template-compilation": "^3.0.0",
|
|
90
84
|
"bower": "^1.8.8",
|
|
@@ -116,7 +110,7 @@
|
|
|
116
110
|
"qunit-dom": "^3.4.0",
|
|
117
111
|
"release-it": "^15.10.3",
|
|
118
112
|
"rollup": "^4.46.3",
|
|
119
|
-
"rollup-plugin-copy": "^3.
|
|
113
|
+
"rollup-plugin-copy": "^3.5.0",
|
|
120
114
|
"router_js": "^8.0.6",
|
|
121
115
|
"sass": "^1.89.2",
|
|
122
116
|
"sass-embedded": "^1.90.0",
|
|
@@ -156,6 +150,7 @@
|
|
|
156
150
|
"types": "./declarations/*.d.ts",
|
|
157
151
|
"default": "./dist/*.js"
|
|
158
152
|
},
|
|
153
|
+
"./utils/*": "./dist/utils/*",
|
|
159
154
|
"./addon-main.js": "./addon-main.cjs"
|
|
160
155
|
},
|
|
161
156
|
"typesVersions": {
|
|
@@ -166,7 +161,7 @@
|
|
|
166
161
|
}
|
|
167
162
|
},
|
|
168
163
|
"scripts": {
|
|
169
|
-
"build": "
|
|
164
|
+
"build": "pnpm build:js && pnpm build:utils && pnpm build:types",
|
|
170
165
|
"build:js": "rollup --config",
|
|
171
166
|
"build:utils": "cd utils && tsc --project tsconfig.json",
|
|
172
167
|
"build:types": "glint --declaration && npx fix-bad-declaration-output './declarations/**/*.d.ts'",
|