@shuvi/shared 0.0.1-rc.7 → 1.0.0-rc.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.
@@ -0,0 +1,26 @@
1
+ export declare const NAME = "shuvi";
2
+ export declare const DEV_ONLY_ASSETS_PREFIX: string;
3
+ export declare const ROUTE_RESOURCE_QUERYSTRING = "shuvi-route";
4
+ export declare const PUBLIC_ENV_PREFIX = "SHUVI_PUBLIC_";
5
+ export declare const CLIENT_CONTAINER_ID = "__APP";
6
+ export declare const CLIENT_APPDATA_ID = "__APP_DATA";
7
+ export declare const DEV_STYLE_ANCHOR_ID = "__shuvi_style_anchor";
8
+ export declare const DEV_STYLE_HIDE_FOUC = "data-shuvi-hide-fouc";
9
+ export declare const DEV_STYLE_PREPARE = "__shuvi_style_prepare";
10
+ export declare const DEV_HOT_MIDDLEWARE_PATH: string;
11
+ export declare const DEV_HOT_LAUNCH_EDITOR_ENDPOINT: string;
12
+ export declare const IDENTITY_RUNTIME_PUBLICPATH: string;
13
+ export declare const ROUTE_NOT_FOUND_NAME = "404";
14
+ export declare const SHUVI_ERROR: {
15
+ APP_ERROR: {
16
+ code: number;
17
+ message: string;
18
+ };
19
+ PAGE_NOT_FOUND: {
20
+ code: number;
21
+ message: string;
22
+ };
23
+ };
24
+ export declare const BUNDLER_DEFAULT_TARGET: string;
25
+ export declare const BUNDLER_TARGET_CLIENT: string;
26
+ export declare const BUNDLER_TARGET_SERVER: string;
@@ -0,0 +1,32 @@
1
+ // common
2
+ export const NAME = 'shuvi';
3
+ export const DEV_ONLY_ASSETS_PREFIX = `/_${NAME}`;
4
+ export const ROUTE_RESOURCE_QUERYSTRING = `shuvi-route`;
5
+ export const PUBLIC_ENV_PREFIX = 'SHUVI_PUBLIC_';
6
+ // app
7
+ export const CLIENT_CONTAINER_ID = '__APP';
8
+ export const CLIENT_APPDATA_ID = '__APP_DATA';
9
+ export const DEV_STYLE_ANCHOR_ID = '__shuvi_style_anchor';
10
+ export const DEV_STYLE_HIDE_FOUC = 'data-shuvi-hide-fouc';
11
+ export const DEV_STYLE_PREPARE = '__shuvi_style_prepare';
12
+ export const DEV_HOT_MIDDLEWARE_PATH = `${DEV_ONLY_ASSETS_PREFIX}/webpack-hmr`;
13
+ export const DEV_HOT_LAUNCH_EDITOR_ENDPOINT = `${DEV_ONLY_ASSETS_PREFIX}/development/open-stack-frame-in-editor`;
14
+ export const IDENTITY_RUNTIME_PUBLICPATH = `__${NAME}_dynamic_public_path__`;
15
+ export const ROUTE_NOT_FOUND_NAME = `404`;
16
+ export const SHUVI_ERROR = {
17
+ APP_ERROR: {
18
+ code: 500,
19
+ message: 'Internal Application Error.'
20
+ },
21
+ PAGE_NOT_FOUND: {
22
+ code: 404,
23
+ message: 'This page could not be found.'
24
+ }
25
+ };
26
+ // bundle
27
+ export const BUNDLER_DEFAULT_TARGET = `${NAME}/client`;
28
+ // service has BUNDLER_DEFAULT_TARGET and
29
+ // shuvi inner has used BUNDLER_DEFAULT_TARGET replaced BUNDLER_DEFAULT_TARGET,
30
+ // keep BUNDLER_TARGET_CLIENT for old users plugins, will be remove in future
31
+ export const BUNDLER_TARGET_CLIENT = BUNDLER_DEFAULT_TARGET;
32
+ export const BUNDLER_TARGET_SERVER = `${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(): Store;
9
+ }
@@ -0,0 +1,26 @@
1
+ const hasOwnProperty = Object.prototype.hasOwnProperty;
2
+ const isServer = typeof window === 'undefined';
3
+ // set on server, get from client
4
+ export class Telestore {
5
+ constructor(store) {
6
+ this._store = store;
7
+ }
8
+ get(key, defaultValue) {
9
+ if (isServer) {
10
+ return defaultValue;
11
+ }
12
+ if (!hasOwnProperty.call(this._store, key)) {
13
+ return defaultValue;
14
+ }
15
+ return this._store[key];
16
+ }
17
+ set(key, value) {
18
+ if (!isServer) {
19
+ return;
20
+ }
21
+ this._store[key] = value;
22
+ }
23
+ dump() {
24
+ return this._store;
25
+ }
26
+ }
@@ -1,6 +1,5 @@
1
1
  export declare const NAME = "shuvi";
2
- export declare const CONFIG_FILE = "shuvi.config.js";
3
- export declare const PATH_PREFIX: string;
2
+ export declare const DEV_ONLY_ASSETS_PREFIX: string;
4
3
  export declare const ROUTE_RESOURCE_QUERYSTRING = "shuvi-route";
5
4
  export declare const PUBLIC_ENV_PREFIX = "SHUVI_PUBLIC_";
6
5
  export declare const CLIENT_CONTAINER_ID = "__APP";
@@ -11,6 +10,17 @@ export declare const DEV_STYLE_PREPARE = "__shuvi_style_prepare";
11
10
  export declare const DEV_HOT_MIDDLEWARE_PATH: string;
12
11
  export declare const DEV_HOT_LAUNCH_EDITOR_ENDPOINT: string;
13
12
  export declare const IDENTITY_RUNTIME_PUBLICPATH: string;
14
- export declare const IDENTITY_SSR_RUNTIME_PUBLICPATH: string;
15
13
  export declare const ROUTE_NOT_FOUND_NAME = "404";
16
- export declare const BUILD_SERVER_FILE_SERVER = "server";
14
+ export declare const SHUVI_ERROR: {
15
+ APP_ERROR: {
16
+ code: number;
17
+ message: string;
18
+ };
19
+ PAGE_NOT_FOUND: {
20
+ code: number;
21
+ message: string;
22
+ };
23
+ };
24
+ export declare const BUNDLER_DEFAULT_TARGET: string;
25
+ export declare const BUNDLER_TARGET_CLIENT: string;
26
+ export declare const BUNDLER_TARGET_SERVER: string;
package/lib/constants.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BUNDLER_TARGET_SERVER = exports.BUNDLER_TARGET_CLIENT = exports.BUNDLER_DEFAULT_TARGET = exports.SHUVI_ERROR = exports.ROUTE_NOT_FOUND_NAME = exports.IDENTITY_RUNTIME_PUBLICPATH = exports.DEV_HOT_LAUNCH_EDITOR_ENDPOINT = exports.DEV_HOT_MIDDLEWARE_PATH = exports.DEV_STYLE_PREPARE = exports.DEV_STYLE_HIDE_FOUC = exports.DEV_STYLE_ANCHOR_ID = exports.CLIENT_APPDATA_ID = exports.CLIENT_CONTAINER_ID = exports.PUBLIC_ENV_PREFIX = exports.ROUTE_RESOURCE_QUERYSTRING = exports.DEV_ONLY_ASSETS_PREFIX = exports.NAME = void 0;
3
4
  // common
4
5
  exports.NAME = 'shuvi';
5
- exports.CONFIG_FILE = 'shuvi.config.js';
6
- exports.PATH_PREFIX = `/_${exports.NAME}`;
6
+ exports.DEV_ONLY_ASSETS_PREFIX = `/_${exports.NAME}`;
7
7
  exports.ROUTE_RESOURCE_QUERYSTRING = `shuvi-route`;
8
8
  exports.PUBLIC_ENV_PREFIX = 'SHUVI_PUBLIC_';
9
9
  // app
@@ -12,10 +12,24 @@ exports.CLIENT_APPDATA_ID = '__APP_DATA';
12
12
  exports.DEV_STYLE_ANCHOR_ID = '__shuvi_style_anchor';
13
13
  exports.DEV_STYLE_HIDE_FOUC = 'data-shuvi-hide-fouc';
14
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__`;
15
+ exports.DEV_HOT_MIDDLEWARE_PATH = `${exports.DEV_ONLY_ASSETS_PREFIX}/webpack-hmr`;
16
+ exports.DEV_HOT_LAUNCH_EDITOR_ENDPOINT = `${exports.DEV_ONLY_ASSETS_PREFIX}/development/open-stack-frame-in-editor`;
17
+ exports.IDENTITY_RUNTIME_PUBLICPATH = `__${exports.NAME}_dynamic_public_path__`;
19
18
  exports.ROUTE_NOT_FOUND_NAME = `404`;
