@shuvi/shared 0.0.1-pre.1

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.
@@ -0,0 +1,17 @@
1
+ export declare const NAME = "shuvi";
2
+ export declare const CONFIG_FILE = "shuvi.config.js";
3
+ export declare const PATH_PREFIX: string;
4
+ export declare const ROUTE_RESOURCE_QUERYSTRING = "shuvi-route";
5
+ export declare const PUBLIC_ENV_PREFIX = "SHUVI_PUBLIC_";
6
+ export declare const CLIENT_CONTAINER_ID = "__APP";
7
+ export declare const CLIENT_APPDATA_ID = "__APP_DATA";
8
+ export declare const DEV_STYLE_ANCHOR_ID = "__shuvi_style_anchor";
9
+ export declare const DEV_STYLE_HIDE_FOUC = "data-shuvi-hide-fouc";
10
+ export declare const DEV_STYLE_PREPARE = "__shuvi_style_prepare";
11
+ export declare const DEV_HOT_MIDDLEWARE_PATH: string;
12
+ export declare const DEV_HOT_LAUNCH_EDITOR_ENDPOINT: string;
13
+ export declare const IDENTITY_RUNTIME_PUBLICPATH: string;
14
+ export declare const IDENTITY_SSR_RUNTIME_PUBLICPATH: string;
15
+ export declare const ROUTE_NOT_FOUND_NAME = "404";
16
+ export declare const BUNDLER_TARGET_CLIENT: string;
17
+ export declare const BUNDLER_TARGET_SERVER: string;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // common
4
+ exports.NAME = 'shuvi';
5
+ exports.CONFIG_FILE = 'shuvi.config.js';
6
+ exports.PATH_PREFIX = `/_${exports.NAME}`;
7
+ exports.ROUTE_RESOURCE_QUERYSTRING = `shuvi-route`;
8
+ exports.PUBLIC_ENV_PREFIX = 'SHUVI_PUBLIC_';
9
+ // app
10
+ exports.CLIENT_CONTAINER_ID = '__APP';
11
+ exports.CLIENT_APPDATA_ID = '__APP_DATA';
12
+ exports.DEV_STYLE_ANCHOR_ID = '__shuvi_style_anchor';
13
+ exports.DEV_STYLE_HIDE_FOUC = 'data-shuvi-hide-fouc';
14
+ exports.DEV_STYLE_PREPARE = '__shuvi_style_prepare';
15
+ exports.DEV_HOT_MIDDLEWARE_PATH = `${exports.PATH_PREFIX}/webpack-hmr`;
16
+ exports.DEV_HOT_LAUNCH_EDITOR_ENDPOINT = `${exports.PATH_PREFIX}/development/open-stack-frame-in-editor`;
17
+ exports.IDENTITY_RUNTIME_PUBLICPATH = `__${exports.NAME}_public_path__`;
18
+ exports.IDENTITY_SSR_RUNTIME_PUBLICPATH = `__${exports.NAME}_ssr_public_path__`;
19
+ exports.ROUTE_NOT_FOUND_NAME = `404`;
20
+ // bundle
21
+ exports.BUNDLER_TARGET_CLIENT = `${exports.NAME}/client`;
22
+ exports.BUNDLER_TARGET_SERVER = `${exports.NAME}/server`;
@@ -0,0 +1,9 @@
1
+ /// <reference lib="dom" />
2
+ export declare type Store = Record<string, any>;
3
+ export declare class Telestore {
4
+ private _store;
5
+ constructor(store: Store);
6
+ get<T = unknown>(key: string, defaultValue?: T): T | undefined;
7
+ set(key: string, value: any): void;
8
+ dump(): Record<string, any>;
9
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const hasOwnProperty = Object.prototype.hasOwnProperty;
4
+ const isServer = typeof window === 'undefined';
5
+ // set on server, get from client
6
+ class Telestore {
7
+ constructor(store) {
8
+ this._store = store;
9
+ }
10
+ get(key, defaultValue) {
11
+ if (isServer) {
12
+ return defaultValue;
13
+ }
14
+ if (!hasOwnProperty.call(this._store, key)) {
15
+ return defaultValue;
16
+ }
17
+ return this._store[key];
18
+ }
19
+ set(key, value) {
20
+ if (!isServer) {
21
+ return;
22
+ }
23
+ this._store[key] = value;
24
+ }
25
+ dump() {
26
+ return this._store;
27
+ }
28
+ }
29
+ exports.Telestore = Telestore;
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@shuvi/shared",
3
+ "version": "0.0.1-pre.1",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git+https://github.com/shuvijs/shuvi.git",
7
+ "directory": "packages/shared"
8
+ },
9
+ "author": "liximomo",
10
+ "license": "MIT",
11
+ "files": [
12
+ "lib"
13
+ ],
14
+ "sideEffects": false,
15
+ "scripts": {
16
+ "dev": "tsc -p tsconfig.build.json -w",
17
+ "prebuild": "rimraf lib",
18
+ "build": "tsc -p tsconfig.build.json"
19
+ },
20
+ "engines": {
21
+ "node": ">= 12.0.0"
22
+ },
23
+ "gitHead": "0bc0bc76e72ca5a339341e8b71d6bb6bb41409e8"
24
+ }