tungsten 0.4.13 → 0.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/dist/.build-complete +1 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/Components.d.ts +41 -0
- package/dist/Components.d.ts.map +1 -1
- package/dist/Components.js +60 -72
- package/dist/ContentNode.d.ts +8 -2
- package/dist/ContentNode.d.ts.map +1 -1
- package/dist/ContentNode.js +4 -1
- package/dist/Framework.js +4 -4
- package/dist/FrameworkConfig.d.ts +0 -2
- package/dist/FrameworkConfig.d.ts.map +1 -1
- package/dist/FunctionComponentStandIn.d.ts +1 -1
- package/dist/FunctionComponentStandIn.d.ts.map +1 -1
- package/dist/FunctionComponentStandIn.js +1 -0
- package/dist/Instance/Instance.js +2 -2
- package/dist/RenderingNode.d.ts +2 -2
- package/dist/RenderingNode.d.ts.map +1 -1
- package/dist/Script.d.ts +1 -1
- package/dist/Script.d.ts.map +1 -1
- package/dist/Servers/DevServer.d.ts.map +1 -1
- package/dist/Servers/DevServer.js +10 -0
- package/dist/Servers/loadEnvsDev.js +10 -10
- package/dist/Servers/routing.d.ts.map +1 -1
- package/dist/Servers/routing.js +8 -9
- package/dist/Store/makeStore.d.ts +4 -4
- package/dist/Store/makeStore.d.ts.map +1 -1
- package/dist/Store/makeStore.js +23 -57
- package/dist/_client/cjsHelpers.d.ts.map +1 -1
- package/dist/_client/cjsHelpers.js +4 -2
- package/dist/_client/client.js +0 -14
- package/dist/_client/hmr.d.ts +2 -0
- package/dist/_client/hmr.d.ts.map +1 -0
- package/dist/_client/hmr.js +65 -0
- package/dist/_client/liveReload.d.ts +2 -0
- package/dist/_client/liveReload.d.ts.map +1 -0
- package/dist/_client/liveReload.js +6 -0
- package/dist/_client/liveReloadSource.d.ts +3 -0
- package/dist/_client/liveReloadSource.d.ts.map +1 -0
- package/dist/_client/liveReloadSource.js +25 -0
- package/dist/babelPlugins/BabelTransformDocInit.d.ts +9 -0
- package/dist/babelPlugins/BabelTransformDocInit.d.ts.map +1 -0
- package/dist/babelPlugins/BabelTransformDocInit.js +201 -0
- package/dist/babelPlugins/BabelTransformPackageImports.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformPackageImports.js +1 -10
- package/dist/babelPlugins/transformPackageImports/getWebLocationOfPackageFile.js +1 -1
- package/dist/bin/index.d.ts.map +1 -1
- package/dist/bin/index.js +82 -75
- package/dist/browserStorage.d.ts +56 -18
- package/dist/browserStorage.d.ts.map +1 -1
- package/dist/browserStorage.js +172 -102
- package/dist/build/bundle.d.ts +1 -1
- package/dist/build/bundle.d.ts.map +1 -1
- package/dist/build/bundle.js +45 -31
- package/dist/build/compileJavascript.d.ts.map +1 -1
- package/dist/build/compileJavascript.js +0 -1
- package/dist/build/createClientFiles.d.ts.map +1 -1
- package/dist/build/createClientFiles.js +4 -8
- package/dist/build/getSxyClientPackageAliases.d.ts.map +1 -1
- package/dist/build/getSxyClientPackageAliases.js +3 -1
- package/dist/build/makeBabelUserDevConfig.d.ts.map +1 -1
- package/dist/build/makeBabelUserDevConfig.js +5 -1
- package/dist/build/makeBabelUserProdConfig.d.ts.map +1 -1
- package/dist/build/makeBabelUserProdConfig.js +5 -1
- package/dist/cliOutput.d.ts +5 -0
- package/dist/cliOutput.d.ts.map +1 -1
- package/dist/cliOutput.js +22 -0
- package/dist/componentProxyHandlers.d.ts +20 -13
- package/dist/componentProxyHandlers.d.ts.map +1 -1
- package/dist/componentProxyHandlers.js +130 -86
- package/dist/components/Link.d.ts +1 -1
- package/dist/components/Link.d.ts.map +1 -1
- package/dist/components/NativeHtml.d.ts +10 -0
- package/dist/components/NativeHtml.d.ts.map +1 -0
- package/dist/components/NativeHtml.js +12 -0
- package/dist/components/PopMessages.d.ts +1 -1
- package/dist/components/PopMessages.d.ts.map +1 -1
- package/dist/components/Protected.d.ts +10 -0
- package/dist/components/Protected.d.ts.map +1 -0
- package/dist/components/Protected.js +12 -0
- package/dist/components/Stylesheet.d.ts +1 -1
- package/dist/components/Stylesheet.d.ts.map +1 -1
- package/dist/components/bindable/BindableCheckbox.d.ts +1 -1
- package/dist/components/bindable/BindableCheckbox.d.ts.map +1 -1
- package/dist/components/bindable/BindableInput.d.ts +1 -1
- package/dist/components/bindable/BindableInput.d.ts.map +1 -1
- package/dist/components/bindable/BindableInputNonString.d.ts +1 -1
- package/dist/components/bindable/BindableInputNonString.d.ts.map +1 -1
- package/dist/components/bindable/BindableInputString.d.ts +1 -1
- package/dist/components/bindable/BindableInputString.d.ts.map +1 -1
- package/dist/components/bindable/BindableInputTyped.d.ts +1 -1
- package/dist/components/bindable/BindableInputTyped.d.ts.map +1 -1
- package/dist/components/bindable/BindableInputTypedLegacy.d.ts +1 -1
- package/dist/components/bindable/BindableInputTypedLegacy.d.ts.map +1 -1
- package/dist/components/bindable/BindableRadio.d.ts +1 -1
- package/dist/components/bindable/BindableRadio.d.ts.map +1 -1
- package/dist/components/bindable/BindableSelect.d.ts +1 -1
- package/dist/components/bindable/BindableSelect.d.ts.map +1 -1
- package/dist/components/bindable/BindableTextarea.d.ts +1 -1
- package/dist/components/bindable/BindableTextarea.d.ts.map +1 -1
- package/dist/components/library/RichTextEditor/RichTextEditor.d.ts +1 -1
- package/dist/components/library/RichTextEditor/RichTextEditor.d.ts.map +1 -1
- package/dist/components/library/RichTextEditor/contentTree.d.ts.map +1 -1
- package/dist/components/library/RichTextEditor/contentTree.js +2 -1
- package/dist/components/library/__StatefulMessage/StatefulMessage.d.ts +1 -1
- package/dist/components/library/__StatefulMessage/StatefulMessage.d.ts.map +1 -1
- package/dist/defaultConfig.d.ts.map +1 -1
- package/dist/defaultConfig.js +0 -1
- package/dist/devBanner.d.ts +4 -0
- package/dist/devBanner.d.ts.map +1 -0
- package/dist/devBanner.js +50 -0
- package/dist/docInit.d.ts +16 -0
- package/dist/docInit.d.ts.map +1 -0
- package/dist/docInit.js +54 -0
- package/dist/env/getEnvSchemas.d.ts +1 -1
- package/dist/env/getEnvSchemas.d.ts.map +1 -1
- package/dist/env/getEnvSchemas.js +21 -22
- package/dist/env/registerEnvSchemas.d.ts +13 -0
- package/dist/env/registerEnvSchemas.d.ts.map +1 -0
- package/dist/env/registerEnvSchemas.js +23 -0
- package/dist/frameworkConfigSchema.d.ts +0 -2
- package/dist/frameworkConfigSchema.d.ts.map +1 -1
- package/dist/frameworkConfigSchema.js +0 -1
- package/dist/hydrate/hydrate.d.ts.map +1 -1
- package/dist/hydrate/hydrate.js +14 -3
- package/dist/hydrate/renderHydrationMismatchBanner.d.ts +1 -0
- package/dist/hydrate/renderHydrationMismatchBanner.d.ts.map +1 -1
- package/dist/hydrate/renderHydrationMismatchBanner.js +11 -63
- package/dist/indexInner.d.ts +6 -2
- package/dist/indexInner.d.ts.map +1 -1
- package/dist/indexInner.js +6 -1
- package/dist/jsxRuntime.d.ts +1 -1
- package/dist/jsxRuntime.d.ts.map +1 -1
- package/dist/jsxRuntime.js +9 -7
- package/dist/jsxRuntimeSignals.d.ts +8 -4
- package/dist/jsxRuntimeSignals.d.ts.map +1 -1
- package/dist/jsxRuntimeSignals.js +8 -6
- package/dist/mutatingFunctions.d.ts +2 -1
- package/dist/mutatingFunctions.d.ts.map +1 -1
- package/dist/mutatingFunctions.js +7 -1
- package/dist/nbsp.d.ts +2 -2
- package/dist/nbsp.d.ts.map +1 -1
- package/dist/rawHtml/filterContentNode.d.ts.map +1 -1
- package/dist/rawHtml/filterContentNode.js +3 -1
- package/dist/render/HeadData.d.ts +1 -0
- package/dist/render/HeadData.d.ts.map +1 -1
- package/dist/render/contentNodeToHtml.d.ts.map +1 -1
- package/dist/render/contentNodeToHtml.js +2 -1
- package/dist/render/contentToHtml.d.ts.map +1 -1
- package/dist/render/contentToHtml.js +3 -1
- package/dist/render/contentTreeToRenderingTree.d.ts.map +1 -1
- package/dist/render/contentTreeToRenderingTree.js +5 -1
- package/dist/render/processHead.d.ts.map +1 -1
- package/dist/render/processHead.js +15 -34
- package/dist/render/readDocInitScript.d.ts +3 -0
- package/dist/render/readDocInitScript.d.ts.map +1 -0
- package/dist/render/readDocInitScript.js +15 -0
- package/dist/render/rootToHtmlDev.d.ts.map +1 -1
- package/dist/routing/Group.d.ts +1 -1
- package/dist/routing/Group.d.ts.map +1 -1
- package/dist/routing/MatchedRoute.d.ts +1 -1
- package/dist/routing/MatchedRoute.d.ts.map +1 -1
- package/dist/settings.d.ts +3 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +4 -0
- package/dist/signals/tracking.d.ts +33 -0
- package/dist/signals/tracking.d.ts.map +1 -0
- package/dist/signals/tracking.js +87 -0
- package/dist/style/styleContentSxy.d.ts.map +1 -1
- package/dist/style/styleContentSxy.js +6 -1
- package/dist/testing/installTestDocInit.d.ts +2 -0
- package/dist/testing/installTestDocInit.d.ts.map +1 -0
- package/dist/testing/installTestDocInit.js +6 -0
- package/dist/throwError.d.ts.map +1 -1
- package/dist/throwError.js +4 -1
- package/dist/update/integrateUpdateVdom.d.ts.map +1 -1
- package/dist/update/integrateUpdateVdom.js +39 -3
- package/dist/warnOnFrameworkChange.js +1 -1
- package/package.json +7 -6
- package/readme.md +2 -135
- package/types/assets.d.ts +21 -0
- package/types/index.d.ts +24 -29
- package/types/jsx/html.d.ts +0 -1
- package/types/jsx/html.global.d.ts +0 -1
- package/types/jsx/html.values.d.ts +0 -1
- package/types/jsx/jsx.d.ts +8 -8
- package/vendor/manifest.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DevServer.d.ts","sourceRoot":"","sources":["../../src/Servers/DevServer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAClC,OAAO,OAA4D,MAAM,SAAS,CAAA;AAQlF,OAAO,KAAK,EAAE,uBAAuB,EAAwB,MAAM,uBAAuB,CAAA;AAC1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAMpD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAW3C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAIrC,OAAO,EAAE,UAAU,EAAkB,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AAEjG,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"DevServer.d.ts","sourceRoot":"","sources":["../../src/Servers/DevServer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAClC,OAAO,OAA4D,MAAM,SAAS,CAAA;AAQlF,OAAO,KAAK,EAAE,uBAAuB,EAAwB,MAAM,uBAAuB,CAAA;AAC1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAMpD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAW3C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAIrC,OAAO,EAAE,UAAU,EAAkB,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AAEjG,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAwBrD,qBAAa,SAAU,SAAQ,cAAc;IACzC,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,EAAE,uBAAuB,CAAA;IAC/B,eAAe,EAAE,eAAe,CAAA;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAO;IAC9B,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACzC,GAAG,EAAE,OAAO,CAAC,WAAW,CAAA;IAExB,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,OAAO,CAAO;IAC3B,cAAc,EAAE,MAAM,CAAI;IAC1B,oBAAoB,EAAE,MAAM,CAAI;IAChC,OAAO,CAAC,iBAAiB,CAA2B;IACpD,OAAO,CAAC,iBAAiB,CAA4B;IAIrD,OAAO,CAAC,MAAM,CAA2C;gBAErD,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,uBAAuB,EAAE,eAAe,EAAE,eAAe,EACvF,iBAAiB,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM;IAgIlD,OAAO,CAAC,mBAAmB,CA2E1B;IAKD,OAAO,CAAC,sBAAsB,CAQ7B;IACD,OAAO,CAAC,mBAAmB,CAA8B;IACzD,OAAO,CAAC,iBAAiB,CAA+B;IACxD,OAAO,CAAC,kBAAkB,CAAyB;IACnD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAM;IAC9C,OAAO,CAAC,oBAAoB,CAwB3B;IACD,OAAO,CAAC,mBAAmB,CAK1B;IACD,OAAO,CAAC,gBAAgB,CAcvB;IAED,OAAO,CAAC,aAAa,CAwOpB;IAaD,OAAO,CAAC,mBAAmB,CAsC1B;IAID,aAAa,GAAU,MAAM,kBAAkB,EAAE,QAAQ,MAAM,yBAQ9D;IACD,QAAQ,GAAI,OAAO,OAAO,UAIzB;IACD,SAAS,GAAI,OAAO,OAAO,EAAE,YAAY,MAAM,EAAE,YAiBhD;IACD,KAAK,QAAO,OAAO,CAAC,MAAM,CAAC,CAO1B;IACD,IAAI,aAMH;CAGJ"}
|
|
@@ -40,6 +40,8 @@ import { devErrorPageAutoRetryScript } from './devErrorPageAutoRetry.js';
|
|
|
40
40
|
function debug(...texts) {
|
|
41
41
|
// console.log(...texts)
|
|
42
42
|
}
|
|
43
|
+
// what Chrome DevTools fetches to auto-connect a localhost project as a workspace
|
|
44
|
+
const chromeDevtoolsProjectSettingsPath = '/.well-known/appspecific/com.chrome.devtools.json';
|
|
43
45
|
export class DevServer extends TungstenServer {
|
|
44
46
|
constructor(framework, config, compilationInfo, initialProcessEnv = {} /* FIX ME */) {
|
|
45
47
|
super();
|
|
@@ -204,6 +206,14 @@ export class DevServer extends TungstenServer {
|
|
|
204
206
|
res.status(404).end();
|
|
205
207
|
return;
|
|
206
208
|
}
|
|
209
|
+
// Chrome DevTools probes every localhost server for a workspace descriptor (automatic
|
|
210
|
+
// workspace folders). Answering it only pays once dev emits source maps back to the app's
|
|
211
|
+
// sources, so until then: a 404 without the 404-route render it would otherwise cost
|
|
212
|
+
if (req.url === chromeDevtoolsProjectSettingsPath) {
|
|
213
|
+
cliLog(`Chrome DevTools asked for ${req.url} - not supported yet, skipping the render`);
|
|
214
|
+
res.status(404).end();
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
207
217
|
cliLog('handling ' + req.url);
|
|
208
218
|
const errorTrack = [];
|
|
209
219
|
// Captured as soon as each resolves, independent of the promiseAllObj combinators
|
|
@@ -65,37 +65,37 @@ buildCodeFolder) {
|
|
|
65
65
|
//console.log('check for schemas')
|
|
66
66
|
// If there are env schemas, load the relevant env and parse with schemas
|
|
67
67
|
if ('privateEnvSchema' in envSchemas) {
|
|
68
|
-
if (_firstLoad) cliLog('
|
|
68
|
+
if (_firstLoad) cliLog('private env schema found');
|
|
69
69
|
const result = await validate(envSchemas.privateEnvSchema, tempEnv);
|
|
70
70
|
if (!result.success) {
|
|
71
|
-
throwError('Your environment variables failed your
|
|
71
|
+
throwError('Your environment variables failed your private env schema (registerPrivateEnvSchema)', '\n' + result.problems + '\nenv: ' + JSON.stringify(tempEnv, null, 4));
|
|
72
72
|
}
|
|
73
|
-
checkIsObject('loadEnvsDev()', '
|
|
73
|
+
checkIsObject('loadEnvsDev()', 'the private env schema', result.value);
|
|
74
74
|
const coreResult = await validate(tungstenCorePrivateEnvSchema, result.value);
|
|
75
75
|
if (!coreResult.success) {
|
|
76
|
-
throwError('Your private environment variables don\'t meet the Tungsten requirements.
|
|
76
|
+
throwError('Your private environment variables don\'t meet the Tungsten requirements. Check .env / .env.private and the schema given to registerPrivateEnvSchema - it may need to coerce a value to the right type.',
|
|
77
77
|
// eslint-disable-line max-len
|
|
78
78
|
'\n' + coreResult.problems + '\nenv: ' + JSON.stringify(tempEnv, null, 4));
|
|
79
79
|
}
|
|
80
|
-
global.tungstenPrivateEnv =
|
|
80
|
+
global.tungstenPrivateEnv = coreResult.value;
|
|
81
81
|
//console.log('global.tungstenPrivateEnv', global.tungstenPrivateEnv)
|
|
82
82
|
if (_firstLoad) cliOut('tungsten private env loaded and passed schema validation'); // save this so that we can show all messages about loading .env files first
|
|
83
83
|
}
|
|
84
84
|
if ('publicEnvSchema' in envSchemas) {
|
|
85
|
-
if (_firstLoad) cliLog('
|
|
85
|
+
if (_firstLoad) cliLog('public env schema found');
|
|
86
86
|
const tempPublicEnv = objectRemap(objectFilter(tempEnv, key => key.startsWith('TUNGSTEN_PUBLIC_')), (key, value) => {
|
|
87
87
|
return [key.slice('TUNGSTEN_PUBLIC_'.length), value];
|
|
88
88
|
});
|
|
89
89
|
const result = await validate(envSchemas.publicEnvSchema, tempPublicEnv);
|
|
90
90
|
if (!result.success) {
|
|
91
|
-
throwError('
|
|
91
|
+
throwError('Your public environment variables failed your public env schema (registerPublicEnvSchema)', '\n' + result.problems + '\nenv: ' + JSON.stringify(tempEnv, null, 4) + '\nparsed public env ' + JSON.stringify(tempPublicEnv, null, 4));
|
|
92
92
|
}
|
|
93
|
-
checkIsObject('loadEnvsDev()', '
|
|
93
|
+
checkIsObject('loadEnvsDev()', 'the public env schema', result.value);
|
|
94
94
|
const coreResult = await validate(tungstenCorePublicEnvSchema, result.value);
|
|
95
95
|
if (!coreResult.success) {
|
|
96
|
-
throwError('Your
|
|
96
|
+
throwError('Your public environment variables don\'t meet the Tungsten requirements. Check .env.public and the schema given to registerPublicEnvSchema - it may need to coerce a value to the right type.',
|
|
97
97
|
// eslint-disable-line max-len
|
|
98
|
-
'\n' + coreResult.problems + '\
|
|
98
|
+
'\n' + coreResult.problems + '\npublic env: ' + JSON.stringify(tempPublicEnv, null, 4));
|
|
99
99
|
}
|
|
100
100
|
global.tungstenPublicEnv = coreResult.value;
|
|
101
101
|
//console.log('global.tungstenPublicEnv', global.tungstenPublicEnv)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/Servers/routing.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAGlD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAIjE,wBAAsB,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAE,iBAAiB,GAAG,IAAW,GAC5G,OAAO,CAAC,gBAAgB,CAAC,
|
|
1
|
+
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/Servers/routing.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAGlD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAIjE,wBAAsB,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAE,iBAAiB,GAAG,IAAW,GAC5G,OAAO,CAAC,gBAAgB,CAAC,CA0D9B"}
|
package/dist/Servers/routing.js
CHANGED
|
@@ -25,19 +25,18 @@ export async function routing(location, routes, serverDataLoading = null) {
|
|
|
25
25
|
const match = matchPath(path, location);
|
|
26
26
|
if (match !== null) {
|
|
27
27
|
const params = match.params;
|
|
28
|
-
|
|
28
|
+
// no loader, no data key: this object is serialized into the page as-is
|
|
29
|
+
const matched = {
|
|
30
|
+
key: path,
|
|
31
|
+
params,
|
|
32
|
+
content: route.content
|
|
33
|
+
};
|
|
29
34
|
if ('data' in route) {
|
|
30
35
|
if (serverDataLoading) serverDataLoading.value = true;
|
|
31
|
-
data = await route.data(params, location, match.query);
|
|
36
|
+
matched.data = await route.data(params, location, match.query);
|
|
32
37
|
if (serverDataLoading) serverDataLoading.value = false;
|
|
33
38
|
}
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
key: path,
|
|
37
|
-
params,
|
|
38
|
-
content: route.content,
|
|
39
|
-
data: data
|
|
40
|
-
};
|
|
39
|
+
return matched;
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
42
|
// handle 404 and default routes
|
|
@@ -4,12 +4,12 @@ import { ServerDataLoading } from './ServerDataLoading.js';
|
|
|
4
4
|
import { SubscribedElements } from './StoreSubscriptions.types.js';
|
|
5
5
|
export declare class StoreValueServer<T> {
|
|
6
6
|
#private;
|
|
7
|
-
constructor(
|
|
7
|
+
constructor(value: T, serverDataLoading: ServerDataLoading);
|
|
8
8
|
readonly get: () => T;
|
|
9
9
|
readonly set: (newValue: T) => void;
|
|
10
|
-
readonly subscribe: (
|
|
11
|
-
readonly unsubscribe: (
|
|
12
|
-
readonly sync: (
|
|
10
|
+
readonly subscribe: () => void;
|
|
11
|
+
readonly unsubscribe: () => void;
|
|
12
|
+
readonly sync: () => T;
|
|
13
13
|
}
|
|
14
14
|
export declare class StoreValue<T> {
|
|
15
15
|
#private;
|
|
@@ -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;
|
|
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;AAEnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAIlE,qBAAa,gBAAgB,CAAC,CAAC;;gBAGf,KAAK,EAAE,CAAC,EAAE,iBAAiB,EAAE,iBAAiB;IAI1D,QAAQ,CAAC,GAAG,UAAoB;IAChC,QAAQ,CAAC,GAAG,GAAI,UAAU,CAAC,UAO1B;IACD,QAAQ,CAAC,SAAS,aAAW;IAC7B,QAAQ,CAAC,WAAW,aAAW;IAC/B,QAAQ,CAAC,IAAI,UAAoB;CACpC;AAED,qBAAa,UAAU,CAAC,CAAC;;gBAMT,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,kBAAkB,EAAE,kBAAkB;IAKtE,QAAQ,CAAC,GAAG,UAAoB;IAChC,QAAQ,CAAC,GAAG,GAAI,UAAU,CAAC,UAY1B;IACD,QAAQ,CAAC,SAAS,GAAI,SAAS,0BAA0B,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,UASvE;IACD,QAAQ,CAAC,WAAW,GAAI,SAAS,0BAA0B,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,UAQzE;IACD,QAAQ,CAAC,IAAI,GAAI,SAAS,0BAA0B,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,OAGlE;CACJ;AAED,MAAM,MAAM,SAAS,CAAC,MAAM,IAAI;KAC3B,QAAQ,IAAI,MAAM,MAAM,GAAG;QACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAA;QACpC,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAA;QAC/C,QAAQ,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,0BAA0B,CAAC,GAAG,EAAE,GAAG,EAAE,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,CAWnB"}
|
package/dist/Store/makeStore.js
CHANGED
|
@@ -7,81 +7,47 @@ function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
|
7
7
|
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
|
8
8
|
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
9
9
|
import { objectMap } from '../objectMap.js';
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
// the server render is one pass, so nothing re-renders on a write: no subscribers, and subscribe
|
|
11
|
+
// is a no-op that keeps the cell's shape for the component proxy
|
|
12
12
|
var _value = /*#__PURE__*/new WeakMap();
|
|
13
|
-
var _subscribedElements = /*#__PURE__*/new WeakMap();
|
|
14
|
-
var _subscribers = /*#__PURE__*/new WeakMap();
|
|
15
13
|
var _serverDataLoading = /*#__PURE__*/new WeakMap();
|
|
16
14
|
export class StoreValueServer {
|
|
17
|
-
constructor(
|
|
18
|
-
_classPrivateFieldInitSpec(this, _key, void 0);
|
|
15
|
+
constructor(value, serverDataLoading) {
|
|
19
16
|
_classPrivateFieldInitSpec(this, _value, void 0);
|
|
20
|
-
_classPrivateFieldInitSpec(this, _subscribedElements, void 0);
|
|
21
|
-
_classPrivateFieldInitSpec(this, _subscribers, new Set());
|
|
22
17
|
_classPrivateFieldInitSpec(this, _serverDataLoading, void 0);
|
|
23
18
|
_defineProperty(this, "get", () => _classPrivateFieldGet(_value, this));
|
|
24
19
|
_defineProperty(this, "set", newValue => {
|
|
25
20
|
_classPrivateFieldSet(_value, this, newValue);
|
|
26
|
-
//console.log(this.#key, 'pushing', this.#subscribers)
|
|
27
|
-
for (const element of _classPrivateFieldGet(_subscribers, this)) {
|
|
28
|
-
if (element.shouldStoreComponentUpdate !== undefined) {
|
|
29
|
-
if (!element.shouldStoreComponentUpdate(_classPrivateFieldGet(_key, this), _classPrivateFieldGet(_value, this))) {
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
//console.log('queueing update for', element.constructor.name, 'on', this.#key)
|
|
34
|
-
element.__queueUpdate();
|
|
35
|
-
}
|
|
36
21
|
if (_classPrivateFieldGet(_serverDataLoading, this).value) {
|
|
37
|
-
// save this for network export
|
|
22
|
+
// save this for network export
|
|
38
23
|
// huh?
|
|
39
24
|
}
|
|
40
25
|
});
|
|
41
|
-
_defineProperty(this, "subscribe",
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
/* ???
|
|
45
|
-
if (!this.#store.#subscriptions.exists(element) this.#store.#subscriptions.add(element)
|
|
46
|
-
this.#store.#subscriptions.get(element).add(this)
|
|
47
|
-
*/
|
|
48
|
-
});
|
|
49
|
-
_defineProperty(this, "unsubscribe", element => {
|
|
50
|
-
//console.log('StoreValueServer unsubscribe', this.#key, element)
|
|
51
|
-
_classPrivateFieldGet(_subscribers, this).delete(element);
|
|
52
|
-
//console.log('Subs', this.#subscribers)
|
|
53
|
-
});
|
|
54
|
-
_defineProperty(this, "sync", element => {
|
|
55
|
-
if (isBrowser) console.log('StoreValueServer.sync', 'IS browser!');
|
|
56
|
-
//if (isBrowser) this.#subscribers.add(element)
|
|
57
|
-
//this.#subscribers.add(element)
|
|
58
|
-
if (isBrowser) this.subscribe(element);
|
|
59
|
-
return _classPrivateFieldGet(_value, this);
|
|
60
|
-
});
|
|
61
|
-
_classPrivateFieldSet(_key, this, key);
|
|
26
|
+
_defineProperty(this, "subscribe", () => {});
|
|
27
|
+
_defineProperty(this, "unsubscribe", () => {});
|
|
28
|
+
_defineProperty(this, "sync", () => _classPrivateFieldGet(_value, this));
|
|
62
29
|
_classPrivateFieldSet(_value, this, value);
|
|
63
|
-
_classPrivateFieldSet(_subscribedElements, this, subscribedElements);
|
|
64
30
|
_classPrivateFieldSet(_serverDataLoading, this, serverDataLoading);
|
|
65
31
|
}
|
|
66
32
|
}
|
|
67
|
-
var
|
|
33
|
+
var _key = /*#__PURE__*/new WeakMap();
|
|
68
34
|
var _value2 = /*#__PURE__*/new WeakMap();
|
|
69
|
-
var
|
|
70
|
-
var
|
|
35
|
+
var _subscribedElements = /*#__PURE__*/new WeakMap();
|
|
36
|
+
var _subscribers = /*#__PURE__*/new WeakMap();
|
|
71
37
|
export class StoreValue {
|
|
72
38
|
constructor(key, value, subscribedElements) {
|
|
73
39
|
/* #store: StoreSchemaClassGeneral */
|
|
74
|
-
_classPrivateFieldInitSpec(this,
|
|
40
|
+
_classPrivateFieldInitSpec(this, _key, void 0);
|
|
75
41
|
_classPrivateFieldInitSpec(this, _value2, void 0);
|
|
76
|
-
_classPrivateFieldInitSpec(this,
|
|
77
|
-
_classPrivateFieldInitSpec(this,
|
|
42
|
+
_classPrivateFieldInitSpec(this, _subscribedElements, void 0);
|
|
43
|
+
_classPrivateFieldInitSpec(this, _subscribers, new Set());
|
|
78
44
|
_defineProperty(this, "get", () => _classPrivateFieldGet(_value2, this));
|
|
79
45
|
_defineProperty(this, "set", newValue => {
|
|
80
46
|
_classPrivateFieldSet(_value2, this, newValue);
|
|
81
47
|
//console.log(this.#key, 'pushing', this.#subscribers)
|
|
82
|
-
for (const element of _classPrivateFieldGet(
|
|
48
|
+
for (const element of _classPrivateFieldGet(_subscribers, this)) {
|
|
83
49
|
if (element.shouldStoreComponentUpdate !== undefined) {
|
|
84
|
-
if (!element.shouldStoreComponentUpdate(_classPrivateFieldGet(
|
|
50
|
+
if (!element.shouldStoreComponentUpdate(_classPrivateFieldGet(_key, this), _classPrivateFieldGet(_value2, this))) {
|
|
85
51
|
continue;
|
|
86
52
|
}
|
|
87
53
|
}
|
|
@@ -90,17 +56,17 @@ export class StoreValue {
|
|
|
90
56
|
}
|
|
91
57
|
});
|
|
92
58
|
_defineProperty(this, "subscribe", element => {
|
|
93
|
-
_classPrivateFieldGet(
|
|
94
|
-
let subscriptions = _classPrivateFieldGet(
|
|
59
|
+
_classPrivateFieldGet(_subscribers, this).add(element);
|
|
60
|
+
let subscriptions = _classPrivateFieldGet(_subscribedElements, this).get(element);
|
|
95
61
|
if (subscriptions === undefined) {
|
|
96
62
|
subscriptions = new Set();
|
|
97
|
-
_classPrivateFieldGet(
|
|
63
|
+
_classPrivateFieldGet(_subscribedElements, this).set(element, subscriptions);
|
|
98
64
|
}
|
|
99
|
-
subscriptions.add(_classPrivateFieldGet(
|
|
65
|
+
subscriptions.add(_classPrivateFieldGet(_key, this));
|
|
100
66
|
});
|
|
101
67
|
_defineProperty(this, "unsubscribe", element => {
|
|
102
68
|
//console.log('StoreValue unsubscribe', this.#key, element)
|
|
103
|
-
_classPrivateFieldGet(
|
|
69
|
+
_classPrivateFieldGet(_subscribers, this).delete(element);
|
|
104
70
|
//console.log('Subs', this.#subscribers)
|
|
105
71
|
/*
|
|
106
72
|
// it should always exist. But might be safer to check anyway
|
|
@@ -111,13 +77,13 @@ export class StoreValue {
|
|
|
111
77
|
this.subscribe(element);
|
|
112
78
|
return _classPrivateFieldGet(_value2, this);
|
|
113
79
|
});
|
|
114
|
-
_classPrivateFieldSet(
|
|
80
|
+
_classPrivateFieldSet(_key, this, key);
|
|
115
81
|
_classPrivateFieldSet(_value2, this, value);
|
|
116
|
-
_classPrivateFieldSet(
|
|
82
|
+
_classPrivateFieldSet(_subscribedElements, this, subscribedElements);
|
|
117
83
|
}
|
|
118
84
|
}
|
|
119
85
|
export function makeStore(schema, subscribedElements, serverDataLoading = null) {
|
|
120
86
|
//const Class = (isServer) ? StoreValueServer : StoreValue
|
|
121
|
-
const store = objectMap(schema, (key, value) => serverDataLoading ? new StoreValueServer(
|
|
87
|
+
const store = objectMap(schema, (key, value) => serverDataLoading ? new StoreValueServer(value, serverDataLoading) : new StoreValue(key, value, subscribedElements));
|
|
122
88
|
return store; // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- not sure, just want to get rid of squigglies
|
|
123
89
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cjsHelpers.d.ts","sourceRoot":"","sources":["../../src/_client/cjsHelpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAa,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"cjsHelpers.d.ts","sourceRoot":"","sources":["../../src/_client/cjsHelpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAa,MAAM,gBAAgB,CAAA;AAyCvD,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,qBAAqB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;SAAE,CAAC,CAAA;KAC/E;CACJ;AAkCD,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,mCAuC5C"}
|
|
@@ -33,14 +33,16 @@ function pathCombine(baseFile, dest) {
|
|
|
33
33
|
let dir = baseDir;
|
|
34
34
|
let subDest = dest;
|
|
35
35
|
while (subDest.startsWith('../')) {
|
|
36
|
-
if (dir === '')
|
|
36
|
+
if (dir === '') {
|
|
37
|
+
throw new Error(`pathCombine() error, tried to back up too far. baseDir: ${baseDir} dest: ${dest}`);
|
|
38
|
+
}
|
|
37
39
|
dir = dir.slice(0, dir.lastIndexOf('/'));
|
|
38
40
|
subDest = subDest.slice(3);
|
|
39
41
|
}
|
|
40
42
|
return dir + '/' + subDest;
|
|
41
43
|
} else {
|
|
42
44
|
// unknown
|
|
43
|
-
throw new Error(
|
|
45
|
+
throw new Error('pathCombine error: unknown dest format, expected a relative import.' + ` baseDir: ${baseDir} dest: ${dest}`);
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
export async function loadDeps(deps) {
|
package/dist/_client/client.js
CHANGED
|
@@ -22,20 +22,6 @@ const clientPromise = (async () => {
|
|
|
22
22
|
);
|
|
23
23
|
}
|
|
24
24
|
await Promise.all(promises);
|
|
25
|
-
//const rootComponentRelFilePath = (await import('./rootComponentRelFilePath.js')).rootComponentRelFilePath
|
|
26
|
-
// let RootComponent: TungstenBaseComponentType
|
|
27
|
-
// if ('default' in rootModule) {
|
|
28
|
-
// // @ts-ignore
|
|
29
|
-
// RootComponent = rootModule.default
|
|
30
|
-
// } else {
|
|
31
|
-
// const file = rootComponentRelFilePath.split('/').pop() as string
|
|
32
|
-
// const componentName = file.slice(0, file.lastIndexOf('.'))
|
|
33
|
-
// if (componentName in rootModule) {
|
|
34
|
-
// RootComponent = rootModule[componentName]
|
|
35
|
-
// } else {
|
|
36
|
-
// throw new TungstenError(`Component not found in module ${rootComponentRelFilePath}`)
|
|
37
|
-
// }
|
|
38
|
-
// }
|
|
39
25
|
// @ts-expect-error -- TS doesn't understand that RootComponent was assigned by the promise
|
|
40
26
|
await hydrate(routes, RootComponent, instanceConfig);
|
|
41
27
|
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmr.d.ts","sourceRoot":"","sources":["../../src/_client/hmr.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Tier 2 HMR (config hmr: true): swap changed components and stylesheets in place, falling back to
|
|
2
|
+
// a full reload only when that cannot be done. See docs/hmr.md.
|
|
3
|
+
//
|
|
4
|
+
// This lives in _client rather than the framework's module graph because it fetches whichever file
|
|
5
|
+
// just recompiled via a computed import(), and a non-literal import() anywhere in the traced
|
|
6
|
+
// dependency graph makes the package-copying step throw (it must know every specifier statically).
|
|
7
|
+
// _client files are copied verbatim into the app's .client folder, so they are never traced.
|
|
8
|
+
/* eslint-disable no-console -- the console is this module's output: it reports what HMR did and why */
|
|
9
|
+
import { connectLiveReload } from './liveReloadSource.js';
|
|
10
|
+
function isJsPayload(value) {
|
|
11
|
+
return typeof value === 'object' && value !== null;
|
|
12
|
+
}
|
|
13
|
+
// the re-imported file's exports; applyHmrModule scans them for component definitions
|
|
14
|
+
function importFresh(file) {
|
|
15
|
+
return import(`${file}?t=${Date.now()}`).then(m => m); // eslint-disable-line @typescript-eslint/no-unsafe-type-assertion -- a module namespace is always a string-keyed object
|
|
16
|
+
}
|
|
17
|
+
// Loaded on the first event, not statically: module scripts evaluate in document order and this one
|
|
18
|
+
// precedes cjsHelpers.js, whose globals the framework graph's converted CJS packages need at
|
|
19
|
+
// evaluation time. A static import here evaluated that graph first ("__tungsten_cjs_import is not
|
|
20
|
+
// defined"). Resolved by the import map (getSxyClientPackageAliases.ts).
|
|
21
|
+
const loadHmr = () => import('tungsten/hmr/applyHmrModule.js');
|
|
22
|
+
function fullReload(reason) {
|
|
23
|
+
console.info('[tungsten-hmr] full reload:', reason);
|
|
24
|
+
window.location.reload();
|
|
25
|
+
}
|
|
26
|
+
// CSS has no state to preserve, so re-applying it is always safe: refreshStylesheets() inserts the
|
|
27
|
+
// new link and only removes the old one once it has loaded, so nothing flashes.
|
|
28
|
+
function refreshCss() {
|
|
29
|
+
loadHmr().then(hmr => Promise.all(hmr.refreshStylesheets())).catch(e => console.error('[tungsten-hmr] stylesheet refresh failed', e));
|
|
30
|
+
}
|
|
31
|
+
const es = connectLiveReload(fullReload);
|
|
32
|
+
es.addEventListener('css', () => {
|
|
33
|
+
console.info('[tungsten-hmr] css change, refreshing stylesheets');
|
|
34
|
+
refreshCss();
|
|
35
|
+
});
|
|
36
|
+
es.addEventListener('js', ev => {
|
|
37
|
+
let payload;
|
|
38
|
+
try {
|
|
39
|
+
payload = JSON.parse(ev.data);
|
|
40
|
+
} catch {
|
|
41
|
+
fullReload('bad payload');
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const files = isJsPayload(payload) ? payload.files ?? [] : [];
|
|
45
|
+
if (files.length === 0) {
|
|
46
|
+
fullReload('no files in payload');
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
console.info('[tungsten-hmr] fetching', files);
|
|
50
|
+
// a component's inline style block rides this same JS pipeline (it lives in the .tsx source, not
|
|
51
|
+
// a separate .css), so refresh stylesheets here too - independently of the swap below, so a
|
|
52
|
+
// stylesheet load error does not force a full reload
|
|
53
|
+
refreshCss();
|
|
54
|
+
loadHmr().then(hmr => Promise.all(files.map(importFresh)).then(modules => Promise.all(modules.map((m, i) => hmr.applyHmrModule(m, files[i]))))).then(results => {
|
|
55
|
+
console.info('[tungsten-hmr] results', results);
|
|
56
|
+
if (results.some(r => r.orphaned)) {
|
|
57
|
+
fullReload('a component export was renamed or removed');
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (!results.some(r => r.matched)) fullReload('no matching live component found');
|
|
61
|
+
}).catch(e => {
|
|
62
|
+
console.error('[tungsten-hmr] swap failed', e);
|
|
63
|
+
fullReload('error during swap');
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"liveReload.d.ts","sourceRoot":"","sources":["../../src/_client/liveReload.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Tier 1 live reload (config hmr: 'reload'): any change is a full page reload. Deliberately
|
|
2
|
+
// independent of hmr.ts so it stays a one-line escape hatch if Tier 2 misbehaves. See docs/hmr.md.
|
|
3
|
+
import { connectLiveReload } from './liveReloadSource.js';
|
|
4
|
+
const es = connectLiveReload(() => window.location.reload());
|
|
5
|
+
es.addEventListener('css', () => window.location.reload());
|
|
6
|
+
es.addEventListener('js', () => window.location.reload());
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"liveReloadSource.d.ts","sourceRoot":"","sources":["../../src/_client/liveReloadSource.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;AASjD,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,WAAW,CAerE"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Shared by the two live-reload entries (liveReload.ts, hmr.ts). _client files are copied verbatim
|
|
2
|
+
// into the app's .client folder by createClientFiles and served from there, outside the traced
|
|
3
|
+
// module graph - see the note atop hmr.ts for why that matters.
|
|
4
|
+
function bootIdOf(data) {
|
|
5
|
+
const payload = JSON.parse(data);
|
|
6
|
+
if (typeof payload !== 'object' || payload === null || !('bootId' in payload)) return undefined;
|
|
7
|
+
return typeof payload.bootId === 'string' ? payload.bootId : undefined;
|
|
8
|
+
}
|
|
9
|
+
// This module is served from <siteBasePath>/.client/, so the endpoint resolves relative to it.
|
|
10
|
+
export function connectLiveReload(fullReload) {
|
|
11
|
+
const es = new EventSource(new URL('../__tungsten_live_reload__', import.meta.url));
|
|
12
|
+
// The server sends its bootId as the first event on every connection (handleLiveReloadStream).
|
|
13
|
+
// A different one already in sessionStorage means this is a reconnect to a process that
|
|
14
|
+
// restarted since the page loaded (e.g. devmon after a framework rebuild) - EventSource retries
|
|
15
|
+
// silently on its own, so this is the only reliable signal that the page is now stale.
|
|
16
|
+
es.addEventListener('boot', ev => {
|
|
17
|
+
const bootId = bootIdOf(ev.data);
|
|
18
|
+
if (bootId === undefined) return;
|
|
19
|
+
const key = '__tungsten_boot_id__';
|
|
20
|
+
const prev = sessionStorage.getItem(key);
|
|
21
|
+
sessionStorage.setItem(key, bootId);
|
|
22
|
+
if (prev !== null && prev !== bootId) fullReload('dev server restarted');
|
|
23
|
+
});
|
|
24
|
+
return es;
|
|
25
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as Babel from '@babel/core';
|
|
2
|
+
import type { PluginObj } from '@babel/core';
|
|
3
|
+
type Opts = {
|
|
4
|
+
outputFile: string;
|
|
5
|
+
projectDir?: string | undefined;
|
|
6
|
+
};
|
|
7
|
+
export declare function MakeBabelTransformDocInit(opts: Opts): (babel: typeof Babel) => PluginObj;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=BabelTransformDocInit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BabelTransformDocInit.d.ts","sourceRoot":"","sources":["../../src/babelPlugins/BabelTransformDocInit.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAY,SAAS,EAAc,MAAM,aAAa,CAAA;AAQlE,KAAK,IAAI,GAAG;IACR,UAAU,EAAE,MAAM,CAAA;IAElB,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAClC,CAAA;AAoCD,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,IAAI,IAqBV,OAAO,OAAO,KAAK,KAAG,SAAS,CAuKxE"}
|