19
+ exports.SHUVI_ERROR = {
20
+ APP_ERROR: {
21
+ code: 500,
22
+ message: 'Internal Application Error.'
23
+ },
24
+ PAGE_NOT_FOUND: {
25
+ code: 404,
26
+ message: 'This page could not be found.'
27
+ }
28
+ };
20
29
  // bundle
21
- exports.BUILD_SERVER_FILE_SERVER = `server`;
30
+ exports.BUNDLER_DEFAULT_TARGET = `${exports.NAME}/client`;
31
+ // service has BUNDLER_DEFAULT_TARGET and
32
+ // shuvi inner has used BUNDLER_DEFAULT_TARGET replaced BUNDLER_DEFAULT_TARGET,
33
+ // keep BUNDLER_TARGET_CLIENT for old users plugins, will be remove in future
34
+ exports.BUNDLER_TARGET_CLIENT = exports.BUNDLER_DEFAULT_TARGET;
35
+ exports.BUNDLER_TARGET_SERVER = `${exports.NAME}/server`;
@@ -5,5 +5,5 @@ export declare class Telestore {
5
5
  constructor(store: Store);
6
6
  get<T = unknown>(key: string, defaultValue?: T): T | undefined;
7
7
  set(key: string, value: any): void;
8
- dump(): Record<string, any>;
8
+ dump(): Store;
9
9
  }
