@ohos-ports/teambit-preview-modules-preview-modules 0.0.0-stage → 1.0.3-beta.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/index.d.ts +2 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/preview-1706697595652.js +7 -0
- package/dist/preview-modules.d.ts +15 -0
- package/dist/preview-modules.docs.mdx +14 -0
- package/dist/preview-modules.js +39 -0
- package/dist/preview-modules.js.map +1 -0
- package/dist/tsconfig.json +32 -0
- package/dist/types/preview-module.d.ts +31 -0
- package/dist/types/preview-module.js +3 -0
- package/dist/types/preview-module.js.map +1 -0
- package/index.ts +6 -0
- package/package.json +16 -4
- package/preview-modules.docs.mdx +14 -0
- package/preview-modules.ts +48 -0
- package/tsconfig.json +32 -0
- package/types/asset.d.ts +29 -0
- package/types/preview-module.ts +38 -0
- package/types/style.d.ts +42 -0
- package/README.md +0 -3
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.linkModules = exports.PreviewModules = exports.PREVIEW_MODULES = void 0;
|
|
4
|
+
var preview_modules_1 = require("./preview-modules");
|
|
5
|
+
Object.defineProperty(exports, "PREVIEW_MODULES", { enumerable: true, get: function () { return preview_modules_1.PREVIEW_MODULES; } });
|
|
6
|
+
Object.defineProperty(exports, "PreviewModules", { enumerable: true, get: function () { return preview_modules_1.PreviewModules; } });
|
|
7
|
+
Object.defineProperty(exports, "linkModules", { enumerable: true, get: function () { return preview_modules_1.linkModules; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,qDAI2B;AAHzB,kHAAA,eAAe,OAAA;AACf,iHAAA,cAAc,OAAA;AACd,8GAAA,WAAW,OAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
;
|
|
2
|
+
import * as overview_0 from '/Users/giladshoham/Library/Caches/Bit/capsules/root/e43b6116945cee5ca1d1bf65bd89ae6d1ef7764f/teambit.preview_modules_preview-modules@1.0.3/dist/preview-modules.docs.mdx';
|
|
3
|
+
|
|
4
|
+
export const compositions = [];
|
|
5
|
+
export const overview = [overview_0];
|
|
6
|
+
|
|
7
|
+
export const compositions_metadata = {"compositions":[]};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PreviewModule, ModuleFile } from './types/preview-module';
|
|
2
|
+
declare type ModuleId = string;
|
|
3
|
+
export declare class PreviewModules extends Map<ModuleId, PreviewModule> {
|
|
4
|
+
onSet: Set<() => void>;
|
|
5
|
+
set(id: ModuleId, preview: PreviewModule): this;
|
|
6
|
+
loadComponentPreviews(compId: string, previews: Record<string, ModuleFile[]>): void;
|
|
7
|
+
}
|
|
8
|
+
declare global {
|
|
9
|
+
interface Window {
|
|
10
|
+
__bit_preview_modules: PreviewModules;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export declare const PREVIEW_MODULES: PreviewModules;
|
|
14
|
+
export declare function linkModules(previewName: string, previewModule: PreviewModule): void;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
labels: ['preview']
|
|
3
|
+
description: 'A component to make preview modules easier available on the global object.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
API:
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
PREVIEW_MODULES: PreviewModules;
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
function linkModules(previewName: string, previewModule: PreviewModule);
|
|
14
|
+
```
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.linkModules = exports.PREVIEW_MODULES = exports.PreviewModules = void 0;
|
|
4
|
+
class PreviewModules extends Map {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.onSet = new Set();
|
|
8
|
+
}
|
|
9
|
+
set(id, preview) {
|
|
10
|
+
super.set(id, preview);
|
|
11
|
+
this.onSet.forEach((callback) => callback());
|
|
12
|
+
return this;
|
|
13
|
+
}
|
|
14
|
+
loadComponentPreviews(compId, previews) {
|
|
15
|
+
Object.entries(previews).forEach(([previewName, moduleFile]) => {
|
|
16
|
+
const preview = this.get(previewName);
|
|
17
|
+
if (!preview)
|
|
18
|
+
return; // TODO - ok for now
|
|
19
|
+
preview.componentMap[compId] = moduleFile;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.PreviewModules = PreviewModules;
|
|
24
|
+
// singleton for the browser
|
|
25
|
+
function getPreviewModules() {
|
|
26
|
+
if (typeof window !== 'undefined') {
|
|
27
|
+
if (!window.__bit_preview_modules) {
|
|
28
|
+
window.__bit_preview_modules = new PreviewModules();
|
|
29
|
+
}
|
|
30
|
+
return window.__bit_preview_modules;
|
|
31
|
+
}
|
|
32
|
+
return new PreviewModules();
|
|
33
|
+
}
|
|
34
|
+
exports.PREVIEW_MODULES = getPreviewModules();
|
|
35
|
+
function linkModules(previewName, previewModule) {
|
|
36
|
+
exports.PREVIEW_MODULES.set(previewName, previewModule);
|
|
37
|
+
}
|
|
38
|
+
exports.linkModules = linkModules;
|
|
39
|
+
//# sourceMappingURL=preview-modules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-modules.js","sourceRoot":"","sources":["../preview-modules.ts"],"names":[],"mappings":";;;AAIA,MAAa,cAAe,SAAQ,GAA4B;IAAhE;;QACE,UAAK,GAAG,IAAI,GAAG,EAAc,CAAC;IAmBhC,CAAC;IAjBU,GAAG,CAAC,EAAY,EAAE,OAAsB;QAC/C,KAAK,CAAC,GAAG,CAAC,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onJS",
|
|
11
|
+
"jsx": "react",
|
|
12
|
+
"allowJs": true,
|
|
13
|
+
"composite": true,
|
|
14
|
+
"declaration": true,
|
|
15
|
+
"sourceMap": true,
|
|
16
|
+
"skipLibCheck": true,
|
|
17
|
+
"experimentalDecorators": true,
|
|
18
|
+
"outDir": "dist",
|
|
19
|
+
"moduleResolution": "node",
|
|
20
|
+
"esModuleInterop": true,
|
|
21
|
+
"rootDir": ".",
|
|
22
|
+
"resolveJsonModule": true
|
|
23
|
+
},
|
|
24
|
+
"exclude": [
|
|
25
|
+
"dist",
|
|
26
|
+
"package.json"
|
|
27
|
+
],
|
|
28
|
+
"include": [
|
|
29
|
+
"**/*",
|
|
30
|
+
"**/*.json"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
declare type MainModuleExports = {
|
|
2
|
+
(...args: any[]): void;
|
|
3
|
+
apiObject?: boolean;
|
|
4
|
+
};
|
|
5
|
+
declare type DefaultObject = MainModuleExports | {
|
|
6
|
+
default: MainModuleExports;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* A full index of the preview data
|
|
10
|
+
*/
|
|
11
|
+
export declare type PreviewModule<T = any> = {
|
|
12
|
+
/** Dictionary mapping components to their module files. */
|
|
13
|
+
componentMap: Record<string, ModuleFile<T>[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Dictionary mapping components to their preview metadata
|
|
16
|
+
*/
|
|
17
|
+
componentMapMetadata: Record<string, unknown>;
|
|
18
|
+
/** The 'main file' for this Preview type */
|
|
19
|
+
modulesMap: {
|
|
20
|
+
default: {
|
|
21
|
+
default: DefaultObject;
|
|
22
|
+
};
|
|
23
|
+
[envId: string]: {
|
|
24
|
+
default: DefaultObject;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
isSplitComponentBundle?: boolean;
|
|
28
|
+
};
|
|
29
|
+
/** single preview module, e.g. compositions file */
|
|
30
|
+
export declare type ModuleFile<T = any> = Record<string, T>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-module.js","sourceRoot":"","sources":["../../types/preview-module.ts"],"names":[],"mappings":""}
|
package/index.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ohos-ports/teambit-preview-modules-preview-modules",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.3-beta.0",
|
|
4
|
+
"homepage": "https://bit.cloud/teambit/preview/modules/preview-modules",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"componentId": {
|
|
7
|
+
"scope": "teambit.preview",
|
|
8
|
+
"name": "modules/preview-modules",
|
|
9
|
+
"version": "1.0.3"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {},
|
|
12
|
+
"peerDependencies": {},
|
|
13
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
14
|
+
"optionalDependencies": {},
|
|
15
|
+
"peerDependenciesMeta": {},
|
|
16
|
+
"private": false,
|
|
17
|
+
"description": "HarmonyOS port of @teambit/preview.modules.preview-modules@1.0.3; republished because the original exists only on the bit.cloud registry and is missing from public npm; dist artifacts untouched."
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
labels: ['preview']
|
|
3
|
+
description: 'A component to make preview modules easier available on the global object.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
API:
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
PREVIEW_MODULES: PreviewModules;
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
function linkModules(previewName: string, previewModule: PreviewModule);
|
|
14
|
+
```
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { PreviewModule, ModuleFile } from './types/preview-module';
|
|
2
|
+
|
|
3
|
+
type ModuleId = string;
|
|
4
|
+
|
|
5
|
+
export class PreviewModules extends Map<ModuleId, PreviewModule> {
|
|
6
|
+
onSet = new Set<() => void>();
|
|
7
|
+
|
|
8
|
+
override set(id: ModuleId, preview: PreviewModule) {
|
|
9
|
+
super.set(id, preview);
|
|
10
|
+
this.onSet.forEach((callback) => callback());
|
|
11
|
+
return this;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
loadComponentPreviews(
|
|
15
|
+
compId: string,
|
|
16
|
+
previews: Record<string, ModuleFile[]>
|
|
17
|
+
) {
|
|
18
|
+
Object.entries(previews).forEach(([previewName, moduleFile]) => {
|
|
19
|
+
const preview = this.get(previewName);
|
|
20
|
+
if (!preview) return; // TODO - ok for now
|
|
21
|
+
|
|
22
|
+
preview.componentMap[compId] = moduleFile;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare global {
|
|
28
|
+
interface Window {
|
|
29
|
+
__bit_preview_modules: PreviewModules;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// singleton for the browser
|
|
34
|
+
function getPreviewModules() {
|
|
35
|
+
if (typeof window !== 'undefined') {
|
|
36
|
+
if (!(window as any).__bit_preview_modules) {
|
|
37
|
+
window.__bit_preview_modules = new PreviewModules();
|
|
38
|
+
}
|
|
39
|
+
return window.__bit_preview_modules;
|
|
40
|
+
}
|
|
41
|
+
return new PreviewModules();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const PREVIEW_MODULES = getPreviewModules();
|
|
45
|
+
|
|
46
|
+
export function linkModules(previewName: string, previewModule: PreviewModule) {
|
|
47
|
+
PREVIEW_MODULES.set(previewName, previewModule);
|
|
48
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"lib": [
|
|
4
|
+
"es2019",
|
|
5
|
+
"DOM",
|
|
6
|
+
"ES6",
|
|
7
|
+
"DOM.Iterable"
|
|
8
|
+
],
|
|
9
|
+
"target": "es2015",
|
|
10
|
+
"module": "CommonJS",
|
|
11
|
+
"jsx": "react",
|
|
12
|
+
"allowJs": true,
|
|
13
|
+
"composite": true,
|
|
14
|
+
"declaration": true,
|
|
15
|
+
"sourceMap": true,
|
|
16
|
+
"skipLibCheck": true,
|
|
17
|
+
"experimentalDecorators": true,
|
|
18
|
+
"outDir": "dist",
|
|
19
|
+
"moduleResolution": "node",
|
|
20
|
+
"esModuleInterop": true,
|
|
21
|
+
"rootDir": ".",
|
|
22
|
+
"resolveJsonModule": true
|
|
23
|
+
},
|
|
24
|
+
"exclude": [
|
|
25
|
+
"dist",
|
|
26
|
+
"package.json"
|
|
27
|
+
],
|
|
28
|
+
"include": [
|
|
29
|
+
"**/*",
|
|
30
|
+
"**/*.json"
|
|
31
|
+
]
|
|
32
|
+
}
|
package/types/asset.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
declare module '*.png' {
|
|
2
|
+
const value: any;
|
|
3
|
+
export = value;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.svg' {
|
|
6
|
+
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
|
+
|
|
8
|
+
export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
|
|
9
|
+
const src: string;
|
|
10
|
+
export default src;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// @TODO Gilad
|
|
14
|
+
declare module '*.jpg' {
|
|
15
|
+
const value: any;
|
|
16
|
+
export = value;
|
|
17
|
+
}
|
|
18
|
+
declare module '*.jpeg' {
|
|
19
|
+
const value: any;
|
|
20
|
+
export = value;
|
|
21
|
+
}
|
|
22
|
+
declare module '*.gif' {
|
|
23
|
+
const value: any;
|
|
24
|
+
export = value;
|
|
25
|
+
}
|
|
26
|
+
declare module '*.bmp' {
|
|
27
|
+
const value: any;
|
|
28
|
+
export = value;
|
|
29
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
type MainModuleExports = {
|
|
2
|
+
(...args: any[]): void;
|
|
3
|
+
apiObject?: boolean;
|
|
4
|
+
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// When using package.json with type: "module" field, there might be another default property
|
|
8
|
+
type DefaultObject = MainModuleExports | {
|
|
9
|
+
default: MainModuleExports;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A full index of the preview data
|
|
14
|
+
*/
|
|
15
|
+
export type PreviewModule<T = any> = {
|
|
16
|
+
/** Dictionary mapping components to their module files. */
|
|
17
|
+
componentMap: Record<string, ModuleFile<T>[]>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Dictionary mapping components to their preview metadata
|
|
21
|
+
*/
|
|
22
|
+
componentMapMetadata: Record<string, unknown>;
|
|
23
|
+
|
|
24
|
+
/** The 'main file' for this Preview type */
|
|
25
|
+
modulesMap: {
|
|
26
|
+
default: {
|
|
27
|
+
default: DefaultObject;
|
|
28
|
+
};
|
|
29
|
+
[envId: string]: {
|
|
30
|
+
default: DefaultObject;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
isSplitComponentBundle?: boolean;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** single preview module, e.g. compositions file */
|
|
38
|
+
export type ModuleFile<T = any> = Record<string, T>;
|
package/types/style.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
declare module '*.module.css' {
|
|
2
|
+
const classes: { readonly [key: string]: string };
|
|
3
|
+
export default classes;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.module.scss' {
|
|
6
|
+
const classes: { readonly [key: string]: string };
|
|
7
|
+
export default classes;
|
|
8
|
+
}
|
|
9
|
+
declare module '*.module.sass' {
|
|
10
|
+
const classes: { readonly [key: string]: string };
|
|
11
|
+
export default classes;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module '*.module.less' {
|
|
15
|
+
const classes: { readonly [key: string]: string };
|
|
16
|
+
export default classes;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module '*.less' {
|
|
20
|
+
const classes: { readonly [key: string]: string };
|
|
21
|
+
export default classes;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare module '*.css' {
|
|
25
|
+
const classes: { readonly [key: string]: string };
|
|
26
|
+
export default classes;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare module '*.sass' {
|
|
30
|
+
const classes: { readonly [key: string]: string };
|
|
31
|
+
export default classes;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare module '*.scss' {
|
|
35
|
+
const classes: { readonly [key: string]: string };
|
|
36
|
+
export default classes;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare module '*.mdx' {
|
|
40
|
+
const component: any;
|
|
41
|
+
export default component;
|
|
42
|
+
}
|
package/README.md
DELETED