@weapp-core/constants 0.0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 ice breaker
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # @weapp-core/constants
2
+
3
+ ## 简介
4
+
5
+ `@weapp-core/constants` 提供 `weapp-vite` 生态内部共享的常量定义,重点覆盖可同时被构建期逻辑、小程序运行时代码和测试复用的运行时安全常量。
6
+
7
+ ## 特性
8
+
9
+ - 仅导出字符串常量与类型安全友好的字面量值
10
+ - 可同时被 Node.js 构建流程与小程序运行时代码复用
11
+ - 统一维护 app prelude 与 request globals 相关内部标记
12
+ - 避免不同包之间重复硬编码内部字段名
13
+
14
+ ## 安装
15
+
16
+ ```bash
17
+ pnpm add @weapp-core/constants
18
+ ```
19
+
20
+ ## 使用
21
+
22
+ ```ts
23
+ import {
24
+ APP_PRELUDE_CHUNK_MARKER,
25
+ REQUEST_GLOBAL_ACTUALS_KEY,
26
+ REQUEST_GLOBAL_PRELUDE_MARKER,
27
+ } from '@weapp-core/constants'
28
+
29
+ const preludeMarker = `/* ${APP_PRELUDE_CHUNK_MARKER} */`
30
+ const requestPreludeMarker = `/* ${REQUEST_GLOBAL_PRELUDE_MARKER} */`
31
+ const actualsKey = REQUEST_GLOBAL_ACTUALS_KEY
32
+ ```
33
+
34
+ ## 设计约束
35
+
36
+ - 不引入 `node:*`、文件系统、路径处理或其他 Node.js 专属依赖
37
+ - 不包含副作用与动态执行逻辑
38
+ - 适合作为运行时代码可直接依赖的叶子包
39
+
40
+ ## 相关链接
41
+
42
+ - 仓库:https://github.com/weapp-vite/weapp-vite
@@ -0,0 +1,22 @@
1
+ //#region src/index.d.ts
2
+ declare const APP_PRELUDE_CHUNK_MARKER = "__wvAPR__";
3
+ declare const APP_PRELUDE_GUARD_KEY = "__ai";
4
+ declare const APP_PRELUDE_REQUIRE_MARKER = "__wvAPQ__";
5
+ declare const REQUEST_GLOBAL_PRELUDE_MARKER = "__wvRGP__";
6
+ declare const REQUEST_GLOBAL_PRELUDE_GUARD_KEY = "__ri";
7
+ declare const REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER = "__wvRGL__";
8
+ declare const REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER = "__wvRGC__";
9
+ declare const REQUEST_GLOBAL_BUNDLE_MARKER = "__wvRGB__";
10
+ declare const REQUEST_GLOBAL_ACTUALS_KEY = "__ra";
11
+ declare const REQUEST_GLOBAL_PLACEHOLDER_KEY = "__rp";
12
+ declare const REQUEST_GLOBAL_MARK_PLACEHOLDER_HELPER = "__rM";
13
+ declare const REQUEST_GLOBAL_LAZY_FUNCTION_HELPER = "__rF";
14
+ declare const REQUEST_GLOBAL_LAZY_CONSTRUCTOR_HELPER = "__rC";
15
+ declare const REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER = "__rU";
16
+ declare const REQUEST_GLOBAL_EXPOSE_HELPER = "__rE";
17
+ declare const REQUEST_GLOBAL_INSTALLER_HOST_REF = "__rh";
18
+ declare const REQUEST_GLOBAL_CHUNK_MODULE_REF = "__rm";
19
+ declare const REQUEST_GLOBAL_CHUNK_HOST_REF = "__rc";
20
+ declare const REQUEST_GLOBAL_BUNDLE_HOST_REF = "__rb";
21
+ //#endregion
22
+ export { APP_PRELUDE_CHUNK_MARKER, APP_PRELUDE_GUARD_KEY, APP_PRELUDE_REQUIRE_MARKER, REQUEST_GLOBAL_ACTUALS_KEY, REQUEST_GLOBAL_BUNDLE_HOST_REF, REQUEST_GLOBAL_BUNDLE_MARKER, REQUEST_GLOBAL_CHUNK_HOST_REF, REQUEST_GLOBAL_CHUNK_MODULE_REF, REQUEST_GLOBAL_EXPOSE_HELPER, REQUEST_GLOBAL_INSTALLER_HOST_REF, REQUEST_GLOBAL_LAZY_CONSTRUCTOR_HELPER, REQUEST_GLOBAL_LAZY_FUNCTION_HELPER, REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER, REQUEST_GLOBAL_MARK_PLACEHOLDER_HELPER, REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER, REQUEST_GLOBAL_PLACEHOLDER_KEY, REQUEST_GLOBAL_PRELUDE_GUARD_KEY, REQUEST_GLOBAL_PRELUDE_MARKER, REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER };
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
1
+ //#region src/index.ts
2
+ const APP_PRELUDE_CHUNK_MARKER = "__wvAPR__";
3
+ const APP_PRELUDE_GUARD_KEY = "__ai";
4
+ const APP_PRELUDE_REQUIRE_MARKER = "__wvAPQ__";
5
+ const REQUEST_GLOBAL_PRELUDE_MARKER = "__wvRGP__";
6
+ const REQUEST_GLOBAL_PRELUDE_GUARD_KEY = "__ri";
7
+ const REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER = "__wvRGL__";
8
+ const REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER = "__wvRGC__";
9
+ const REQUEST_GLOBAL_BUNDLE_MARKER = "__wvRGB__";
10
+ const REQUEST_GLOBAL_ACTUALS_KEY = "__ra";
11
+ const REQUEST_GLOBAL_PLACEHOLDER_KEY = "__rp";
12
+ const REQUEST_GLOBAL_MARK_PLACEHOLDER_HELPER = "__rM";
13
+ const REQUEST_GLOBAL_LAZY_FUNCTION_HELPER = "__rF";
14
+ const REQUEST_GLOBAL_LAZY_CONSTRUCTOR_HELPER = "__rC";
15
+ const REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER = "__rU";
16
+ const REQUEST_GLOBAL_EXPOSE_HELPER = "__rE";
17
+ const REQUEST_GLOBAL_INSTALLER_HOST_REF = "__rh";
18
+ const REQUEST_GLOBAL_CHUNK_MODULE_REF = "__rm";
19
+ const REQUEST_GLOBAL_CHUNK_HOST_REF = "__rc";
20
+ const REQUEST_GLOBAL_BUNDLE_HOST_REF = "__rb";
21
+ //#endregion
22
+ export { APP_PRELUDE_CHUNK_MARKER, APP_PRELUDE_GUARD_KEY, APP_PRELUDE_REQUIRE_MARKER, REQUEST_GLOBAL_ACTUALS_KEY, REQUEST_GLOBAL_BUNDLE_HOST_REF, REQUEST_GLOBAL_BUNDLE_MARKER, REQUEST_GLOBAL_CHUNK_HOST_REF, REQUEST_GLOBAL_CHUNK_MODULE_REF, REQUEST_GLOBAL_EXPOSE_HELPER, REQUEST_GLOBAL_INSTALLER_HOST_REF, REQUEST_GLOBAL_LAZY_CONSTRUCTOR_HELPER, REQUEST_GLOBAL_LAZY_FUNCTION_HELPER, REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER, REQUEST_GLOBAL_MARK_PLACEHOLDER_HELPER, REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER, REQUEST_GLOBAL_PLACEHOLDER_KEY, REQUEST_GLOBAL_PRELUDE_GUARD_KEY, REQUEST_GLOBAL_PRELUDE_MARKER, REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER };
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@weapp-core/constants",
3
+ "type": "module",
4
+ "version": "0.0.1",
5
+ "description": "Shared runtime-safe constants for weapp-vite and related packages",
6
+ "author": "ice breaker <1324318532@qq.com>",
7
+ "license": "MIT",
8
+ "homepage": "https://github.com/weapp-vite/weapp-vite",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/weapp-vite/weapp-vite.git",
12
+ "directory": "@weapp-core/constants"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/weapp-vite/weapp-vite/issues"
16
+ },
17
+ "keywords": [
18
+ "weapp-vite",
19
+ "miniprogram",
20
+ "constants",
21
+ "runtime",
22
+ "weapp"
23
+ ],
24
+ "sideEffects": false,
25
+ "weapp-vite-dev": {
26
+ "exports": {
27
+ ".": {
28
+ "types": "./src/index.ts",
29
+ "default": "./src/index.ts"
30
+ }
31
+ },
32
+ "main": "./src/index.ts",
33
+ "module": "./src/index.ts",
34
+ "types": "./src/index.ts"
35
+ },
36
+ "exports": {
37
+ ".": {
38
+ "types": "./dist/index.d.ts",
39
+ "import": "./dist/index.js"
40
+ }
41
+ },
42
+ "main": "./dist/index.js",
43
+ "module": "./dist/index.js",
44
+ "types": "./dist/index.d.ts",
45
+ "files": [
46
+ "dist"
47
+ ],
48
+ "engines": {
49
+ "node": "^20.19.0 || >=22.12.0"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "dependencies": {},
55
+ "devDependencies": {},
56
+ "scripts": {
57
+ "dev": "tsdown -w --sourcemap",
58
+ "build": "tsdown",
59
+ "test": "vitest run",
60
+ "test:dev": "vitest",
61
+ "typecheck": "tsc --noEmit",
62
+ "release": "pnpm publish",
63
+ "lint": "eslint .",
64
+ "lint:fix": "eslint . --fix",
65
+ "sync": "cnpm sync @weapp-core/constants"
66
+ }
67
+ }