package/lib/telestore.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Telestore = void 0;
3
4
  const hasOwnProperty = Object.prototype.hasOwnProperty;
4
5
  const isServer = typeof window === 'undefined';
5
6
  // set on server, get from client
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shuvi/shared",
3
- "version": "0.0.1-rc.7",
3
+ "version": "1.0.0-rc.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/shuvijs/shuvi.git",
@@ -9,16 +9,20 @@
9
9
  "author": "liximomo",
10
10
  "license": "MIT",
11
11
  "files": [
12
- "lib"
12
+ "lib",
13
+ "esm"
13
14
  ],
14
15
  "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
16
  "engines": {
21
17
  "node": ">= 12.0.0"
22
18
  },
23
- "gitHead": "ce745f5e6b4b588865aecd4a5839dfde83dfba79"
24
- }
19
+ "scripts": {
20
+ "dev": "run-p watch:*",
21
+ "watch:esm": "tsc -p tsconfig.build.json -m esnext --outDir esm -w",
22
+ "watch:cjs": "tsc -p tsconfig.build.json -m commonjs --outDir lib -w",
23
+ "prebuild": "rimraf lib esm",
24
+ "build": "run-p build:*",
25
+ "build:esm": "tsc -p tsconfig.build.json -m esnext --outDir esm",
26
+ "build:cjs": "tsc -p tsconfig.build.json -m commonjs --outDir lib"
27
+ }
28
+ }