tungsten 0.2.7 → 0.2.9
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/Components.d.ts +3 -1
- package/dist/Components.d.ts.map +1 -1
- package/dist/Components.js +100 -51
- package/dist/DomNodes.js +2 -2
- package/dist/FrameworkConfig.d.ts +2 -0
- package/dist/FrameworkConfig.d.ts.map +1 -1
- package/dist/FunctionComponentStandIn.d.ts +2 -0
- package/dist/FunctionComponentStandIn.d.ts.map +1 -1
- package/dist/FunctionComponentStandIn.js +16 -3
- package/dist/Instance/ClientRuntimeContext.d.ts +8 -0
- package/dist/Instance/ClientRuntimeContext.d.ts.map +1 -0
- package/dist/Instance/ClientRuntimeContext.js +1 -0
- package/dist/Instance/Instance.d.ts +20 -1
- package/dist/Instance/Instance.d.ts.map +1 -1
- package/dist/Instance/Instance.js +59 -11
- package/dist/Servers/loadEnvsDev.d.ts +1 -1
- package/dist/Servers/loadEnvsDev.d.ts.map +1 -1
- package/dist/Servers/loadEnvsDev.js +18 -3
- package/dist/Store/makeStore.d.ts.map +1 -1
- package/dist/Store/makeStore.js +7 -14
- package/dist/auth/passwordHashing.sxyt.js +2 -2
- package/dist/babelPlugins/BabelTransformPackageImports.d.ts +1 -0
- package/dist/babelPlugins/BabelTransformPackageImports.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformPackageImports.js +109 -70
- package/dist/bin/commands/compile.sxyt.js +76 -1
- package/dist/build/compileJavascript.d.ts.map +1 -1
- package/dist/build/compileJavascript.js +13 -1
- package/dist/build/makeBabelUserDevConfig.d.ts +1 -1
- package/dist/build/makeBabelUserDevConfig.d.ts.map +1 -1
- package/dist/build/makeBabelUserDevConfig.js +2 -1
- package/dist/componentProxyHandlers.d.ts +2 -2
- package/dist/componentProxyHandlers.d.ts.map +1 -1
- package/dist/componentProxyHandlers.js +70 -44
- package/dist/componentProxyHandlers.sxyt.d.ts +2 -0
- package/dist/componentProxyHandlers.sxyt.d.ts.map +1 -0
- package/dist/componentProxyHandlers.sxyt.js +130 -0
- package/dist/findUserConfig.d.ts +1 -1
- package/dist/findUserConfig.d.ts.map +1 -1
- package/dist/findUserConfig.js +2 -2
- package/dist/frameworkConfigSchema.d.ts +4 -0
- package/dist/frameworkConfigSchema.d.ts.map +1 -1
- package/dist/frameworkConfigSchema.js +1 -0
- package/dist/getUserConfig.d.ts +1 -1
- package/dist/getUserConfig.d.ts.map +1 -1
- package/dist/getUserConfig.js +2 -2
- package/dist/hooks/useState.js +1 -1
- package/dist/indexInner.d.ts +0 -1
- package/dist/indexInner.d.ts.map +1 -1
- package/dist/indexInner.js +1 -1
- package/dist/update/UpdateScheduler.d.ts +17 -0
- package/dist/update/UpdateScheduler.d.ts.map +1 -0
- package/dist/update/UpdateScheduler.js +113 -0
- package/dist/update/integrateUpdateVdom.d.ts +11 -1
- package/dist/update/integrateUpdateVdom.d.ts.map +1 -1
- package/dist/update/integrateUpdateVdom.js +117 -59
- package/dist/{react-zone.d.ts → zones/react.d.ts} +5 -5
- package/dist/zones/react.d.ts.map +1 -0
- package/dist/{react-zone.js → zones/react.js} +3 -3
- package/package.json +7 -4
- package/readme.md +80 -0
- package/dist/react-zone.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Instance.d.ts","sourceRoot":"","sources":["../../src/Instance/Instance.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAElE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AACrE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAE,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EtC;IACD,QAAQ,GAAI,OAAO,MAAM,UAIxB;IACD,iBAAiB,aAEhB;IAKD,WAAW,GAAI,WAAW,MAAM,GAAG;QAC/B,QAAQ,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;QAChC,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAC7B,aAYA;IAED,SAAS,GAAI,MAAM,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,aAAa,MAAM,aAKjE;IAED,SAAS,GAAI,MAAM,MAAM,OAAO,EAAE,aAAa,MAAM,UAIpD;IAED,iBAAiB,GAAI,WAAW,mBAAmB,UAElD;IAED,mBAAmB,GAAI,WAAW,mBAAmB,UAGpD;IAED,2BAA2B,aAM1B;CACJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
2
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
3
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
-
import { isClient } from "../isClient.js";
|
|
4
|
+
import { isClient as processIsClient } from "../isClient.js";
|
|
5
5
|
import { routing } from "../Servers/routing.js";
|
|
6
6
|
import { RoutingRedirect } from "../routing/RoutingRedirect.js";
|
|
7
7
|
import { throwError } from "../throwError.js";
|
|
@@ -10,14 +10,14 @@ import { isProd } from "../isProd.js";
|
|
|
10
10
|
import { WebRedirect } from "../routing/WebRedirect.js";
|
|
11
11
|
import { RouteRedirectComponent } from "../components/RouteRedirectComponent.js";
|
|
12
12
|
import { WebRedirectComponent } from "../components/WebRedirectComponent.js";
|
|
13
|
-
import { isServer } from "../isServer.js";
|
|
13
|
+
import { isServer as processIsServer } from "../isServer.js";
|
|
14
14
|
import { ContentNodeIsClassComponent } from "../ContentNode.js";
|
|
15
15
|
import { $props, $type } from "../contentNodeSymbols.js";
|
|
16
16
|
export class Instance {
|
|
17
17
|
constructor(_location, instanceConfig, reqRes, appRoutes, routes,
|
|
18
18
|
//globalData: GlobalData,
|
|
19
19
|
//matchedRouteInfo: MatchedRouteInfo
|
|
20
|
-
internalStore, stores, storeSubscriptions, globalData, _matchedRouteInfo) {
|
|
20
|
+
internalStore, stores, storeSubscriptions, globalData, _matchedRouteInfo, runtimeContext) {
|
|
21
21
|
_defineProperty(this, "location", void 0);
|
|
22
22
|
_defineProperty(this, "reqRes", void 0);
|
|
23
23
|
_defineProperty(this, "appRoutes", void 0);
|
|
@@ -39,6 +39,10 @@ export class Instance {
|
|
|
39
39
|
_defineProperty(this, "matchedRouteInfo", void 0);
|
|
40
40
|
_defineProperty(this, "persistentHeadChildren", void 0);
|
|
41
41
|
_defineProperty(this, "navigating", false);
|
|
42
|
+
_defineProperty(this, "runtimeContext", void 0);
|
|
43
|
+
_defineProperty(this, "isClient", void 0);
|
|
44
|
+
_defineProperty(this, "isServer", void 0);
|
|
45
|
+
_defineProperty(this, "registeredComponents", []);
|
|
42
46
|
_defineProperty(this, "getRoutes", () => {
|
|
43
47
|
return typeof this.appRoutes === 'function' ? this.appRoutes(this.reqRes) : this.appRoutes;
|
|
44
48
|
});
|
|
@@ -90,7 +94,10 @@ export class Instance {
|
|
|
90
94
|
this.matchedRouteInfo = matchedRouteInfo;
|
|
91
95
|
const publicUrl = isProd && this.config.staticSite === true // add .html suffix for static sites
|
|
92
96
|
? routeKey === '/' ? '/' : routeKey + '.html' : routeKey;
|
|
93
|
-
if (isClient)
|
|
97
|
+
if (this.isClient) {
|
|
98
|
+
const runtimeWindow = this.runtimeContext?.window ?? window;
|
|
99
|
+
runtimeWindow.history.pushState(null, '', this.config.siteBasePath + publicUrl);
|
|
100
|
+
}
|
|
94
101
|
this.setTitleToDefault();
|
|
95
102
|
this.updateLocation(routeKey); // this.internalStore.set('location', to)
|
|
96
103
|
//this.finishedNavigating()
|
|
@@ -105,11 +112,12 @@ export class Instance {
|
|
|
105
112
|
// }
|
|
106
113
|
_defineProperty(this, "redirect", (url, code = 302) => {
|
|
107
114
|
if (this.reqRes) {
|
|
108
|
-
console.assert(isServer, 'reqRes is set, expected isServer to be truth');
|
|
115
|
+
console.assert(this.isServer, 'reqRes is set, expected isServer to be truth');
|
|
109
116
|
this.reqRes.res.redirect(code, url);
|
|
110
117
|
} else {
|
|
111
|
-
console.assert(isClient, 'reqRes is not set, expected isClient to be truthy');
|
|
112
|
-
window
|
|
118
|
+
console.assert(this.isClient, 'reqRes is not set, expected isClient to be truthy');
|
|
119
|
+
const runtimeWindow = this.runtimeContext?.window ?? window;
|
|
120
|
+
runtimeWindow.location.replace(url);
|
|
113
121
|
}
|
|
114
122
|
});
|
|
115
123
|
_defineProperty(this, "setDefaultTitle", defaultTitle => {
|
|
@@ -118,11 +126,47 @@ export class Instance {
|
|
|
118
126
|
_defineProperty(this, "setTitle", title => {
|
|
119
127
|
//console.log('Setting title to', title)
|
|
120
128
|
this.title = title;
|
|
121
|
-
if (isClient) document.title = title;
|
|
129
|
+
if (this.isClient) (this.runtimeContext?.document ?? document).title = title;
|
|
122
130
|
});
|
|
123
131
|
_defineProperty(this, "setTitleToDefault", () => {
|
|
124
132
|
this.setTitle(this.defaultTitle);
|
|
125
133
|
});
|
|
134
|
+
// registerStore = (storeClass: typeof BaseStore) => {
|
|
135
|
+
// TungstenComponent.prototype.storeClass = storeClass
|
|
136
|
+
// }
|
|
137
|
+
_defineProperty(this, "queueUpdate", component => {
|
|
138
|
+
const scheduler = this.runtimeContext?.scheduler;
|
|
139
|
+
if (scheduler === undefined) return false;
|
|
140
|
+
scheduler.enqueueUpdate(component, async () => {
|
|
141
|
+
if (component.__unmountStarted === true) return;
|
|
142
|
+
await component.__update();
|
|
143
|
+
}, `${component.constructor.name} update`);
|
|
144
|
+
return true;
|
|
145
|
+
});
|
|
146
|
+
_defineProperty(this, "queueTask", (task, description) => {
|
|
147
|
+
const scheduler = this.runtimeContext?.scheduler;
|
|
148
|
+
if (scheduler === undefined) return false;
|
|
149
|
+
scheduler.enqueueTask(task, description);
|
|
150
|
+
return true;
|
|
151
|
+
});
|
|
152
|
+
_defineProperty(this, "trackWork", (task, description) => {
|
|
153
|
+
const scheduler = this.runtimeContext?.scheduler;
|
|
154
|
+
if (scheduler !== undefined) scheduler.trackWork(task, description);else task();
|
|
155
|
+
});
|
|
156
|
+
_defineProperty(this, "registerComponent", component => {
|
|
157
|
+
this.registeredComponents.push(component);
|
|
158
|
+
});
|
|
159
|
+
_defineProperty(this, "unregisterComponent", component => {
|
|
160
|
+
const index = this.registeredComponents.indexOf(component);
|
|
161
|
+
if (index >= 0) this.registeredComponents.splice(index, 1);
|
|
162
|
+
});
|
|
163
|
+
_defineProperty(this, "disposeRegisteredComponents", () => {
|
|
164
|
+
for (const component of [...this.registeredComponents].reverse()) {
|
|
165
|
+
component.__delete();
|
|
166
|
+
component.__deleted();
|
|
167
|
+
}
|
|
168
|
+
this.registeredComponents.length = 0;
|
|
169
|
+
});
|
|
126
170
|
// console.log('isClient', isClient)
|
|
127
171
|
// console.log('location', location)
|
|
128
172
|
//this.internalStore = new Store
|
|
@@ -138,12 +182,16 @@ export class Instance {
|
|
|
138
182
|
this.matchedRouteInfo = _matchedRouteInfo;
|
|
139
183
|
this.config = instanceConfig; // createInstanceConfig(appConfig)
|
|
140
184
|
this.persistentHeadChildren = [];
|
|
185
|
+
this.runtimeContext = runtimeContext;
|
|
186
|
+
this.isClient = runtimeContext !== undefined ? true : processIsClient;
|
|
187
|
+
this.isServer = runtimeContext !== undefined ? false : processIsServer;
|
|
141
188
|
//if (AppClass === null) throwError('Instance', 'AppClass is null, did you register an '
|
|
142
|
-
if (isClient) {
|
|
143
|
-
window
|
|
189
|
+
if (this.isClient && (runtimeContext?.navigation ?? true)) {
|
|
190
|
+
const runtimeWindow = runtimeContext?.window ?? window;
|
|
191
|
+
runtimeWindow.addEventListener('popstate', event => {
|
|
144
192
|
//console.log('popstate', window.location.pathname)
|
|
145
193
|
//this.updateLocation(window.location.pathname)
|
|
146
|
-
const newLocation =
|
|
194
|
+
const newLocation = runtimeWindow.location.pathname;
|
|
147
195
|
if (!StringIsValidRouteKey(newLocation, routes)) {
|
|
148
196
|
throwError('Instance constructor', `new location 'newLocation' is not a route in the routes object`);
|
|
149
197
|
}
|
|
@@ -3,6 +3,6 @@ type ProcessEnv = {
|
|
|
3
3
|
[x: string]: string | undefined;
|
|
4
4
|
TZ?: string;
|
|
5
5
|
};
|
|
6
|
-
export declare function loadEnvsDev(config: FrameworkConfigComplete, iteration: number, initialProcessEnv: ProcessEnv, _firstLoad: boolean): Promise<void>;
|
|
6
|
+
export declare function loadEnvsDev(config: FrameworkConfigComplete, iteration: number, initialProcessEnv: ProcessEnv, _firstLoad: boolean, useTestEnvFiles?: boolean): Promise<void>;
|
|
7
7
|
export {};
|
|
8
8
|
//# sourceMappingURL=loadEnvsDev.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadEnvsDev.d.ts","sourceRoot":"","sources":["../../src/Servers/loadEnvsDev.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAQpE,KAAK,UAAU,GAAG;IACd,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAChC,EAAE,CAAC,EAAE,MAAM,CAAC;CACf,CAAA;AAED,wBAAsB,WAAW,CAC7B,MAAM,EAAE,uBAAuB,EAE/B,SAAS,EAAE,MAAM,EACjB,iBAAiB,EAAE,UAAU,EAC7B,UAAU,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"loadEnvsDev.d.ts","sourceRoot":"","sources":["../../src/Servers/loadEnvsDev.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAQpE,KAAK,UAAU,GAAG;IACd,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAChC,EAAE,CAAC,EAAE,MAAM,CAAC;CACf,CAAA;AAED,wBAAsB,WAAW,CAC7B,MAAM,EAAE,uBAAuB,EAE/B,SAAS,EAAE,MAAM,EACjB,iBAAiB,EAAE,UAAU,EAC7B,UAAU,EAAE,OAAO,EACnB,eAAe,UAAQ,iBAuH1B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { join } from 'path';
|
|
2
|
-
import { readFile as readFilePromise } from 'fs/promises';
|
|
2
|
+
import { readFile as readFilePromise, access as accessPromise } from 'fs/promises';
|
|
3
3
|
import { remap as objectRemap, filter as objectFilter } from 'sxy-lib/objects.js';
|
|
4
4
|
import { getEnvSchemasDev } from "../env/getEnvSchemas.js";
|
|
5
5
|
import { parseIni } from "../parseIni.js";
|
|
@@ -9,7 +9,7 @@ import { throwError } from 'tungsten/throwError.js';
|
|
|
9
9
|
import { tungstenCorePrivateEnvSchema } from "./tungstenCorePrivateEnvSchema.js";
|
|
10
10
|
export async function loadEnvsDev(config,
|
|
11
11
|
//load: Load,
|
|
12
|
-
iteration, initialProcessEnv, _firstLoad) {
|
|
12
|
+
iteration, initialProcessEnv, _firstLoad, useTestEnvFiles = false) {
|
|
13
13
|
//console.log('loadEnvsDev')
|
|
14
14
|
const tempEnv = {
|
|
15
15
|
...initialProcessEnv
|
|
@@ -20,7 +20,21 @@ iteration, initialProcessEnv, _firstLoad) {
|
|
|
20
20
|
const envLocation = join(projectDir, '.env');
|
|
21
21
|
const privateEnvLocation = join(projectDir, '.env.private');
|
|
22
22
|
const publicEnvLocation = join(projectDir, '.env.public');
|
|
23
|
+
const testEnvLocation = join(projectDir, '.env.test');
|
|
24
|
+
const testPrivateEnvLocation = join(projectDir, '.env.test.private');
|
|
25
|
+
const testPublicEnvLocation = join(projectDir, '.env.test.public');
|
|
23
26
|
let someEnvLoaded = false;
|
|
27
|
+
// In test mode, prefer the .env.test* variant of each file, falling back to
|
|
28
|
+
// the base file only when the .test variant is absent (per-file replacement).
|
|
29
|
+
const resolveEnvFile = async (basePath, testPath) => {
|
|
30
|
+
if (!useTestEnvFiles) return basePath;
|
|
31
|
+
try {
|
|
32
|
+
await accessPromise(testPath);
|
|
33
|
+
return testPath;
|
|
34
|
+
} catch {
|
|
35
|
+
return basePath;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
24
38
|
const tryLoadEnvFile = async (fileName, filePath, prefix = '') => {
|
|
25
39
|
try {
|
|
26
40
|
//cliOut(`try to load env from ${filePath}`)
|
|
@@ -38,7 +52,8 @@ iteration, initialProcessEnv, _firstLoad) {
|
|
|
38
52
|
}
|
|
39
53
|
}
|
|
40
54
|
};
|
|
41
|
-
await Promise.all([
|
|
55
|
+
const [envPath, privateEnvPath, publicEnvPath] = await Promise.all([resolveEnvFile(envLocation, testEnvLocation), resolveEnvFile(privateEnvLocation, testPrivateEnvLocation), resolveEnvFile(publicEnvLocation, testPublicEnvLocation)]);
|
|
56
|
+
await Promise.all([tryLoadEnvFile('.env', envPath), tryLoadEnvFile('.env.private', privateEnvPath), tryLoadEnvFile('.env.public', publicEnvPath, 'TUNGSTEN_PUBLIC_')]);
|
|
42
57
|
if (_firstLoad && !someEnvLoaded) cliOut('No env files were loaded');
|
|
43
58
|
//console.log('check for schemas')
|
|
44
59
|
// If there are env schemas, load the relevant env and parse with schemas
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"makeStore.d.ts","sourceRoot":"","sources":["../../src/Store/makeStore.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAC/B,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAA;AAGnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D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AAE,GAAG,CAAC,KAAK,IAAI,CAAA;QAChF,QAAQ,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,0BAA0B,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAAK,IAAI,CAAA;QAClF,QAAQ,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,0BAA0B,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAAK,MAAM,CAAC,QAAQ,CAAC,CAAA;KAC1F;CACJ,CAAA;AAGD,wBAAgB,SAAS,CAAC,MAAM,SAAS,MAAM,EAC3C,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,kBAAkB,EACtC,iBAAiB,GAAE,iBAAiB,GAAG,IAAW,GACnD,SAAS,CAAC,MAAM,CAAC,CASnB"}
|
package/dist/Store/makeStore.js
CHANGED
|
@@ -90,17 +90,13 @@ export class StoreValue {
|
|
|
90
90
|
}
|
|
91
91
|
});
|
|
92
92
|
_defineProperty(this, "subscribe", element => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (subscriptions === undefined) {
|
|
99
|
-
subscriptions = new Set();
|
|
100
|
-
_classPrivateFieldGet(_subscribedElements2, this).set(element, subscriptions);
|
|
101
|
-
}
|
|
102
|
-
subscriptions.add(_classPrivateFieldGet(_key2, this));
|
|
93
|
+
_classPrivateFieldGet(_subscribers2, this).add(element);
|
|
94
|
+
let subscriptions = _classPrivateFieldGet(_subscribedElements2, this).get(element);
|
|
95
|
+
if (subscriptions === undefined) {
|
|
96
|
+
subscriptions = new Set();
|
|
97
|
+
_classPrivateFieldGet(_subscribedElements2, this).set(element, subscriptions);
|
|
103
98
|
}
|
|
99
|
+
subscriptions.add(_classPrivateFieldGet(_key2, this));
|
|
104
100
|
});
|
|
105
101
|
_defineProperty(this, "unsubscribe", element => {
|
|
106
102
|
//console.log('StoreValue unsubscribe', this.#key, element)
|
|
@@ -112,10 +108,7 @@ export class StoreValue {
|
|
|
112
108
|
*/
|
|
113
109
|
});
|
|
114
110
|
_defineProperty(this, "sync", element => {
|
|
115
|
-
|
|
116
|
-
//if (isBrowser) this.#subscribers.add(element)
|
|
117
|
-
//this.#subscribers.add(element)
|
|
118
|
-
if (isBrowser) this.subscribe(element);
|
|
111
|
+
this.subscribe(element);
|
|
119
112
|
return _classPrivateFieldGet(_value2, this);
|
|
120
113
|
});
|
|
121
114
|
_classPrivateFieldSet(_key2, this, key);
|
|
@@ -7,7 +7,7 @@ describe('hashPassword()', ({
|
|
|
7
7
|
}) => {
|
|
8
8
|
it('hashes a password and returns a string', async () => {
|
|
9
9
|
const hashed = await hashPassword('abcd');
|
|
10
|
-
console.log('hashed: ' + hashed)
|
|
10
|
+
//console.log('hashed: ' + hashed)
|
|
11
11
|
expect(hashed).to.be.a('string');
|
|
12
12
|
expect(hashed.length).to.be.at.least(10);
|
|
13
13
|
});
|
|
@@ -19,7 +19,7 @@ describe('hashPasswordBytes()', ({
|
|
|
19
19
|
const hashedBytes = await hashPasswordBytes('abcd');
|
|
20
20
|
expect(hashedBytes).to.be.an.instanceOf(Buffer);
|
|
21
21
|
const hashedString = hashedBytes.toString();
|
|
22
|
-
console.log('hashedString: ' + hashedString)
|
|
22
|
+
//console.log('hashedString: ' + hashedString)
|
|
23
23
|
expect(hashedString).to.be.a('string');
|
|
24
24
|
expect(hashedString.length).to.be.at.least(10);
|
|
25
25
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BabelTransformPackageImports.d.ts","sourceRoot":"","sources":["../../src/babelPlugins/BabelTransformPackageImports.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"BabelTransformPackageImports.d.ts","sourceRoot":"","sources":["../../src/babelPlugins/BabelTransformPackageImports.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;A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GAC7C,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAmC,MAAM,CAAA;AAChF,MAAM,MAAM,oBAAoB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,KAAK,MAAM,CAAA;AACrF,MAAM,MAAM,gBAAgB,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,KAAK,MAAM,CAAA;AAsDzF,wBAAgB,gCAAgC,CAAC,IAAI,EAAE,IAAI;eAiyBpC,SAAS;;kCAkBmB,QAAQ,CAAC,iBAAiB,CAAC;;;EA0H7E"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1
4
|
// BabelTransformPackgeImports
|
|
2
5
|
// exports MakeBabelTransformPackgeImports (function)
|
|
3
6
|
//
|
|
@@ -9,7 +12,6 @@ import { join, dirname, relative } from 'path';
|
|
|
9
12
|
import slash from 'slash';
|
|
10
13
|
import precinct from 'precinct';
|
|
11
14
|
//import sxyPrecinct from 'sxy-precinct'
|
|
12
|
-
import cabinet from 'sxy-filing-cabinet';
|
|
13
15
|
import { existsSync, mkdirSync, promises as fsPromises, readFileSync, writeFileSync } from 'fs';
|
|
14
16
|
import { createRequire } from 'module';
|
|
15
17
|
import { transformFileAsync as babelTransformFileAsync, transformAsync as babelTransformAsync } from '@babel/core';
|
|
@@ -27,12 +29,23 @@ import { cliError, cliWarn, cliNote, cliInfo, cliNews } from "../cliOutput.js";
|
|
|
27
29
|
import { isBareImport } from "./isBareImport.js";
|
|
28
30
|
import { TungstenError } from "../TungstenError.js";
|
|
29
31
|
import { throwError } from "../throwError.js";
|
|
30
|
-
import { errorOut } from "../output.js";
|
|
31
32
|
//import { copyPackageModulesToPackagesFolder } from '../build/copyPackageModulesToPackagesFolder.js'
|
|
32
33
|
const require = createRequire(import.meta.url);
|
|
33
34
|
function debug(...texts) {
|
|
34
35
|
//console.log(...texts)
|
|
35
36
|
}
|
|
37
|
+
class UnsupportedCompiledDependencyError extends TungstenError {
|
|
38
|
+
constructor(dependency, importedFrom, importHistory, options) {
|
|
39
|
+
super(`Could not resolve ${dependency} from ${importedFrom}`);
|
|
40
|
+
_defineProperty(this, "dependency", void 0);
|
|
41
|
+
_defineProperty(this, "importedFrom", void 0);
|
|
42
|
+
_defineProperty(this, "importHistory", void 0);
|
|
43
|
+
this.dependency = dependency;
|
|
44
|
+
this.importedFrom = importedFrom;
|
|
45
|
+
this.importHistory = importHistory;
|
|
46
|
+
if (options?.cause !== undefined) this.cause = options.cause;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
36
49
|
const javascriptFileExtensions = ['.js', '.jsx', '.cjs', '.cjsx', '.mjs', '.mjsx', '.ts', '.tsx', '.cts', '.ctx', '.mts', '.mtsx'];
|
|
37
50
|
function hasJavascriptFileExtension(file) {
|
|
38
51
|
for (const ex of javascriptFileExtensions) {
|
|
@@ -140,7 +153,22 @@ export function MakeBabelTransformPackageImports(opts) {
|
|
|
140
153
|
return cache[key] = finalLocation;
|
|
141
154
|
}
|
|
142
155
|
};
|
|
143
|
-
function
|
|
156
|
+
function formatImportLocation(location) {
|
|
157
|
+
const normalized = slash(location);
|
|
158
|
+
const nodeModulesMarker = '/node_modules/';
|
|
159
|
+
const nodeModulesPosition = normalized.lastIndexOf(nodeModulesMarker);
|
|
160
|
+
if (nodeModulesPosition !== -1) {
|
|
161
|
+
return normalized.slice(nodeModulesPosition + nodeModulesMarker.length);
|
|
162
|
+
}
|
|
163
|
+
const projectRelative = slash(relative(opts.projectDir, location));
|
|
164
|
+
return projectRelative.startsWith('../') ? normalized : projectRelative;
|
|
165
|
+
}
|
|
166
|
+
function formatUnsupportedDependencyError(error) {
|
|
167
|
+
const history = [...error.importHistory, error.importedFrom].filter((location, index, locations) => index === 0 || location !== locations[index - 1]).map(formatImportLocation);
|
|
168
|
+
history.push(`${error.dependency} (unresolved)`);
|
|
169
|
+
return 'Your code that is compiled may depend on a node module - this is not allowed.' + `\nCould not resolve "${error.dependency}".` + `\nImport history:\n ${history.join('\n -> ')}`;
|
|
170
|
+
}
|
|
171
|
+
function resolvePrecinctDependencies(deps, file, sourceFilename, history) {
|
|
144
172
|
const out = [];
|
|
145
173
|
for (const dep of deps) {
|
|
146
174
|
if (dep.startsWith('node:')) continue;
|
|
@@ -152,21 +180,17 @@ export function MakeBabelTransformPackageImports(opts) {
|
|
|
152
180
|
}));
|
|
153
181
|
continue;
|
|
154
182
|
}
|
|
155
|
-
const f =
|
|
156
|
-
partial: dep,
|
|
157
|
-
filename: file,
|
|
158
|
-
directory: packageDir
|
|
159
|
-
});
|
|
160
|
-
if (f === '') throw new TungstenError(`resolvePrecinctDependencies() err: cabinet returned empty string for ${dep} in ${packageDir}`);
|
|
183
|
+
const f = getCjsRequire(file).resolve(dep);
|
|
161
184
|
out.push(f);
|
|
162
185
|
} catch (error) {
|
|
163
|
-
|
|
164
|
-
|
|
186
|
+
throw new UnsupportedCompiledDependencyError(dep, file, history.length === 0 ? [sourceFilename] : history, {
|
|
187
|
+
cause: error
|
|
188
|
+
});
|
|
165
189
|
}
|
|
166
190
|
}
|
|
167
191
|
return out;
|
|
168
192
|
}
|
|
169
|
-
function getFileDependencies(fileInfo,
|
|
193
|
+
function getFileDependencies(fileInfo, sourceFilename, history) {
|
|
170
194
|
const {
|
|
171
195
|
file
|
|
172
196
|
} = fileInfo;
|
|
@@ -177,7 +201,7 @@ export function MakeBabelTransformPackageImports(opts) {
|
|
|
177
201
|
//console.log('getFileDependencies', 'd', d)
|
|
178
202
|
return isBareImport(d) ? applyImportAliases(d, fileInfo.type) : d;
|
|
179
203
|
});
|
|
180
|
-
const resolved = resolvePrecinctDependencies(deps, file,
|
|
204
|
+
const resolved = resolvePrecinctDependencies(deps, file, sourceFilename, history);
|
|
181
205
|
return resolved;
|
|
182
206
|
}
|
|
183
207
|
function getFileEsmGenIntermediateCacheLocation(file, packageInfo) {
|
|
@@ -385,63 +409,62 @@ export function MakeBabelTransformPackageImports(opts) {
|
|
|
385
409
|
finalDest,
|
|
386
410
|
packageInfo
|
|
387
411
|
} = fileInfo;
|
|
388
|
-
try {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
}
|
|
414
|
-
} else {
|
|
415
|
-
try {
|
|
416
|
-
//if (file.endsWith('index.cjs')) console.log('trying to transform a *index.cjs file:', file)
|
|
417
|
-
const code = await babelFileCjs(file, cacheDest, finalDest, packageInfo, nonEsmDependenciesFull);
|
|
418
|
-
//console.log('writing file', cacheDest)
|
|
419
|
-
//console.log('writing file', finalDest)
|
|
420
|
-
//if (file.endsWith('index.cjs')) console.log('writing a transformed *index.cjs file to cache:', cacheDest)
|
|
421
|
-
await fsPromises.writeFile(cacheDest, code); // rel contains the slash at start
|
|
422
|
-
//if (file.endsWith('index.cjs')) console.log('writing a transformed *index.cjs file to final:', finalDest)
|
|
423
|
-
await fsPromises.writeFile(finalDest, code); // rel contains the slash at start
|
|
424
|
-
} catch (e) {
|
|
425
|
-
cliError(`Error transforming file '${file}' with babelFileCjs`);
|
|
426
|
-
throw e;
|
|
427
|
-
}
|
|
412
|
+
//try {
|
|
413
|
+
const dependencies = getFileDependencies(fileInfo, sourceFilename, history);
|
|
414
|
+
// cliInfo(`deps for ${file}`)
|
|
415
|
+
// cliInfo(dependencies)
|
|
416
|
+
const dependenciesFull = dependencies.map(d => resolveFile(d));
|
|
417
|
+
const nonEsmDependenciesFull = dependenciesFull.filter(fi => fi.type !== 'esm');
|
|
418
|
+
//await recordFileInPackagesLog(relFile, packageInfo)
|
|
419
|
+
await fsPromises.mkdir(dirname(cacheDest), {
|
|
420
|
+
recursive: true
|
|
421
|
+
});
|
|
422
|
+
await fsPromises.mkdir(dirname(finalDest), {
|
|
423
|
+
recursive: true
|
|
424
|
+
});
|
|
425
|
+
//if (file.endsWith('index.cjs')) console.log('checking type for *index.cjs file:', packageInfo.type)
|
|
426
|
+
if (hasJavascriptFileExtension(file)) {
|
|
427
|
+
if (packageInfo.type === 'esm' && file.endsWith('.js') || file.endsWith('.mjs')) {
|
|
428
|
+
try {
|
|
429
|
+
const code = await babelFileEsm(file /*, packageInfo*/, nonEsmDependenciesFull);
|
|
430
|
+
//console.log('writing file', cacheDest)
|
|
431
|
+
//console.log('writing file', finalDest)
|
|
432
|
+
await fsPromises.writeFile(cacheDest, code); // rel contains the slash at start
|
|
433
|
+
await fsPromises.writeFile(finalDest, code); // rel contains the slash at start
|
|
434
|
+
} catch (e) {
|
|
435
|
+
cliError(`Error transforming file '${file}' with bableFileEsm`);
|
|
436
|
+
throw e;
|
|
428
437
|
}
|
|
429
438
|
} else {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
439
|
+
try {
|
|
440
|
+
//if (file.endsWith('index.cjs')) console.log('trying to transform a *index.cjs file:', file)
|
|
441
|
+
const code = await babelFileCjs(file, cacheDest, finalDest, packageInfo, nonEsmDependenciesFull);
|
|
442
|
+
//console.log('writing file', cacheDest)
|
|
443
|
+
//console.log('writing file', finalDest)
|
|
444
|
+
//if (file.endsWith('index.cjs')) console.log('writing a transformed *index.cjs file to cache:', cacheDest)
|
|
445
|
+
await fsPromises.writeFile(cacheDest, code); // rel contains the slash at start
|
|
446
|
+
//if (file.endsWith('index.cjs')) console.log('writing a transformed *index.cjs file to final:', finalDest)
|
|
447
|
+
await fsPromises.writeFile(finalDest, code); // rel contains the slash at start
|
|
448
|
+
} catch (e) {
|
|
449
|
+
cliError(`Error transforming file '${file}' with babelFileCjs`);
|
|
450
|
+
throw e;
|
|
451
|
+
}
|
|
433
452
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
await processDependencies(dependenciesFull, sourceFilename, [...history, file]);
|
|
439
|
-
//console.log('Files outstanding', filesNum)
|
|
440
|
-
return processedFilesCache[file];
|
|
441
|
-
} catch (e) {
|
|
442
|
-
cliError(`process file err for ${file}\nhistory: ${history}\n`, e);
|
|
443
|
-
throw e;
|
|
453
|
+
} else {
|
|
454
|
+
cliInfo(`copying package file ${file}`);
|
|
455
|
+
await fsPromises.copyFile(file, cacheDest);
|
|
456
|
+
await fsPromises.copyFile(file, finalDest);
|
|
444
457
|
}
|
|
458
|
+
const dependenciesFileIndentifiers = dependenciesFull.map(d => d.fileIdentifier);
|
|
459
|
+
addToDependencyGraphFromFileInfo(fileInfo, dependenciesFileIndentifiers);
|
|
460
|
+
// add deps to dependencyGraph
|
|
461
|
+
// returns the deps
|
|
462
|
+
await processDependencies(dependenciesFull, sourceFilename, [...history, file]);
|
|
463
|
+
//console.log('Files outstanding', filesNum)
|
|
464
|
+
return processedFilesCache[file];
|
|
465
|
+
// } catch (error) {
|
|
466
|
+
// throw error
|
|
467
|
+
// }
|
|
445
468
|
}
|
|
446
469
|
async function copyFileFromCache(fileIdentifier, cacheNode) {
|
|
447
470
|
//
|
|
@@ -538,7 +561,15 @@ export function MakeBabelTransformPackageImports(opts) {
|
|
|
538
561
|
return cachedFileInfo;
|
|
539
562
|
} else {
|
|
540
563
|
const fileInfo = resolveFile(file);
|
|
541
|
-
opts.promises.push(processFile(fileInfo, sourceFilename, [sourceFilename])
|
|
564
|
+
opts.promises.push(processFile(fileInfo, sourceFilename, [sourceFilename]).catch(error => {
|
|
565
|
+
if (error instanceof UnsupportedCompiledDependencyError) {
|
|
566
|
+
cliError(formatUnsupportedDependencyError(error));
|
|
567
|
+
} else {
|
|
568
|
+
cliError(`Error processing a package imported by ${formatImportLocation(sourceFilename)}`);
|
|
569
|
+
cliError(error);
|
|
570
|
+
}
|
|
571
|
+
return undefined;
|
|
572
|
+
}));
|
|
542
573
|
return importedPackageFiles[file] = fileInfo;
|
|
543
574
|
}
|
|
544
575
|
}
|
|
@@ -573,9 +604,14 @@ export function MakeBabelTransformPackageImports(opts) {
|
|
|
573
604
|
const exportsMap = arrays.mapToObject(exports, value => [value, true]);
|
|
574
605
|
//console.log('lexInner exports map', exportsMap)
|
|
575
606
|
for (const re of reexports) {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
607
|
+
try {
|
|
608
|
+
const reFullLocation = getCjsRelativeImportSourceLocation(re, file);
|
|
609
|
+
const reLexExportsMap = lexInternal(reFullLocation);
|
|
610
|
+
Object.assign(exportsMap, reLexExportsMap);
|
|
611
|
+
} catch {
|
|
612
|
+
// Named-export inference is best-effort. The main dependency traversal
|
|
613
|
+
// reports unresolved dependencies with the complete import history.
|
|
614
|
+
}
|
|
579
615
|
}
|
|
580
616
|
return cache[file] = exportsMap;
|
|
581
617
|
}
|
|
@@ -631,6 +667,7 @@ export function MakeBabelTransformPackageImports(opts) {
|
|
|
631
667
|
let filename;
|
|
632
668
|
let destinationFilename;
|
|
633
669
|
let require;
|
|
670
|
+
let skipPackageCompilationForFile = false;
|
|
634
671
|
//let dependencyChart
|
|
635
672
|
// function processExport(path: NodePath<ExportNamedDeclaration> | NodePath<ExportAllDeclaration>) {
|
|
636
673
|
// const source = path.node.source
|
|
@@ -645,6 +682,7 @@ export function MakeBabelTransformPackageImports(opts) {
|
|
|
645
682
|
throwError('BabelTransformPackageImports', 'Babel did not provide a filename');
|
|
646
683
|
}
|
|
647
684
|
filename = slash(stateFilename);
|
|
685
|
+
skipPackageCompilationForFile = opts.skipPackageCompilationFiles.has(filename);
|
|
648
686
|
//cliWarn('process package imports', filename)
|
|
649
687
|
//cliWarn('BabelTransformPackageImports on', filename)
|
|
650
688
|
const relativeFilename = filename.slice(opts.codeDir.length + 1);
|
|
@@ -655,6 +693,7 @@ export function MakeBabelTransformPackageImports(opts) {
|
|
|
655
693
|
},
|
|
656
694
|
visitor: {
|
|
657
695
|
ImportDeclaration: function (path) {
|
|
696
|
+
if (skipPackageCompilationForFile) return;
|
|
658
697
|
try {
|
|
659
698
|
let location = path.node.source.value;
|
|
660
699
|
//console.log('BabelTransformPackageImports', 'ImportDeclaration', location)
|