nativescript-web-adapter 0.1.5 → 0.1.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.
- package/README.md +32 -14
- package/angular/components/absolute-layout.component.ts +18 -0
- package/angular/components/action-bar.component.ts +16 -0
- package/angular/components/action-item.component.ts +22 -0
- package/angular/components/activity-indicator.component.ts +32 -0
- package/angular/components/button.component.ts +45 -0
- package/angular/components/date-picker.component.ts +35 -0
- package/angular/components/directives/absolute-position.directive.ts +31 -0
- package/angular/components/directives/grid-position.directive.ts +43 -0
- package/angular/components/dock-layout.component.ts +46 -0
- package/angular/components/flexbox-layout.component.ts +16 -0
- package/angular/components/frame.component.ts +9 -0
- package/angular/components/grid-layout.component.ts +48 -0
- package/angular/components/html-view.component.ts +23 -0
- package/angular/components/image-cache-it.component.ts +21 -0
- package/angular/components/image.component.ts +22 -0
- package/angular/components/index.ts +156 -0
- package/angular/components/label.component.ts +27 -0
- package/angular/components/list-picker.component.ts +33 -0
- package/angular/components/list-view.component.ts +22 -0
- package/angular/components/navigation-button.component.ts +36 -0
- package/angular/components/page.component.ts +21 -0
- package/angular/components/placeholder.component.ts +16 -0
- package/angular/components/progress.component.ts +20 -0
- package/angular/components/root-layout.component.ts +19 -0
- package/angular/components/scroll-view.component.ts +17 -0
- package/angular/components/search-bar.component.ts +34 -0
- package/angular/components/segmented-bar-item.component.ts +27 -0
- package/angular/components/segmented-bar.component.ts +101 -0
- package/angular/components/slider.component.ts +41 -0
- package/angular/components/stack-layout.component.ts +17 -0
- package/angular/components/switch.component.ts +62 -0
- package/angular/components/tab-view-item.component.ts +27 -0
- package/angular/components/tab-view.component.ts +89 -0
- package/angular/components/text-field.component.ts +38 -0
- package/angular/components/text-view.component.ts +29 -0
- package/angular/components/time-picker.component.ts +27 -0
- package/angular/components/web-view.component.ts +25 -0
- package/angular/components/wrap-layout.component.ts +17 -0
- package/angular/composables/dialogs.ts +54 -0
- package/angular/composables/index.ts +6 -0
- package/angular/composables/ref.ts +8 -0
- package/angular/composables/useActionBar.ts +20 -0
- package/angular/composables/useFrame.ts +26 -0
- package/angular/composables/usePage.ts +26 -0
- package/angular/index.ts +8 -0
- package/core/components/Button.vue +2 -2
- package/core/components/GridLayout.vue +2 -2
- package/core/components/HtmlView.vue +2 -2
- package/core/components/Image.vue +2 -2
- package/core/components/ImageCacheIt.vue +2 -2
- package/core/components/Label.vue +2 -2
- package/core/components/ListPicker.vue +2 -2
- package/core/components/NavigationButton.vue +2 -2
- package/core/components/Progress.vue +2 -2
- package/core/components/SearchBar.vue +2 -2
- package/core/components/Slider.vue +2 -2
- package/core/components/Switch.vue +2 -2
- package/core/components/TextField.vue +2 -2
- package/core/components/TextView.vue +2 -2
- package/core/components/WebView.vue +2 -2
- package/core/composables/dialogs.ts +5 -5
- package/dist/nativescript-web-adapter.es.js +22375 -45
- package/dist/nativescript-web-adapter.umd.js +534 -1
- package/package.json +37 -7
- package/tools/cli.cjs +17 -4
- package/tools/create-web-platform.cjs +40 -18
- package/tools/modules/appPatch.cjs +125 -1
- package/tools/modules/templates.cjs +161 -84
- package/tools/modules/transform.cjs +69 -2
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
// - Clean platform-specific globals and handlers
|
|
5
5
|
// - Keep template tags intact for custom web components to handle
|
|
6
6
|
|
|
7
|
-
function transformContent(content, srcPath) {
|
|
7
|
+
function transformContent(content, srcPath, framework = 'vue') {
|
|
8
|
+
if (framework === 'angular') {
|
|
9
|
+
return transformAngularContent(content, srcPath);
|
|
10
|
+
}
|
|
8
11
|
// globals.ts shim for web
|
|
9
12
|
if (srcPath && /globals\.ts$/.test(srcPath)) {
|
|
10
13
|
return "export function initGlobals() { /* web shim: no-op */ }\n";
|
|
@@ -90,4 +93,68 @@ function transformContent(content, srcPath) {
|
|
|
90
93
|
return content;
|
|
91
94
|
}
|
|
92
95
|
|
|
93
|
-
|
|
96
|
+
function transformAngularContent(content, srcPath) {
|
|
97
|
+
if (srcPath && /globals\.ts$/.test(srcPath)) {
|
|
98
|
+
return "export function initGlobals() { /* web shim: no-op */ }\n";
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (srcPath && /polyfills\.ts$/.test(srcPath)) {
|
|
102
|
+
return '';
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (srcPath && /app\.component\.html$/.test(srcPath)) {
|
|
106
|
+
return content.replace(/<\s*page-router-outlet\s*><\s*\/\s*page-router-outlet\s*>/g, '<router-outlet></router-outlet>');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (srcPath && /main\.ts$/.test(srcPath)) {
|
|
110
|
+
const routesImport = content.match(/import\s+\{\s*routes\s*\}\s+from\s+['"][^'"]+['"]\s*;?/);
|
|
111
|
+
const appCompImport = content.match(/import\s+\{\s*AppComponent\s*\}\s+from\s+['"][^'"]+['"]\s*;?/);
|
|
112
|
+
const needsHttp = /provideNativeScriptHttpClient/.test(content) || /provideHttpClient/.test(content);
|
|
113
|
+
const hasWithInterceptors = /withInterceptorsFromDi/.test(content);
|
|
114
|
+
|
|
115
|
+
const lines = [];
|
|
116
|
+
lines.push("import 'zone.js';");
|
|
117
|
+
lines.push("import { bootstrapApplication } from '@angular/platform-browser';");
|
|
118
|
+
lines.push("import { provideRouter } from '@angular/router';");
|
|
119
|
+
if (needsHttp) {
|
|
120
|
+
lines.push(
|
|
121
|
+
hasWithInterceptors
|
|
122
|
+
? "import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';"
|
|
123
|
+
: "import { provideHttpClient } from '@angular/common/http';"
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
if (routesImport) lines.push(routesImport[0].replace(/from\s+['"][^'"]+['"]/, "from './app/app.routes'"));
|
|
127
|
+
else lines.push("import { routes } from './app/app.routes';");
|
|
128
|
+
if (appCompImport) lines.push(appCompImport[0].replace(/from\s+['"][^'"]+['"]/, "from './app/app.component'"));
|
|
129
|
+
else lines.push("import { AppComponent } from './app/app.component';");
|
|
130
|
+
lines.push("import './app.css';");
|
|
131
|
+
lines.push('');
|
|
132
|
+
const providers = [];
|
|
133
|
+
if (needsHttp) {
|
|
134
|
+
providers.push(hasWithInterceptors ? 'provideHttpClient(withInterceptorsFromDi())' : 'provideHttpClient()');
|
|
135
|
+
}
|
|
136
|
+
providers.push('provideRouter(routes)');
|
|
137
|
+
lines.push(`bootstrapApplication(AppComponent, { providers: [${providers.join(', ')}] });`);
|
|
138
|
+
lines.push('');
|
|
139
|
+
return lines.join('\n');
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
content = content.replace(/import\s+['"]@nativescript\/core\/globals['"];?\n?/g, '');
|
|
143
|
+
content = content.replace(/import\s+['"]@nativescript\/angular\/polyfills['"];?\n?/g, '');
|
|
144
|
+
|
|
145
|
+
content = content.replace(/import\s+[\s\S]*?from\s+['"]@nativescript\/angular['"];?\n?/g, (m) => {
|
|
146
|
+
if (/^\s*import\s*\{\s*Routes\s*\}\s*from\s*['"]@angular\/router['"]/.test(m)) return m;
|
|
147
|
+
return m;
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
content = content.replace(/registerElement\([^)]+\);?\n?/g, '');
|
|
151
|
+
|
|
152
|
+
content = content.replace(/import\s+\{[\s\S]*?\}\s+from\s+['"]@triniwiz\/nativescript-masonkit\/web['"];?\n?/g, '');
|
|
153
|
+
content = content.replace(/import\s+\{[\s\S]*?\}\s+from\s+['"]@triniwiz\/nativescript-masonkit['"];?\n?/g, '');
|
|
154
|
+
|
|
155
|
+
content = content.replace(/from\s+['"]@nativescript\/core['"]/g, "from 'nativescript-web-adapter'");
|
|
156
|
+
|
|
157
|
+
return content;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
module.exports = { transformContent };
|