@nativescript/vite 0.0.1 → 0.0.2
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/LICENSE +19 -0
- package/README.md +44 -0
- package/{dist/configuration → configuration}/angular.d.ts +1 -1
- package/configuration/angular.js +480 -0
- package/configuration/angular.js.map +1 -0
- package/configuration/base.d.ts +5 -0
- package/configuration/base.js +494 -0
- package/configuration/base.js.map +1 -0
- package/configuration/javascript.d.ts +4 -0
- package/configuration/javascript.js +151 -0
- package/configuration/javascript.js.map +1 -0
- package/{dist/configuration → configuration}/react.d.ts +1 -1
- package/{dist/configuration → configuration}/react.js +18 -17
- package/configuration/react.js.map +1 -0
- package/{dist/configuration → configuration}/solid.d.ts +1 -1
- package/{dist/configuration → configuration}/solid.js +17 -16
- package/configuration/solid.js.map +1 -0
- package/configuration/typescript.d.ts +4 -0
- package/configuration/typescript.js +175 -0
- package/configuration/typescript.js.map +1 -0
- package/{dist/configuration → configuration}/vue.d.ts +1 -1
- package/configuration/vue.js +163 -0
- package/configuration/vue.js.map +1 -0
- package/helpers/angular-linker.d.ts +13 -0
- package/helpers/angular-linker.js +181 -0
- package/helpers/angular-linker.js.map +1 -0
- package/helpers/cli-flags.d.ts +1 -0
- package/helpers/cli-flags.js +15 -0
- package/helpers/cli-flags.js.map +1 -0
- package/{dist/helpers → helpers}/commonjs-plugins.js +14 -13
- package/helpers/commonjs-plugins.js.map +1 -0
- package/{dist/helpers → helpers}/config-as-json.d.ts +1 -1
- package/{dist/helpers → helpers}/config-as-json.js +7 -6
- package/helpers/config-as-json.js.map +1 -0
- package/helpers/css-platform-plugin.d.ts +10 -0
- package/helpers/css-platform-plugin.js +76 -0
- package/helpers/css-platform-plugin.js.map +1 -0
- package/helpers/css-tree.js +22 -0
- package/helpers/css-tree.js.map +1 -0
- package/{dist/helpers → helpers}/dynamic-import-plugin.js +8 -7
- package/helpers/dynamic-import-plugin.js.map +1 -0
- package/helpers/esbuild-platform-resolver.d.ts +14 -0
- package/helpers/esbuild-platform-resolver.js +93 -0
- package/helpers/esbuild-platform-resolver.js.map +1 -0
- package/helpers/external-configs.d.ts +6 -0
- package/helpers/external-configs.js +34 -0
- package/helpers/external-configs.js.map +1 -0
- package/{dist/helpers → helpers}/flavor.d.ts +1 -0
- package/helpers/flavor.js +51 -0
- package/helpers/flavor.js.map +1 -0
- package/{dist/helpers → helpers}/global-defines.d.ts +11 -2
- package/helpers/global-defines.js +24 -0
- package/helpers/global-defines.js.map +1 -0
- package/helpers/logging.d.ts +13 -0
- package/helpers/logging.js +111 -0
- package/helpers/logging.js.map +1 -0
- package/helpers/main-entry.d.ts +10 -0
- package/helpers/main-entry.js +215 -0
- package/helpers/main-entry.js.map +1 -0
- package/{dist/helpers → helpers}/module-resolution.js +4 -3
- package/helpers/module-resolution.js.map +1 -0
- package/helpers/module-runner-patch.d.ts +3 -0
- package/helpers/module-runner-patch.js +63 -0
- package/helpers/module-runner-patch.js.map +1 -0
- package/helpers/nativeclass-transform.d.ts +7 -0
- package/helpers/nativeclass-transform.js +158 -0
- package/helpers/nativeclass-transform.js.map +1 -0
- package/helpers/nativeclass-transformer-plugin.d.ts +5 -0
- package/helpers/nativeclass-transformer-plugin.js +23 -0
- package/helpers/nativeclass-transformer-plugin.js.map +1 -0
- package/{dist/helpers → helpers}/nativescript-package-resolver.js +18 -17
- package/helpers/nativescript-package-resolver.js.map +1 -0
- package/helpers/ns-cli-plugins.d.ts +14 -0
- package/helpers/ns-cli-plugins.js +165 -0
- package/helpers/ns-cli-plugins.js.map +1 -0
- package/helpers/package-platform-aliases.d.ts +10 -0
- package/{dist/helpers → helpers}/package-platform-aliases.js +19 -23
- package/helpers/package-platform-aliases.js.map +1 -0
- package/helpers/postcss-platform-config.d.ts +13 -0
- package/helpers/postcss-platform-config.js +97 -0
- package/helpers/postcss-platform-config.js.map +1 -0
- package/helpers/prelink-angular.d.ts +2 -0
- package/helpers/prelink-angular.js +117 -0
- package/helpers/prelink-angular.js.map +1 -0
- package/helpers/preserve-imports.d.ts +2 -0
- package/helpers/preserve-imports.js +38 -0
- package/helpers/preserve-imports.js.map +1 -0
- package/{dist/helpers → helpers}/project.js +2 -4
- package/helpers/project.js.map +1 -0
- package/helpers/resolver.d.ts +4 -0
- package/{dist/helpers → helpers}/resolver.js +7 -6
- package/helpers/resolver.js.map +1 -0
- package/helpers/theme-core-plugins.d.ts +14 -0
- package/helpers/theme-core-plugins.js +121 -0
- package/helpers/theme-core-plugins.js.map +1 -0
- package/helpers/ts-config-paths.d.ts +10 -0
- package/{dist/helpers → helpers}/ts-config-paths.js +73 -72
- package/helpers/ts-config-paths.js.map +1 -0
- package/{dist/helpers → helpers}/utils.d.ts +6 -0
- package/{dist/helpers → helpers}/utils.js +28 -34
- package/helpers/utils.js.map +1 -0
- package/{dist/helpers → helpers}/workers.js +15 -16
- package/helpers/workers.js.map +1 -0
- package/hmr/client/css-handler.d.ts +4 -0
- package/hmr/client/css-handler.js +78 -0
- package/hmr/client/css-handler.js.map +1 -0
- package/hmr/client/index.d.ts +13 -0
- package/hmr/client/index.js +1550 -0
- package/hmr/client/index.js.map +1 -0
- package/hmr/client/utils.d.ts +38 -0
- package/hmr/client/utils.js +426 -0
- package/hmr/client/utils.js.map +1 -0
- package/hmr/entry-runtime.d.ts +8 -0
- package/hmr/entry-runtime.js +135 -0
- package/hmr/entry-runtime.js.map +1 -0
- package/hmr/frameworks/angular/server/strategy.d.ts +2 -0
- package/hmr/frameworks/angular/server/strategy.js +101 -0
- package/hmr/frameworks/angular/server/strategy.js.map +1 -0
- package/hmr/frameworks/vue/client/index.d.ts +22 -0
- package/hmr/frameworks/vue/client/index.js +1537 -0
- package/hmr/frameworks/vue/client/index.js.map +1 -0
- package/hmr/frameworks/vue/server/compiler.d.ts +11 -0
- package/hmr/frameworks/vue/server/compiler.js +26 -0
- package/hmr/frameworks/vue/server/compiler.js.map +1 -0
- package/hmr/frameworks/vue/server/sfc-transforms.d.ts +14 -0
- package/hmr/frameworks/vue/server/sfc-transforms.js +282 -0
- package/hmr/frameworks/vue/server/sfc-transforms.js.map +1 -0
- package/hmr/frameworks/vue/server/strategy.d.ts +2 -0
- package/hmr/frameworks/vue/server/strategy.js +273 -0
- package/hmr/frameworks/vue/server/strategy.js.map +1 -0
- package/hmr/helpers/ast-extract.d.ts +6 -0
- package/hmr/helpers/ast-extract.js +72 -0
- package/hmr/helpers/ast-extract.js.map +1 -0
- package/hmr/helpers/ast-normalizer.d.ts +7 -0
- package/hmr/helpers/ast-normalizer.js +772 -0
- package/hmr/helpers/ast-normalizer.js.map +1 -0
- package/hmr/helpers/babel.d.ts +3 -0
- package/hmr/helpers/babel.js +17 -0
- package/hmr/helpers/babel.js.map +1 -0
- package/hmr/helpers/sanitize.d.ts +6 -0
- package/hmr/helpers/sanitize.js +55 -0
- package/hmr/helpers/sanitize.js.map +1 -0
- package/hmr/helpers/vendor-rewrite.d.ts +1 -0
- package/hmr/helpers/vendor-rewrite.js +35 -0
- package/hmr/helpers/vendor-rewrite.js.map +1 -0
- package/hmr/server/compiler.d.ts +2 -0
- package/hmr/server/compiler.js +75 -0
- package/hmr/server/compiler.js.map +1 -0
- package/hmr/server/constants.d.ts +14 -0
- package/hmr/server/constants.js +23 -0
- package/hmr/server/constants.js.map +1 -0
- package/hmr/server/core-sanitize.d.ts +32 -0
- package/hmr/server/core-sanitize.js +134 -0
- package/hmr/server/core-sanitize.js.map +1 -0
- package/hmr/server/framework-strategy.d.ts +68 -0
- package/hmr/server/framework-strategy.js +2 -0
- package/hmr/server/framework-strategy.js.map +1 -0
- package/hmr/server/index.d.ts +5 -0
- package/hmr/server/index.js +19 -0
- package/hmr/server/index.js.map +1 -0
- package/hmr/server/vite-plugin.d.ts +5 -0
- package/hmr/server/vite-plugin.js +44 -0
- package/hmr/server/vite-plugin.js.map +1 -0
- package/hmr/server/websocket.d.ts +15 -0
- package/hmr/server/websocket.js +5528 -0
- package/hmr/server/websocket.js.map +1 -0
- package/hmr/shared/runtime/http-only-boot.d.ts +1 -0
- package/hmr/shared/runtime/http-only-boot.js +107 -0
- package/hmr/shared/runtime/http-only-boot.js.map +1 -0
- package/hmr/shared/runtime/root-placeholder.d.ts +1 -0
- package/hmr/shared/runtime/root-placeholder.js +142 -0
- package/hmr/shared/runtime/root-placeholder.js.map +1 -0
- package/hmr/shared/runtime/vendor-bootstrap.d.ts +1 -0
- package/hmr/shared/runtime/vendor-bootstrap.js +134 -0
- package/hmr/shared/runtime/vendor-bootstrap.js.map +1 -0
- package/hmr/shared/vendor/manifest-loader.d.ts +9 -0
- package/hmr/shared/vendor/manifest-loader.js +38 -0
- package/hmr/shared/vendor/manifest-loader.js.map +1 -0
- package/hmr/shared/vendor/manifest.d.ts +34 -0
- package/hmr/shared/vendor/manifest.js +787 -0
- package/hmr/shared/vendor/manifest.js.map +1 -0
- package/hmr/shared/vendor/registry.d.ts +9 -0
- package/hmr/shared/vendor/registry.js +62 -0
- package/hmr/shared/vendor/registry.js.map +1 -0
- package/hmr/vendor-bootstrap.d.ts +3 -0
- package/hmr/vendor-bootstrap.js +32 -0
- package/hmr/vendor-bootstrap.js.map +1 -0
- package/{dist/index.d.ts → index.d.ts} +2 -0
- package/{dist/index.js → index.js} +3 -0
- package/index.js.map +1 -0
- package/package.json +39 -30
- package/{dist/polyfills → polyfills}/mdn-data-at-rules.js +1 -0
- package/polyfills/mdn-data-at-rules.js.map +1 -0
- package/{dist/polyfills → polyfills}/mdn-data-properties.js +1 -0
- package/polyfills/mdn-data-properties.js.map +1 -0
- package/{dist/polyfills → polyfills}/mdn-data-syntaxes.js +1 -0
- package/polyfills/mdn-data-syntaxes.js.map +1 -0
- package/{dist/polyfills → polyfills}/module.js +1 -0
- package/polyfills/module.js.map +1 -0
- package/runtime/core-aliases-early.d.ts +1 -0
- package/runtime/core-aliases-early.js +334 -0
- package/runtime/core-aliases-early.js.map +1 -0
- package/shims/angular-animations-stub.d.ts +8 -0
- package/shims/angular-animations-stub.js +14 -0
- package/shims/angular-animations-stub.js.map +1 -0
- package/shims/node-module.d.ts +5 -0
- package/shims/node-module.js +13 -0
- package/shims/node-module.js.map +1 -0
- package/{dist/shims → shims}/react-reconciler-constants.js +2 -1
- package/shims/react-reconciler-constants.js.map +1 -0
- package/{dist/shims → shims}/react-reconciler.js +1 -0
- package/shims/react-reconciler.js.map +1 -0
- package/{dist/shims → shims}/set-value.js +5 -1
- package/shims/set-value.js.map +1 -0
- package/transformers/NativeClass/index.d.ts +2 -0
- package/transformers/NativeClass/index.js +222 -0
- package/transformers/NativeClass/index.js.map +1 -0
- package/dist/configuration/angular.js +0 -30
- package/dist/configuration/base.d.ts +0 -13
- package/dist/configuration/base.js +0 -228
- package/dist/configuration/old-without-merge-base.d.ts +0 -13
- package/dist/configuration/old-without-merge-base.js +0 -249
- package/dist/configuration/vue.js +0 -45
- package/dist/helpers/css-tree.js +0 -21
- package/dist/helpers/flavor.js +0 -40
- package/dist/helpers/global-defines.js +0 -18
- package/dist/helpers/main-entry.d.ts +0 -5
- package/dist/helpers/main-entry.js +0 -75
- package/dist/helpers/ns-cli-plugins.d.ts +0 -17
- package/dist/helpers/ns-cli-plugins.js +0 -128
- package/dist/helpers/package-platform-aliases.d.ts +0 -4
- package/dist/helpers/resolver.d.ts +0 -4
- package/dist/helpers/ts-config-paths.d.ts +0 -4
- package/dist/hmr/hmr-angular.d.ts +0 -1
- package/dist/hmr/hmr-angular.js +0 -34
- package/dist/hmr/hmr-bridge.d.ts +0 -18
- package/dist/hmr/hmr-bridge.js +0 -154
- package/dist/hmr/hmr-client.d.ts +0 -5
- package/dist/hmr/hmr-client.js +0 -93
- package/dist/hmr/hmr-server.d.ts +0 -20
- package/dist/hmr/hmr-server.js +0 -179
- package/dist/transformers/NativeClass/index.d.ts +0 -5
- package/dist/transformers/NativeClass/index.js +0 -46
- /package/{dist/helpers → helpers}/commonjs-plugins.d.ts +0 -0
- /package/{dist/helpers → helpers}/css-tree.d.ts +0 -0
- /package/{dist/helpers → helpers}/dynamic-import-plugin.d.ts +0 -0
- /package/{dist/helpers → helpers}/module-resolution.d.ts +0 -0
- /package/{dist/helpers → helpers}/nativescript-package-resolver.d.ts +0 -0
- /package/{dist/helpers → helpers}/project.d.ts +0 -0
- /package/{dist/helpers → helpers}/workers.d.ts +0 -0
- /package/{dist/polyfills → polyfills}/mdn-data-at-rules.d.ts +0 -0
- /package/{dist/polyfills → polyfills}/mdn-data-properties.d.ts +0 -0
- /package/{dist/polyfills → polyfills}/mdn-data-syntaxes.d.ts +0 -0
- /package/{dist/polyfills → polyfills}/module.d.ts +0 -0
- /package/{dist/shims → shims}/react-reconciler-constants.d.ts +0 -0
- /package/{dist/shims → shims}/react-reconciler.d.ts +0 -0
- /package/{dist/shims → shims}/set-value.d.ts +0 -0
package/dist/hmr/hmr-server.js
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NativeScript True HMR Implementation
|
|
3
|
-
*
|
|
4
|
-
* This creates a bridge between Vite's dev server HMR and NativeScript runtime
|
|
5
|
-
* to enable true hot module replacement without losing application state.
|
|
6
|
-
*/
|
|
7
|
-
import { createServer } from 'vite';
|
|
8
|
-
import { spawn } from 'child_process';
|
|
9
|
-
import { WebSocketServer, WebSocket } from 'ws';
|
|
10
|
-
import path from 'path';
|
|
11
|
-
import fs from 'fs';
|
|
12
|
-
import { getProjectFilePath } from '../helpers/project.js';
|
|
13
|
-
const HMR_WS_PORT = 24678; // Different from Vite's default
|
|
14
|
-
const VITE_DEV_PORT = 5173;
|
|
15
|
-
class NativeScriptHMRServer {
|
|
16
|
-
constructor() {
|
|
17
|
-
this.connectedClients = new Set();
|
|
18
|
-
}
|
|
19
|
-
async start() {
|
|
20
|
-
console.log('🔥 Starting NativeScript True HMR...');
|
|
21
|
-
// 1. Start Vite dev server for true HMR
|
|
22
|
-
await this.startViteDevServer();
|
|
23
|
-
// 2. Start WebSocket bridge for NativeScript
|
|
24
|
-
await this.startHMRBridge();
|
|
25
|
-
// 3. Start build process for NativeScript integration
|
|
26
|
-
await this.startBuildProcess();
|
|
27
|
-
console.log('🔥 True HMR ready! Connect your NativeScript app.');
|
|
28
|
-
}
|
|
29
|
-
async startViteDevServer() {
|
|
30
|
-
console.log('🔥 Starting Vite dev server...');
|
|
31
|
-
this.viteServer = await createServer({
|
|
32
|
-
configFile: getProjectFilePath('vite.config.ts'),
|
|
33
|
-
server: {
|
|
34
|
-
port: VITE_DEV_PORT,
|
|
35
|
-
hmr: {
|
|
36
|
-
port: VITE_DEV_PORT + 1, // Vite's internal HMR port
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
mode: 'ios' // or get from args
|
|
40
|
-
});
|
|
41
|
-
await this.viteServer.listen();
|
|
42
|
-
console.log(`🔥 Vite dev server running on http://localhost:${VITE_DEV_PORT}`);
|
|
43
|
-
// Hook into Vite's HMR system
|
|
44
|
-
this.viteServer.ws.on('send', (data) => {
|
|
45
|
-
this.handleViteHMRMessage(data);
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
async startHMRBridge() {
|
|
49
|
-
console.log('🔥 Starting HMR WebSocket bridge...');
|
|
50
|
-
this.wsServer = new WebSocketServer({ port: HMR_WS_PORT });
|
|
51
|
-
this.wsServer.on('connection', (ws) => {
|
|
52
|
-
console.log('🔥 NativeScript client connected to HMR bridge');
|
|
53
|
-
this.connectedClients.add(ws);
|
|
54
|
-
// Send connection confirmation
|
|
55
|
-
ws.send(JSON.stringify({
|
|
56
|
-
type: 'connected',
|
|
57
|
-
timestamp: Date.now()
|
|
58
|
-
}));
|
|
59
|
-
ws.on('close', () => {
|
|
60
|
-
console.log('🔥 NativeScript client disconnected');
|
|
61
|
-
this.connectedClients.delete(ws);
|
|
62
|
-
});
|
|
63
|
-
ws.on('message', (message) => {
|
|
64
|
-
try {
|
|
65
|
-
const data = JSON.parse(message.toString());
|
|
66
|
-
console.log('🔥 Received from NativeScript:', data);
|
|
67
|
-
}
|
|
68
|
-
catch (e) {
|
|
69
|
-
console.error('🔥 Invalid message from NativeScript:', e);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
console.log(`🔥 HMR bridge listening on ws://localhost:${HMR_WS_PORT}`);
|
|
74
|
-
}
|
|
75
|
-
handleViteHMRMessage(data) {
|
|
76
|
-
if (!data || typeof data !== 'object')
|
|
77
|
-
return;
|
|
78
|
-
// Filter out irrelevant file changes
|
|
79
|
-
if (data.updates) {
|
|
80
|
-
const relevantUpdates = data.updates.filter(update => {
|
|
81
|
-
const path = update.path || '';
|
|
82
|
-
return (path.includes('/src/') ||
|
|
83
|
-
path.endsWith('package.json') ||
|
|
84
|
-
path.endsWith('vite.config.ts') ||
|
|
85
|
-
path.endsWith('tsconfig.json') ||
|
|
86
|
-
path.endsWith('nativescript.config.ts'));
|
|
87
|
-
});
|
|
88
|
-
if (relevantUpdates.length === 0) {
|
|
89
|
-
console.log('🔥 Ignoring HMR update for non-src files');
|
|
90
|
-
return; // Skip if no relevant updates
|
|
91
|
-
}
|
|
92
|
-
data.updates = relevantUpdates;
|
|
93
|
-
}
|
|
94
|
-
console.log('🔥 Vite HMR update:', data);
|
|
95
|
-
// Transform Vite HMR message to NativeScript format
|
|
96
|
-
let hmrUpdate;
|
|
97
|
-
if (data.type === 'update') {
|
|
98
|
-
// CSS updates
|
|
99
|
-
const cssUpdates = data.updates?.filter(u => u.path.endsWith('.css') || u.path.endsWith('.scss'));
|
|
100
|
-
if (cssUpdates?.length > 0) {
|
|
101
|
-
hmrUpdate = {
|
|
102
|
-
type: 'css-update',
|
|
103
|
-
path: cssUpdates[0].path,
|
|
104
|
-
timestamp: Date.now(),
|
|
105
|
-
updates: cssUpdates
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
// JS/TS updates
|
|
109
|
-
else {
|
|
110
|
-
hmrUpdate = {
|
|
111
|
-
type: 'js-update',
|
|
112
|
-
timestamp: Date.now(),
|
|
113
|
-
updates: data.updates
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
else if (data.type === 'full-reload') {
|
|
118
|
-
hmrUpdate = {
|
|
119
|
-
type: 'full-reload',
|
|
120
|
-
timestamp: Date.now()
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
return; // Ignore other message types
|
|
125
|
-
}
|
|
126
|
-
// Broadcast to connected NativeScript clients
|
|
127
|
-
this.broadcastToClients(hmrUpdate);
|
|
128
|
-
}
|
|
129
|
-
broadcastToClients(update) {
|
|
130
|
-
const message = JSON.stringify(update);
|
|
131
|
-
let sentCount = 0;
|
|
132
|
-
this.connectedClients.forEach((client) => {
|
|
133
|
-
if (client.readyState === WebSocket.OPEN) {
|
|
134
|
-
client.send(message);
|
|
135
|
-
sentCount++;
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
console.log(`🔥 Broadcasted ${update.type} to ${sentCount} clients`);
|
|
139
|
-
}
|
|
140
|
-
async startBuildProcess() {
|
|
141
|
-
// This runs the traditional build process for initial bundle creation
|
|
142
|
-
// but won't be used for HMR - that's handled by the dev server
|
|
143
|
-
console.log('🔥 Starting initial build process...');
|
|
144
|
-
// We might not need this if we can serve directly from Vite dev server
|
|
145
|
-
// But keeping it for compatibility with NativeScript CLI expectations
|
|
146
|
-
}
|
|
147
|
-
async stop() {
|
|
148
|
-
console.log('🔥 Stopping HMR server...');
|
|
149
|
-
if (this.viteServer) {
|
|
150
|
-
await this.viteServer.close();
|
|
151
|
-
}
|
|
152
|
-
if (this.wsServer) {
|
|
153
|
-
this.wsServer.close();
|
|
154
|
-
}
|
|
155
|
-
if (this.buildProcess) {
|
|
156
|
-
this.buildProcess.kill();
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
// CLI interface
|
|
161
|
-
async function main() {
|
|
162
|
-
const hmrServer = new NativeScriptHMRServer();
|
|
163
|
-
// Handle graceful shutdown
|
|
164
|
-
process.on('SIGINT', async () => {
|
|
165
|
-
await hmrServer.stop();
|
|
166
|
-
process.exit(0);
|
|
167
|
-
});
|
|
168
|
-
process.on('SIGTERM', async () => {
|
|
169
|
-
await hmrServer.stop();
|
|
170
|
-
process.exit(0);
|
|
171
|
-
});
|
|
172
|
-
await hmrServer.start();
|
|
173
|
-
}
|
|
174
|
-
// Export for use in other contexts
|
|
175
|
-
export { NativeScriptHMRServer };
|
|
176
|
-
// Run if called directly
|
|
177
|
-
// if (require.main === module) {
|
|
178
|
-
// main().catch(console.error);
|
|
179
|
-
// }
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
2
|
-
/**
|
|
3
|
-
* A TypeScript transform that compiles classes marked with `@NativeClass` as es5
|
|
4
|
-
*/
|
|
5
|
-
export default function (ctx) {
|
|
6
|
-
function isNativeClassExtension(node) {
|
|
7
|
-
let decorators;
|
|
8
|
-
if ('canHaveDecorators' in ts && ts.canHaveDecorators(node)) {
|
|
9
|
-
// use the newer decorators API when using a newer typescript version
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
decorators = ts.getDecorators(node);
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
// fallback to old behavior on older typescript versions
|
|
15
|
-
decorators = node.decorators;
|
|
16
|
-
}
|
|
17
|
-
return !!decorators?.some((d) => {
|
|
18
|
-
const fullText = d.getFullText().trim();
|
|
19
|
-
if (fullText.indexOf('@NativeClass') > -1) {
|
|
20
|
-
console.log('found @NativeClass decorator in:', fullText);
|
|
21
|
-
}
|
|
22
|
-
return fullText.indexOf('@NativeClass') > -1;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
function visitNode(node) {
|
|
26
|
-
if (ts.isClassDeclaration(node) && isNativeClassExtension(node)) {
|
|
27
|
-
return createHelper(node);
|
|
28
|
-
}
|
|
29
|
-
return ts.visitEachChild(node, visitNode, ctx);
|
|
30
|
-
}
|
|
31
|
-
function createHelper(node) {
|
|
32
|
-
// we remove the decorator for now!
|
|
33
|
-
return ts.factory.createIdentifier(ts
|
|
34
|
-
.transpileModule(node.getText().replace(/@NativeClass(\((.|\n)*?\))?/gm, ''), {
|
|
35
|
-
compilerOptions: {
|
|
36
|
-
noEmitHelpers: true,
|
|
37
|
-
module: ts.ModuleKind.ESNext,
|
|
38
|
-
target: ts.ScriptTarget.ES5,
|
|
39
|
-
experimentalDecorators: true,
|
|
40
|
-
emitDecoratorMetadata: true,
|
|
41
|
-
},
|
|
42
|
-
})
|
|
43
|
-
.outputText.replace(/(Object\.defineProperty\(.*?{.*?)(enumerable:\s*false)(.*?}\))/gs, '$1enumerable: true$3'));
|
|
44
|
-
}
|
|
45
|
-
return (source) => ts.factory.updateSourceFile(source, ts.visitNodes(source.statements, visitNode));
|
|
46
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|