@bleedingdev/modern-js-runtime-renderer-extensions 0.0.0 → 3.9.0-ultramodern.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/cjs/assetPolicy.js +89 -0
- package/dist/cjs/federatedCss.js +57 -0
- package/dist/cjs/node.js +53 -0
- package/dist/cjs/runtimePlugin.js +131 -0
- package/dist/cjs/templatePolicy.js +76 -0
- package/dist/esm/assetPolicy.mjs +48 -0
- package/dist/esm/federatedCss.mjs +19 -0
- package/dist/esm/runtimePlugin.mjs +78 -0
- package/dist/esm/templatePolicy.mjs +38 -0
- package/dist/esm-node/assetPolicy.mjs +49 -0
- package/dist/esm-node/federatedCss.mjs +20 -0
- package/dist/esm-node/node.mjs +11 -0
- package/dist/esm-node/runtimePlugin.mjs +79 -0
- package/dist/esm-node/templatePolicy.mjs +39 -0
- package/dist/types/assetPolicy.d.ts +19 -0
- package/dist/types/federatedCss.d.ts +6 -0
- package/dist/types/node.d.ts +3 -0
- package/dist/types/runtimePlugin.d.ts +7 -0
- package/dist/types/templatePolicy.d.ts +2 -0
- package/package.json +61 -7
- package/rslib.config.mts +19 -0
- package/rstest.config.mts +29 -0
- package/src/assetPolicy.ts +86 -0
- package/src/federatedCss.ts +43 -0
- package/src/node.ts +16 -0
- package/src/runtimePlugin.ts +119 -0
- package/src/templatePolicy.ts +69 -0
- package/tests/federatedCss.test.ts +80 -0
- package/tests/headRuntime.test.tsx +334 -0
- package/tests/nativeAssetPolicy.test.tsx +515 -0
- package/tests/nativeStreamHead.test.tsx +77 -0
- package/tests/nativeStringHead.test.tsx +128 -0
- package/tests/nativeTemplatePolicy.test.tsx +818 -0
- package/tests/runtimePlugin.test.tsx +37 -0
- package/tests/scriptOrder.security.test.ts +42 -0
- package/tsconfig.json +10 -0
- package/README.md +0 -3
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { build } from 'esbuild';
|
|
3
|
+
|
|
4
|
+
const packageDirectory = fileURLToPath(new URL('..', import.meta.url));
|
|
5
|
+
|
|
6
|
+
// Resolve the public package entry, including its platform conditions.
|
|
7
|
+
test.each([
|
|
8
|
+
'browser',
|
|
9
|
+
'node',
|
|
10
|
+
] as const)('public %s entry selects the matching renderer adapter', async platform => {
|
|
11
|
+
const output = await build({
|
|
12
|
+
absWorkingDir: packageDirectory,
|
|
13
|
+
stdin: {
|
|
14
|
+
contents:
|
|
15
|
+
"export { default } from '@modern-js/runtime-renderer-extensions'",
|
|
16
|
+
resolveDir: packageDirectory,
|
|
17
|
+
},
|
|
18
|
+
bundle: true,
|
|
19
|
+
write: false,
|
|
20
|
+
metafile: true,
|
|
21
|
+
platform,
|
|
22
|
+
format: 'esm',
|
|
23
|
+
conditions: ['modern:source'],
|
|
24
|
+
});
|
|
25
|
+
const inputs = Object.keys(output.metafile.inputs);
|
|
26
|
+
expect(inputs.some(input => input.endsWith('/runtimePlugin.ts'))).toBe(true);
|
|
27
|
+
expect(
|
|
28
|
+
inputs.some(input => input.endsWith('/runtime-extensions/src/node.ts')),
|
|
29
|
+
).toBe(platform === 'node');
|
|
30
|
+
expect(
|
|
31
|
+
inputs.some(
|
|
32
|
+
input =>
|
|
33
|
+
input === 'src/node.ts' ||
|
|
34
|
+
input.endsWith('/renderer-extensions/src/node.ts'),
|
|
35
|
+
),
|
|
36
|
+
).toBe(platform === 'node');
|
|
37
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createRouteHydrationScriptTags as createTags } from '@modern-js/runtime-extensions';
|
|
2
|
+
import {
|
|
3
|
+
applyRouterRuntimeState,
|
|
4
|
+
getRouterMatchedRouteIds,
|
|
5
|
+
} from '@modern-js/runtime-extensions/router-state';
|
|
6
|
+
|
|
7
|
+
const createRouteHydrationScriptTags = (
|
|
8
|
+
context: any,
|
|
9
|
+
entryName: string,
|
|
10
|
+
options: any,
|
|
11
|
+
) =>
|
|
12
|
+
createTags(
|
|
13
|
+
context.routeManifest,
|
|
14
|
+
getRouterMatchedRouteIds(context) ?? [],
|
|
15
|
+
entryName,
|
|
16
|
+
options,
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
describe('route hydration script serialization', () => {
|
|
20
|
+
it('quotes and escapes asset and nonce attributes', () => {
|
|
21
|
+
const runtimeContext = {} as any;
|
|
22
|
+
applyRouterRuntimeState(runtimeContext, {
|
|
23
|
+
framework: 'react-router',
|
|
24
|
+
serverSnapshot: { matchedRouteIds: ['route-a'] },
|
|
25
|
+
});
|
|
26
|
+
runtimeContext.routeManifest = {
|
|
27
|
+
routeAssets: {
|
|
28
|
+
'route-a': {
|
|
29
|
+
assets: ['/route" onload="alert(1)&x=<tag>.js'],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
expect(
|
|
35
|
+
createRouteHydrationScriptTags(runtimeContext, 'main', {
|
|
36
|
+
nonce: 'nonce"&<value>',
|
|
37
|
+
}),
|
|
38
|
+
).toBe(
|
|
39
|
+
'<script src="/route" onload="alert(1)&x=<tag>.js" nonce="nonce"&<value>"></script>',
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
});
|
package/tsconfig.json
ADDED
package/README.md
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
# @bleedingdev/modern-js-runtime-renderer-extensions
|
|
2
|
-
|
|
3
|
-
This 0.0.0 version only registers the package name so npm trusted publishing can be configured. It contains no runtime implementation. Use the subsequent UltraModern.js release, published from the repository workflow with provenance.
|