@bleedingdev/modern-js-renderer-octane 0.0.0-stage → 3.9.3-ultramodern.10

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.
Files changed (154) hide show
  1. package/LICENSE +21 -0
  2. package/bin/octane-tsc.mjs +4 -0
  3. package/dist/cjs/bootstrap.js +68 -0
  4. package/dist/cjs/client.js +421 -0
  5. package/dist/cjs/entry-application.js +88 -0
  6. package/dist/cjs/entry-client.js +95 -0
  7. package/dist/cjs/entry-server.js +135 -0
  8. package/dist/cjs/federation-context.js +72 -0
  9. package/dist/cjs/federation.js +205 -0
  10. package/dist/cjs/i18n/I18nProvider.js +59 -0
  11. package/dist/cjs/i18n/LocalizedLink.js +80 -0
  12. package/dist/cjs/i18n/context.js +41 -0
  13. package/dist/cjs/i18n/index.js +83 -0
  14. package/dist/cjs/i18n/languageSync.js +99 -0
  15. package/dist/cjs/i18n/types.js +18 -0
  16. package/dist/cjs/i18n/useI18n.js +110 -0
  17. package/dist/cjs/i18n-external-snapshot.js +645 -0
  18. package/dist/cjs/index.js +46 -0
  19. package/dist/cjs/manifest.js +167 -0
  20. package/dist/cjs/plugin/compiler.js +122 -0
  21. package/dist/cjs/plugin/create.js +266 -0
  22. package/dist/cjs/plugin/index.js +151 -0
  23. package/dist/cjs/plugin/profile.js +91 -0
  24. package/dist/cjs/plugin/source.js +56 -0
  25. package/dist/cjs/router-client.js +139 -0
  26. package/dist/cjs/router-external-snapshot.js +291 -0
  27. package/dist/cjs/router-handler.js +171 -0
  28. package/dist/cjs/router-server-cleanup.js +46 -0
  29. package/dist/cjs/router-server-snapshot.js +405 -0
  30. package/dist/cjs/router-server.js +100 -0
  31. package/dist/cjs/router-snapshot.js +270 -0
  32. package/dist/cjs/router.js +218 -0
  33. package/dist/cjs/routes.js +190 -0
  34. package/dist/cjs/server.js +245 -0
  35. package/dist/cjs/typecheck.js +615 -0
  36. package/dist/cjs/worker-federation-context.js +63 -0
  37. package/dist/cjs/worker-federation-contexts.js +97 -0
  38. package/dist/cjs/worker-federation.js +97 -0
  39. package/dist/esm/bootstrap.mjs +24 -0
  40. package/dist/esm/client.mjs +377 -0
  41. package/dist/esm/entry-application.mjs +44 -0
  42. package/dist/esm/entry-client.mjs +57 -0
  43. package/dist/esm/entry-server.mjs +91 -0
  44. package/dist/esm/federation-context.mjs +25 -0
  45. package/dist/esm/federation.mjs +167 -0
  46. package/dist/esm/i18n/I18nProvider.mjs +21 -0
  47. package/dist/esm/i18n/LocalizedLink.mjs +42 -0
  48. package/dist/esm/i18n/context.mjs +3 -0
  49. package/dist/esm/i18n/index.mjs +8 -0
  50. package/dist/esm/i18n/languageSync.mjs +61 -0
  51. package/dist/esm/i18n/types.mjs +0 -0
  52. package/dist/esm/i18n/useI18n.mjs +72 -0
  53. package/dist/esm/i18n-external-snapshot.mjs +576 -0
  54. package/dist/esm/index.mjs +8 -0
  55. package/dist/esm/manifest.mjs +117 -0
  56. package/dist/esm/router-client.mjs +98 -0
  57. package/dist/esm/router-external-snapshot.mjs +244 -0
  58. package/dist/esm/router-handler.mjs +133 -0
  59. package/dist/esm/router-server-cleanup.mjs +8 -0
  60. package/dist/esm/router-server-snapshot.mjs +367 -0
  61. package/dist/esm/router-server.mjs +11 -0
  62. package/dist/esm/router-snapshot.mjs +199 -0
  63. package/dist/esm/router.mjs +94 -0
  64. package/dist/esm/routes.mjs +134 -0
  65. package/dist/esm/server.mjs +204 -0
  66. package/dist/esm/worker-federation-context.mjs +19 -0
  67. package/dist/esm/worker-federation-contexts.mjs +47 -0
  68. package/dist/esm/worker-federation.mjs +59 -0
  69. package/dist/esm-node/bootstrap.mjs +24 -0
  70. package/dist/esm-node/manifest.mjs +117 -0
  71. package/dist/esm-node/plugin/compiler.mjs +67 -0
  72. package/dist/esm-node/plugin/create.mjs +228 -0
  73. package/dist/esm-node/plugin/index.mjs +103 -0
  74. package/dist/esm-node/plugin/profile.mjs +53 -0
  75. package/dist/esm-node/plugin/source.mjs +7 -0
  76. package/dist/esm-node/typecheck.mjs +560 -0
  77. package/dist/types/bootstrap.d.ts +10 -0
  78. package/dist/types/client.d.ts +40 -0
  79. package/dist/types/entry-application.d.ts +19 -0
  80. package/dist/types/entry-client.d.ts +10 -0
  81. package/dist/types/entry-server.d.ts +14 -0
  82. package/dist/types/federation-context.d.ts +28 -0
  83. package/dist/types/federation.d.ts +20 -0
  84. package/dist/types/i18n/I18nProvider.d.ts +8 -0
  85. package/dist/types/i18n/LocalizedLink.d.ts +14 -0
  86. package/dist/types/i18n/context.d.ts +9 -0
  87. package/dist/types/i18n/index.d.ts +9 -0
  88. package/dist/types/i18n/languageSync.d.ts +26 -0
  89. package/dist/types/i18n/types.d.ts +34 -0
  90. package/dist/types/i18n/useI18n.d.ts +21 -0
  91. package/dist/types/i18n-external-snapshot.d.ts +43 -0
  92. package/dist/types/index.d.ts +9 -0
  93. package/dist/types/manifest.d.ts +34 -0
  94. package/dist/types/plugin/compiler-manifest.d.cts +10 -0
  95. package/dist/types/plugin/compiler.d.ts +5 -0
  96. package/dist/types/plugin/create.d.ts +23 -0
  97. package/dist/types/plugin/index.d.ts +3 -0
  98. package/dist/types/plugin/profile.d.ts +2 -0
  99. package/dist/types/plugin/source.d.ts +1 -0
  100. package/dist/types/plugin/svg-component-template.d.cts +6 -0
  101. package/dist/types/router-client.d.ts +12 -0
  102. package/dist/types/router-external-snapshot.d.ts +10 -0
  103. package/dist/types/router-handler.d.ts +13 -0
  104. package/dist/types/router-server-cleanup.d.ts +3 -0
  105. package/dist/types/router-server-snapshot.d.ts +15 -0
  106. package/dist/types/router-server.d.ts +11 -0
  107. package/dist/types/router-snapshot.d.ts +14 -0
  108. package/dist/types/router.d.ts +30 -0
  109. package/dist/types/routes.d.ts +20 -0
  110. package/dist/types/server.d.ts +47 -0
  111. package/dist/types/typecheck.d.ts +31 -0
  112. package/dist/types/worker-federation-context.d.ts +34 -0
  113. package/dist/types/worker-federation-contexts.d.ts +25 -0
  114. package/dist/types/worker-federation.d.ts +20 -0
  115. package/package.json +278 -4
  116. package/src/bootstrap.ts +60 -0
  117. package/src/client.ts +568 -0
  118. package/src/entry-application.ts +76 -0
  119. package/src/entry-client.ts +90 -0
  120. package/src/entry-server.ts +153 -0
  121. package/src/federation-context.ts +53 -0
  122. package/src/federation.ts +307 -0
  123. package/src/i18n/I18nProvider.ts +47 -0
  124. package/src/i18n/LocalizedLink.ts +86 -0
  125. package/src/i18n/context.ts +12 -0
  126. package/src/i18n/index.ts +31 -0
  127. package/src/i18n/languageSync.ts +132 -0
  128. package/src/i18n/types.ts +36 -0
  129. package/src/i18n/useI18n.ts +119 -0
  130. package/src/i18n-external-snapshot.ts +803 -0
  131. package/src/index.ts +10 -0
  132. package/src/manifest.ts +253 -0
  133. package/src/plugin/compiler-manifest.cjs +204 -0
  134. package/src/plugin/compiler.ts +104 -0
  135. package/src/plugin/create.ts +273 -0
  136. package/src/plugin/index.ts +107 -0
  137. package/src/plugin/profile.ts +50 -0
  138. package/src/plugin/source.ts +16 -0
  139. package/src/plugin/svg-component-template.cjs +17 -0
  140. package/src/router-client.ts +144 -0
  141. package/src/router-external-snapshot.ts +363 -0
  142. package/src/router-handler.ts +185 -0
  143. package/src/router-server-cleanup.ts +11 -0
  144. package/src/router-server-snapshot.ts +564 -0
  145. package/src/router-server.ts +21 -0
  146. package/src/router-snapshot.ts +251 -0
  147. package/src/router.ts +192 -0
  148. package/src/routes.ts +274 -0
  149. package/src/server.ts +340 -0
  150. package/src/typecheck.ts +723 -0
  151. package/src/worker-federation-context.ts +51 -0
  152. package/src/worker-federation-contexts.ts +91 -0
  153. package/src/worker-federation.ts +120 -0
  154. package/README.md +0 -3
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ __webpack_require__.d(__webpack_exports__, {
31
+ OCTANE_COMPILER_VERSION: ()=>OCTANE_COMPILER_VERSION,
32
+ OCTANE_RUNTIME_VERSION: ()=>OCTANE_RUNTIME_VERSION,
33
+ compilerArtifacts: ()=>compilerArtifacts,
34
+ octaneModuleManifestFileName: ()=>octaneModuleManifestFileName,
35
+ validateOctaneModuleManifest: ()=>validateOctaneModuleManifest
36
+ });
37
+ const identity_namespaceObject = require("@modern-js/renderer-core/identity");
38
+ const external_bootstrap_js_namespaceObject = require("./bootstrap.js");
39
+ const OCTANE_RUNTIME_VERSION = '0.13.8';
40
+ const OCTANE_COMPILER_VERSION = '0.2.4';
41
+ function octaneModuleManifestFileName(entryName) {
42
+ return (0, identity_namespaceObject.nativeModuleManifestFilename)('octane', entryName);
43
+ }
44
+ function record(value, fields) {
45
+ if (!value || 'object' != typeof value || Array.isArray(value)) throw new Error('Malformed Octane compiler manifest object.');
46
+ if (Object.keys(value).some((key)=>!fields.includes(key))) throw new Error('Octane compiler manifest contains an unknown field.');
47
+ return value;
48
+ }
49
+ function digest(value) {
50
+ return 'string' == typeof value && /^[a-f\d]{64}$/u.test(value);
51
+ }
52
+ function nonempty(value) {
53
+ return 'string' == typeof value && value.trim().length > 0 && !value.includes('\0');
54
+ }
55
+ function assetPath(value) {
56
+ return nonempty(value) && value.endsWith('.js') && !value.startsWith('/') && !value.includes('\\') && !value.split('/').some((part)=>'..' === part || '.' === part || !part);
57
+ }
58
+ const validatedManifests = new WeakMap();
59
+ function validateOctaneModuleManifest(value, expectedIdentity, expectedNativeHydrationBuildId) {
60
+ (0, external_bootstrap_js_namespaceObject.assertOctaneIdentity)(expectedIdentity);
61
+ const cached = value && 'object' == typeof value ? validatedManifests.get(value) : void 0;
62
+ const manifest = cached ?? readOctaneModuleManifest(value);
63
+ (0, identity_namespaceObject.readRendererIdentity)(manifest.rendererIdentity, expectedIdentity);
64
+ if (void 0 !== expectedNativeHydrationBuildId) {
65
+ (0, external_bootstrap_js_namespaceObject.assertNativeHydrationBuildId)(expectedNativeHydrationBuildId);
66
+ if (manifest.nativeHydrationBuildId !== expectedNativeHydrationBuildId) throw new Error('Octane native hydration build differs from the compiled client.');
67
+ }
68
+ if (!cached) {
69
+ validatedManifests.set(value, manifest);
70
+ validatedManifests.set(manifest, manifest);
71
+ }
72
+ return manifest;
73
+ }
74
+ function readOctaneModuleManifest(value) {
75
+ const manifest = record(value, [
76
+ 'schemaVersion',
77
+ 'renderer',
78
+ 'runtimeVersion',
79
+ 'compilerVersion',
80
+ 'rendererIdentity',
81
+ 'nativeHydrationBuildId',
82
+ 'sourceModules',
83
+ 'assets'
84
+ ]);
85
+ if (1 !== manifest.schemaVersion || 'octane' !== manifest.renderer || manifest.runtimeVersion !== OCTANE_RUNTIME_VERSION || manifest.compilerVersion !== OCTANE_COMPILER_VERSION) throw new Error('Octane compiler manifest ABI conflicts with the application.');
86
+ const rendererIdentity = (0, identity_namespaceObject.readRendererIdentity)(manifest.rendererIdentity, manifest.rendererIdentity);
87
+ const nativeHydrationBuildId = manifest.nativeHydrationBuildId;
88
+ (0, external_bootstrap_js_namespaceObject.assertNativeHydrationBuildId)(nativeHydrationBuildId);
89
+ if (!Array.isArray(manifest.assets) || !manifest.assets.length) throw new Error('Octane compiler manifest has no emitted JavaScript closure.');
90
+ const assetNames = new Set();
91
+ const assets = manifest.assets.map((value)=>{
92
+ const asset = record(value, [
93
+ 'file',
94
+ 'sha256'
95
+ ]);
96
+ if (!assetPath(asset.file) || !digest(asset.sha256) || assetNames.has(asset.file)) throw new Error('Invalid Octane emitted asset digest.');
97
+ assetNames.add(asset.file);
98
+ return Object.freeze({
99
+ file: asset.file,
100
+ sha256: asset.sha256
101
+ });
102
+ });
103
+ if (!Array.isArray(manifest.sourceModules) || !manifest.sourceModules.length) throw new Error('Octane compiler manifest has no authenticated native sources.');
104
+ const resources = new Set();
105
+ const sourceModules = manifest.sourceModules.map((value)=>{
106
+ const source = record(value, [
107
+ 'resource',
108
+ 'canonicalId',
109
+ 'moduleId',
110
+ 'transformKind',
111
+ 'emittedSourceSha256',
112
+ 'assets'
113
+ ]);
114
+ if (!nonempty(source.resource) || source.resource.startsWith('/') || source.resource.includes('\\') || !nonempty(source.canonicalId) || !('string' == typeof source.moduleId && nonempty(source.moduleId) || 'number' == typeof source.moduleId && Number.isFinite(source.moduleId)) || !('compile' === source.transformKind || 'slots' === source.transformKind || 'client-only-stub' === source.transformKind) || !digest(source.emittedSourceSha256) || !Array.isArray(source.assets) || !source.assets.length || source.assets.some((file)=>'string' != typeof file || !assetNames.has(file)) || new Set(source.assets).size !== source.assets.length || resources.has(source.resource)) throw new Error('Invalid Octane native source-to-asset provenance.');
115
+ resources.add(source.resource);
116
+ return Object.freeze({
117
+ resource: source.resource,
118
+ canonicalId: source.canonicalId,
119
+ moduleId: source.moduleId,
120
+ transformKind: source.transformKind,
121
+ emittedSourceSha256: source.emittedSourceSha256,
122
+ assets: Object.freeze([
123
+ ...source.assets
124
+ ])
125
+ });
126
+ });
127
+ return Object.freeze({
128
+ schemaVersion: 1,
129
+ renderer: 'octane',
130
+ runtimeVersion: OCTANE_RUNTIME_VERSION,
131
+ compilerVersion: OCTANE_COMPILER_VERSION,
132
+ rendererIdentity,
133
+ nativeHydrationBuildId,
134
+ sourceModules: Object.freeze(sourceModules),
135
+ assets: Object.freeze(assets)
136
+ });
137
+ }
138
+ const compilerArtifacts = {
139
+ clientManifestFile: octaneModuleManifestFileName,
140
+ async validateClientManifest (value, identity, context) {
141
+ const hydrationBuildId = context.compilationHash ?? context.hydrationBuildId;
142
+ if (context.development && ('string' != typeof hydrationBuildId || !hydrationBuildId.trim())) throw new Error('Octane development snapshot has no native hydration build.');
143
+ const nativeManifest = validateOctaneModuleManifest(value, identity, hydrationBuildId);
144
+ return {
145
+ nativeManifest,
146
+ hydrationBuildId: nativeManifest.nativeHydrationBuildId
147
+ };
148
+ },
149
+ isMutableDevelopmentAsset (filename, entryNames) {
150
+ return 'octane-client-build.json' === filename || entryNames.some((entry)=>filename === octaneModuleManifestFileName(entry));
151
+ }
152
+ };
153
+ exports.OCTANE_COMPILER_VERSION = __webpack_exports__.OCTANE_COMPILER_VERSION;
154
+ exports.OCTANE_RUNTIME_VERSION = __webpack_exports__.OCTANE_RUNTIME_VERSION;
155
+ exports.compilerArtifacts = __webpack_exports__.compilerArtifacts;
156
+ exports.octaneModuleManifestFileName = __webpack_exports__.octaneModuleManifestFileName;
157
+ exports.validateOctaneModuleManifest = __webpack_exports__.validateOctaneModuleManifest;
158
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
159
+ "OCTANE_COMPILER_VERSION",
160
+ "OCTANE_RUNTIME_VERSION",
161
+ "compilerArtifacts",
162
+ "octaneModuleManifestFileName",
163
+ "validateOctaneModuleManifest"
164
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
165
+ Object.defineProperty(exports, '__esModule', {
166
+ value: true
167
+ });
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ const __rslib_import_meta_url__ = /*#__PURE__*/ function() {
3
+ return "u" < typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
4
+ }();
5
+ var __webpack_require__ = {};
6
+ (()=>{
7
+ __webpack_require__.n = (module)=>{
8
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
9
+ __webpack_require__.d(getter, {
10
+ a: getter
11
+ });
12
+ return getter;
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.d = (exports1, getters, values)=>{
17
+ var define = (defs, kind)=>{
18
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
19
+ enumerable: true,
20
+ [kind]: defs[key]
21
+ });
22
+ };
23
+ define(getters, "get");
24
+ define(values, "value");
25
+ };
26
+ })();
27
+ (()=>{
28
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
29
+ })();
30
+ (()=>{
31
+ __webpack_require__.r = (exports1)=>{
32
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
33
+ value: 'Module'
34
+ });
35
+ Object.defineProperty(exports1, '__esModule', {
36
+ value: true
37
+ });
38
+ };
39
+ })();
40
+ var __webpack_exports__ = {};
41
+ __webpack_require__.r(__webpack_exports__);
42
+ __webpack_require__.d(__webpack_exports__, {
43
+ createOctaneCompilerPlugin: ()=>createOctaneCompilerPlugin,
44
+ pluginSourceDirectory: ()=>pluginSourceDirectory
45
+ });
46
+ const external_node_fs_namespaceObject = require("node:fs");
47
+ var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
48
+ const external_node_module_namespaceObject = require("node:module");
49
+ const external_node_path_namespaceObject = require("node:path");
50
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
51
+ const external_node_url_namespaceObject = require("node:url");
52
+ const external_manifest_js_namespaceObject = require("../manifest.js");
53
+ function pluginSourceDirectory() {
54
+ let directory = external_node_path_default().dirname((0, external_node_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__));
55
+ while(true){
56
+ const compiler = external_node_path_default().join(directory, 'src/plugin');
57
+ if (external_node_fs_default().existsSync(external_node_path_default().join(directory, 'package.json')) && external_node_fs_default().existsSync(external_node_path_default().join(compiler, 'compiler-manifest.cjs'))) return compiler;
58
+ const parent = external_node_path_default().dirname(directory);
59
+ if (parent === directory) throw new Error('Cannot locate the UltraModern Octane compiler package.');
60
+ directory = parent;
61
+ }
62
+ }
63
+ function createOctaneCompilerPlugin(options) {
64
+ return {
65
+ name: 'ultramodern:octane:compiler',
66
+ setup (api) {
67
+ const directory = pluginSourceDirectory();
68
+ const require1 = (0, external_node_module_namespaceObject.createRequire)(external_node_path_default().join(directory, 'index.cjs'));
69
+ const { OctaneCompilerManifestPlugin } = require1('./compiler-manifest.cjs');
70
+ const appRequire = (0, external_node_module_namespaceObject.createRequire)(external_node_path_default().join(api.context.rootPath, 'package.json'));
71
+ const { inferRspackEnvironment, OctaneRspackPlugin } = appRequire('@octanejs/rspack-plugin');
72
+ api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>mergeRsbuildConfig(config, {
73
+ source: {
74
+ include: [
75
+ /[/\\]@octanejs[/\\]/u
76
+ ]
77
+ }
78
+ }));
79
+ api.modifyRspackConfig((config, { environment: rsbuildEnvironment })=>{
80
+ const environment = rsbuildEnvironment.name === options.workerEnvironmentName ? 'server' : inferRspackEnvironment(config.target);
81
+ config.plugins ??= [];
82
+ config.plugins.push(new OctaneRspackPlugin({
83
+ root: api.context.rootPath,
84
+ environment,
85
+ transpile: false
86
+ }));
87
+ config.plugins.push(new OctaneCompilerManifestPlugin({
88
+ emitClientManifest: 'client' === environment,
89
+ root: api.context.rootPath,
90
+ runtimeVersion: external_manifest_js_namespaceObject.OCTANE_RUNTIME_VERSION,
91
+ compilerVersion: external_manifest_js_namespaceObject.OCTANE_COMPILER_VERSION,
92
+ rendererIdentities: options.rendererIdentities,
93
+ manifestFilename: external_manifest_js_namespaceObject.octaneModuleManifestFileName,
94
+ validateManifest: external_manifest_js_namespaceObject.validateOctaneModuleManifest
95
+ }));
96
+ config.module ??= {};
97
+ config.module.rules ??= [];
98
+ config.module.rules.push({
99
+ test: /\.tsrx$/u,
100
+ type: "javascript/auto",
101
+ use: [
102
+ {
103
+ loader: 'builtin:swc-loader',
104
+ options: {
105
+ detectSyntax: 'auto'
106
+ }
107
+ }
108
+ ]
109
+ });
110
+ });
111
+ }
112
+ };
113
+ }
114
+ exports.createOctaneCompilerPlugin = __webpack_exports__.createOctaneCompilerPlugin;
115
+ exports.pluginSourceDirectory = __webpack_exports__.pluginSourceDirectory;
116
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
117
+ "createOctaneCompilerPlugin",
118
+ "pluginSourceDirectory"
119
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
120
+ Object.defineProperty(exports, '__esModule', {
121
+ value: true
122
+ });
@@ -0,0 +1,266 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
13
+ };
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
+ })();
18
+ (()=>{
19
+ __webpack_require__.r = (exports1)=>{
20
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
+ value: 'Module'
22
+ });
23
+ Object.defineProperty(exports1, '__esModule', {
24
+ value: true
25
+ });
26
+ };
27
+ })();
28
+ var __webpack_exports__ = {};
29
+ __webpack_require__.r(__webpack_exports__);
30
+ function generateOctaneAppSources(options) {
31
+ if ((options.entryName ?? 'main') !== 'main') throw new Error('The Octane app template supports the main entry only. The create-time workspace writer places src/modern-app-env.d.ts, src/routes/index.css and the package manifest at the app root regardless of entryName, so it cannot yet route a second entry into src/<entryName>/. Add that entry by hand after generation (mirror src/routes under src/<entryName>/routes) until an admitted native multi-entry create template exists; the native entry generator itself already supports arbitrary entry names.');
32
+ if (!options.appId.trim() || !options.title.trim()) throw new Error('The Octane app template requires an appId and title.');
33
+ if ('.tsx' !== options.sourceExtension) throw new Error('The Octane app template requires the admitted .tsx source profile. .tsrx generation requires an admitted native template profile.');
34
+ if ('octane' !== options.jsxImportSource) throw new Error('The Octane app template requires jsxImportSource: "octane" from the admitted profile.');
35
+ if ('boolean' != typeof options.capabilities.ssr || 'boolean' != typeof options.capabilities.federation) throw new Error('The Octane app template requires admitted capabilities.');
36
+ const title = JSON.stringify(options.title);
37
+ const aboutTitle = JSON.stringify(`${options.title} - About`);
38
+ const appId = JSON.stringify(options.appId);
39
+ return {
40
+ sourceExtension: '.tsx',
41
+ jsxImportSource: 'octane',
42
+ artifacts: [
43
+ {
44
+ path: 'src/routes/layout.tsx',
45
+ content: `import { Link, Outlet } from '@modern-js/renderer-octane/router';
46
+ import Stable from '../components/stable';
47
+ import './index.css';
48
+
49
+ const appTitle = ${title};
50
+
51
+ export default function Layout() {
52
+ return (
53
+ <main data-testid="native-layout">
54
+ <header>
55
+ <p>{appTitle}</p>
56
+ <nav aria-label="Application">
57
+ <Link to="/">Home</Link>
58
+ <Link to="/about">About</Link>
59
+ ${options.capabilities.federation ? ' <Link to="/remotes">Federated applications</Link>\n' : ''}
60
+ </nav>
61
+ </header>
62
+ <Stable />
63
+ <Outlet />
64
+ </main>
65
+ );
66
+ }
67
+ `
68
+ },
69
+ {
70
+ path: 'src/routes/page.tsx',
71
+ content: `import {
72
+ Link,
73
+ useLoaderData,
74
+ useOctaneRouteAction,
75
+ } from '@modern-js/renderer-octane/router';
76
+ import { useActionState } from 'octane';
77
+ import Counter from '../components/counter';
78
+
79
+ const appId = ${appId};
80
+ const appTitle = ${title};
81
+
82
+ export default function HomePage() {
83
+ const data = useLoaderData({ strict: false });
84
+ const submit = useOctaneRouteAction();
85
+ const [result, action, pending] = useActionState(submit, undefined);
86
+ return (
87
+ <section data-app-id={appId} data-testid="native-route" data-renderer="octane">
88
+ <h1>{appTitle}</h1>
89
+ <Counter />
90
+ <pre data-testid="native-loader-value">{JSON.stringify(data)}</pre>
91
+ <form action={action}>
92
+ <label>
93
+ Name <input name="name" />
94
+ </label>
95
+ <button type="submit" disabled={pending}>
96
+ Save
97
+ </button>
98
+ <button type="submit" name="intent" value="redirect">
99
+ Save and redirect
100
+ </button>
101
+ </form>
102
+ <pre data-testid="native-action-value">{JSON.stringify(result)}</pre>
103
+ <Link to="/about">Open native about route</Link>
104
+ </section>
105
+ );
106
+ }
107
+ `
108
+ },
109
+ {
110
+ path: 'src/routes/page.head.ts',
111
+ content: `import type { FileSystemRouteModule } from '@modern-js/renderer-octane/router';
112
+
113
+ export const head: NonNullable<FileSystemRouteModule['head']> = () => ({
114
+ meta: [
115
+ { title: ${title} },
116
+ { name: 'description', content: 'Built with the native Octane renderer' },
117
+ ],
118
+ });
119
+ `
120
+ },
121
+ {
122
+ path: 'src/routes/about/page.tsx',
123
+ content: `import { Link } from '@modern-js/renderer-octane/router';
124
+
125
+ export default function AboutPage() {
126
+ return (
127
+ <section data-testid="native-about">
128
+ <h1>Native Octane navigation</h1>
129
+ <Link to="/">Home</Link>
130
+ </section>
131
+ );
132
+ }
133
+ `
134
+ },
135
+ {
136
+ path: 'src/routes/about/page.head.ts',
137
+ content: `import type { FileSystemRouteModule } from '@modern-js/renderer-octane/router';
138
+
139
+ export const head: NonNullable<FileSystemRouteModule['head']> = () => ({
140
+ meta: [
141
+ { title: ${aboutTitle} },
142
+ { name: 'description', content: 'Built with the native Octane renderer' },
143
+ ],
144
+ });
145
+ `
146
+ },
147
+ {
148
+ path: 'src/components/counter.tsx',
149
+ content: `import { useState } from 'octane';
150
+
151
+ export default function Counter() {
152
+ const [count, setCount] = useState(0);
153
+ return (
154
+ <section data-testid="native-edited-component">
155
+ <span data-testid="native-hmr-marker">Counter before native edit</span>
156
+ <button type="button" onClick={() => setCount(value => value + 1)}>
157
+ Increment
158
+ </button>
159
+ <output data-testid="native-count">{count}</output>
160
+ </section>
161
+ );
162
+ }
163
+ `
164
+ },
165
+ {
166
+ path: 'src/components/stable.tsx',
167
+ content: `import { useState } from 'octane';
168
+
169
+ export default function Stable() {
170
+ const [count, setCount] = useState(0);
171
+ return (
172
+ <section data-testid="native-unaffected-component">
173
+ <button type="button" onClick={() => setCount(value => value + 1)}>
174
+ Increment stable state
175
+ </button>
176
+ <output data-testid="native-unaffected-count">{count}</output>
177
+ </section>
178
+ );
179
+ }
180
+ `
181
+ },
182
+ {
183
+ path: 'src/routes/page.data.ts',
184
+ content: `import type { DataHandlerInput } from '@modern-js/renderer-core/data';
185
+
186
+ export function loader({ request }: DataHandlerInput) {
187
+ const url = new URL(request.url);
188
+ if (url.searchParams.get('case') === 'not-found')
189
+ throw new Response('Native route not found', { status: 404 });
190
+ if (url.searchParams.get('case') === 'error')
191
+ throw new Error('Native loader failure');
192
+ if (url.searchParams.get('case') === 'redirect')
193
+ return new Response(null, { headers: { location: '/about' }, status: 302 });
194
+ return {
195
+ message: 'Native loader value',
196
+ privateValue: request.headers.get('x-conformance-private'),
197
+ };
198
+ }
199
+
200
+ export function action({ request }: DataHandlerInput) {
201
+ return request.formData().then(form => {
202
+ const name = form.get('name');
203
+ if (typeof name !== 'string' || name.trim().length === 0)
204
+ return Response.json(
205
+ { fieldErrors: { name: 'Name required' } },
206
+ { status: 422 },
207
+ );
208
+ if (form.get('intent') === 'redirect')
209
+ return new Response(null, {
210
+ headers: {
211
+ location: '/about',
212
+ 'set-cookie': 'conformance-saved=1; Path=/; SameSite=Lax',
213
+ },
214
+ status: 303,
215
+ });
216
+ if (form.get('intent') === 'throw') throw new Error('Native action failure');
217
+ return {
218
+ saved: name,
219
+ privateValue: request.headers.get('x-conformance-private'),
220
+ };
221
+ });
222
+ }
223
+ `
224
+ },
225
+ {
226
+ path: 'src/routes/error.tsx',
227
+ content: `import type { ErrorRouteComponent } from '@modern-js/renderer-octane/router';
228
+
229
+ const ErrorBoundary: ErrorRouteComponent = props => (
230
+ <section data-testid="native-error">
231
+ <h1>Something went wrong</h1>
232
+ <output>
233
+ {props.error instanceof Error ? props.error.message : String(props.error)}
234
+ </output>
235
+ </section>
236
+ );
237
+
238
+ export default ErrorBoundary;
239
+ `
240
+ },
241
+ {
242
+ path: 'src/routes/not-found.tsx',
243
+ content: `import type { NotFoundRouteComponent } from '@modern-js/renderer-octane/router';
244
+
245
+ const NotFound: NotFoundRouteComponent = () => (
246
+ <section data-testid="native-not-found">
247
+ <h1>Page not found</h1>
248
+ </section>
249
+ );
250
+
251
+ export default NotFound;
252
+ `
253
+ }
254
+ ]
255
+ };
256
+ }
257
+ __webpack_require__.d(__webpack_exports__, {
258
+ generateOctaneAppSources: ()=>generateOctaneAppSources
259
+ });
260
+ exports.generateOctaneAppSources = __webpack_exports__.generateOctaneAppSources;
261
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
262
+ "generateOctaneAppSources"
263
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
264
+ Object.defineProperty(exports, '__esModule', {
265
+ value: true
266
+ });