@apps-in-toss/web-framework 0.0.0-dev.1740737494440 → 0.0.0-dev.1740740040772

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,169 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
3
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
4
+ }) : x)(function(x) {
5
+ if (typeof require !== "undefined") return require.apply(this, arguments);
6
+ throw Error('Dynamic require of "' + x + '" is not supported');
7
+ });
8
+
9
+ // ../../.yarn/__virtual__/tsup-virtual-7254073ea3/0/cache/tsup-npm-8.3.5-ed25596739-7794953cbc.zip/node_modules/tsup/assets/esm_shims.js
10
+ import { fileURLToPath } from "url";
11
+ import path from "path";
12
+ var getFilename = () => fileURLToPath(import.meta.url);
13
+ var getDirname = () => path.dirname(getFilename());
14
+ var __dirname = /* @__PURE__ */ getDirname();
15
+
16
+ // src/plugins/appsInTossWeb.ts
17
+ import fs2 from "fs";
18
+ import path3 from "path";
19
+ import { appsInToss } from "@apps-in-toss/framework/plugins";
20
+ import { merge } from "es-toolkit";
21
+ import { execa } from "execa";
22
+ import picocolors from "picocolors";
23
+
24
+ // src/utils/getPackageManager.ts
25
+ function getPackageManager({ isExecutor = false } = {}) {
26
+ const userAgent = process.env.npm_config_user_agent;
27
+ const packageManagerCommands = {
28
+ npm: isExecutor ? "npx" : "npm",
29
+ pnpm: "pnpm",
30
+ yarn: "yarn"
31
+ };
32
+ if (!userAgent) {
33
+ return {
34
+ packageManager: packageManagerCommands["npm"],
35
+ version: "0.0.0"
36
+ };
37
+ }
38
+ const [packageManagerInfo] = userAgent.match(/(\w+)\/(\d+\.\d+\.\d+)/) || [];
39
+ const [packageManager, version] = packageManagerInfo?.split("/") ?? ["npm", null];
40
+ if (!packageManager) {
41
+ return {
42
+ packageManager: packageManagerCommands["npm"],
43
+ version: "0.0.0"
44
+ };
45
+ }
46
+ return {
47
+ packageManager: packageManagerCommands[packageManager],
48
+ version: version ?? "0.0.0"
49
+ };
50
+ }
51
+
52
+ // src/utils/getPackageRoot.ts
53
+ import fs from "fs";
54
+ import path2 from "path";
55
+ function getPackageRoot() {
56
+ let cwd = process.cwd();
57
+ const root = path2.parse(cwd).root;
58
+ while (cwd !== root) {
59
+ if (fs.existsSync(path2.join(cwd, "package.json"))) {
60
+ return cwd;
61
+ }
62
+ cwd = path2.dirname(cwd);
63
+ }
64
+ return cwd;
65
+ }
66
+
67
+ // src/plugins/appsInTossWeb.ts
68
+ function appsInTossWebDev(options) {
69
+ const packageRoot = getPackageRoot();
70
+ return {
71
+ name: "apps-in-toss-web:dev",
72
+ dev: {
73
+ order: "post",
74
+ // pre | post
75
+ handler: async ({ host, port }) => {
76
+ console.log(picocolors.green(`Server is running on http://${host}:${port}
77
+ `));
78
+ const { packageManager } = getPackageManager({ isExecutor: true });
79
+ await execa(packageManager, options.commands.dev.split(" "), {
80
+ cwd: packageRoot,
81
+ stdio: "inherit"
82
+ });
83
+ }
84
+ }
85
+ };
86
+ }
87
+ async function updateMetadata(updateData) {
88
+ const packageRoot = getPackageRoot();
89
+ const projectRootTmp = path3.resolve(packageRoot, ".bedrock");
90
+ await fs2.promises.mkdir(projectRootTmp, { recursive: true });
91
+ let metadata = {};
92
+ try {
93
+ const metadataStr = await fs2.promises.readFile(path3.join(projectRootTmp, "metadata.json"), "utf-8");
94
+ metadata = JSON.parse(metadataStr);
95
+ } catch {
96
+ }
97
+ await fs2.promises.writeFile(path3.join(projectRootTmp, "metadata.json"), JSON.stringify(merge(metadata, updateData)));
98
+ }
99
+ function appsInTossBabelConfig(options) {
100
+ return {
101
+ name: "apps-in-toss-web:babel-config",
102
+ dev: {
103
+ order: "pre",
104
+ handler: async ({ appName }) => {
105
+ updateMetadata({ appName, webPort: options.port });
106
+ }
107
+ },
108
+ build: {
109
+ order: "pre",
110
+ handler: async ({ appName }) => {
111
+ updateMetadata({ appName, webPort: options.port });
112
+ }
113
+ },
114
+ config: {
115
+ babel: {
116
+ conditions: [(_code) => _code.includes("Ait")],
117
+ plugins: [
118
+ [
119
+ __require.resolve("@apps-in-toss/babel-plugin-json"),
120
+ { jsonPath: "./.bedrock/metadata.json", identifierName: "Ait" }
121
+ ]
122
+ ]
123
+ }
124
+ }
125
+ };
126
+ }
127
+ function appsInTossWebBuild(options) {
128
+ const packageRoot = getPackageRoot();
129
+ return {
130
+ name: "apps-in-toss-web:build",
131
+ build: {
132
+ order: "pre",
133
+ handler: async ({ outdir }) => {
134
+ const { packageManager } = getPackageManager({ isExecutor: true });
135
+ const webDistDir = path3.join(outdir, "web");
136
+ await fs2.promises.rm(outdir, { recursive: true, force: true });
137
+ await execa(packageManager, options.commands.build.split(" "), {
138
+ cwd: packageRoot,
139
+ stdio: "inherit"
140
+ });
141
+ await fs2.promises.mkdir(webDistDir, { recursive: true });
142
+ const items = await fs2.promises.readdir(outdir);
143
+ for (const item of items) {
144
+ const src = path3.join(outdir, item);
145
+ const dest = path3.join(webDistDir, item);
146
+ if (src === webDistDir) {
147
+ continue;
148
+ }
149
+ await fs2.promises.rename(src, dest);
150
+ }
151
+ }
152
+ }
153
+ };
154
+ }
155
+ function appsInTossWeb(options) {
156
+ return [
157
+ appsInToss({
158
+ permissions: options.permissions
159
+ }),
160
+ appsInTossBabelConfig(options),
161
+ appsInTossWebBuild(options),
162
+ appsInTossWebDev(options)
163
+ ];
164
+ }
165
+
166
+ export {
167
+ __dirname,
168
+ appsInTossWeb
169
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@apps-in-toss/web-framework",
3
3
  "type": "module",
4
- "version": "0.0.0-dev.1740737494440",
4
+ "version": "0.0.0-dev.1740740040772",
5
5
  "description": "Web Framework for Apps In Toss",
6
6
  "scripts": {
7
7
  "prepack": "yarn build",
@@ -36,7 +36,7 @@
36
36
  "react-native"
37
37
  ],
38
38
  "devDependencies": {
39
- "@react-native-bedrock/bridgepack": "^0.0.0-dev.1740737494440",
39
+ "@react-native-bedrock/bridgepack": "^0.0.0-dev.1740740040772",
40
40
  "@types/babel__core": "^7.20.5",
41
41
  "@types/debug": "^4",
42
42
  "@types/node": "^22.10.2",
@@ -48,9 +48,9 @@
48
48
  "vitest": "^3.0.5"
49
49
  },
50
50
  "dependencies": {
51
- "@apps-in-toss/babel-plugin-json": "0.0.0-dev.1740737494440",
52
- "@apps-in-toss/cli": "0.0.0-dev.1740737494440",
53
- "@apps-in-toss/framework": "0.0.0-dev.1740737494440",
51
+ "@apps-in-toss/babel-plugin-json": "0.0.0-dev.1740740040772",
52
+ "@apps-in-toss/cli": "0.0.0-dev.1740740040772",
53
+ "@apps-in-toss/framework": "0.0.0-dev.1740740040772",
54
54
  "@babel/core": "7.23.9",
55
55
  "@babel/plugin-proposal-class-properties": "^7.16.7",
56
56
  "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7",
@@ -63,18 +63,18 @@
63
63
  "@babel/preset-react": "^7.16.7",
64
64
  "@babel/preset-typescript": "^7.16.7",
65
65
  "@babel/runtime": "7.18.9",
66
- "@react-native-bedrock/mpack-next": "0.0.0-dev.1740737217262",
67
- "@react-native-bedrock/native": "0.0.0-dev.1740737217262",
66
+ "@react-native-bedrock/mpack-next": "0.0.0-dev.1740739857744",
67
+ "@react-native-bedrock/native": "0.0.0-dev.1740739857744",
68
68
  "@types/react": "18.3.3",
69
69
  "es-toolkit": "^1.32.0",
70
70
  "picocolors": "^1.1.1",
71
71
  "react": "18.2.0",
72
72
  "react-native": "0.72.6",
73
- "react-native-bedrock": "0.0.0-dev.1740737217262",
73
+ "react-native-bedrock": "0.0.0-dev.1740739857744",
74
74
  "zod": "^3.24.1"
75
75
  },
76
76
  "publishConfig": {
77
77
  "access": "public"
78
78
  },
79
- "gitHead": "347b3082077a706fb9665295e27316e64573e93c"
79
+ "gitHead": "bf62e2a7b092e720e9e14a9e3ef80891bf0cf2bc"
80
80
  }
@@ -1,53 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
3
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
4
- }) : x)(function(x) {
5
- if (typeof require !== "undefined") return require.apply(this, arguments);
6
- throw Error('Dynamic require of "' + x + '" is not supported');
7
- });
8
-
9
- // ../../.yarn/__virtual__/tsup-virtual-dfda26f750/0/cache/tsup-npm-8.3.5-ed25596739-7794953cbc.zip/node_modules/tsup/assets/esm_shims.js
10
- import { fileURLToPath } from "url";
11
- import path from "path";
12
- var getFilename = () => fileURLToPath(import.meta.url);
13
- var getDirname = () => path.dirname(getFilename());
14
- var __dirname = /* @__PURE__ */ getDirname();
15
-
16
- // src/config/defineConfig.ts
17
- import { z } from "zod";
18
- var AppsInTossConfigSchema = z.object({
19
- appName: z.string(),
20
- web: z.object({
21
- port: z.number(),
22
- commands: z.object({
23
- dev: z.string(),
24
- build: z.string()
25
- })
26
- })
27
- });
28
- var defineConfig = (config) => {
29
- return AppsInTossConfigSchema.parse(config);
30
- };
31
-
32
- // src/config/loadConfig.ts
33
- import { cosmiconfig } from "cosmiconfig";
34
- import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
35
- var loadConfig = async () => {
36
- const explorer = cosmiconfig("apps-in-toss", {
37
- searchPlaces: ["apps-in-toss.config.web.ts", "apps-in-toss.config.web.mts"],
38
- loaders: {
39
- ".ts": TypeScriptLoader(),
40
- ".mts": TypeScriptLoader()
41
- }
42
- });
43
- const result = await explorer.search(process.cwd());
44
- const config = defineConfig(result?.config ?? {});
45
- return config;
46
- };
47
-
48
- export {
49
- __require,
50
- __dirname,
51
- defineConfig,
52
- loadConfig
53
- };
@@ -1,53 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
3
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
4
- }) : x)(function(x) {
5
- if (typeof require !== "undefined") return require.apply(this, arguments);
6
- throw Error('Dynamic require of "' + x + '" is not supported');
7
- });
8
-
9
- // ../../.yarn/__virtual__/tsup-virtual-dfda26f750/0/cache/tsup-npm-8.3.5-ed25596739-7794953cbc.zip/node_modules/tsup/assets/esm_shims.js
10
- import { fileURLToPath } from "url";
11
- import path from "path";
12
- var getFilename = () => fileURLToPath(import.meta.url);
13
- var getDirname = () => path.dirname(getFilename());
14
- var __dirname = /* @__PURE__ */ getDirname();
15
-
16
- // src/defineConfig.ts
17
- import { z } from "zod";
18
- var AppsInTossConfigSchema = z.object({
19
- appName: z.string(),
20
- web: z.object({
21
- port: z.number(),
22
- commands: z.object({
23
- dev: z.string(),
24
- build: z.string()
25
- })
26
- })
27
- });
28
- var defineConfig = (config) => {
29
- return AppsInTossConfigSchema.parse(config);
30
- };
31
-
32
- // src/loadConfig.ts
33
- import { cosmiconfig } from "cosmiconfig";
34
- import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
35
- var loadConfig = async () => {
36
- const explorer = cosmiconfig("apps-in-toss", {
37
- searchPlaces: ["apps-in-toss.config.web.ts", "apps-in-toss.config.web.mts"],
38
- loaders: {
39
- ".ts": TypeScriptLoader(),
40
- ".mts": TypeScriptLoader()
41
- }
42
- });
43
- const result = await explorer.search(process.cwd());
44
- const config = defineConfig(result?.config ?? {});
45
- return config;
46
- };
47
-
48
- export {
49
- __require,
50
- __dirname,
51
- defineConfig,
52
- loadConfig
53
- };
@@ -1,19 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
3
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
4
- }) : x)(function(x) {
5
- if (typeof require !== "undefined") return require.apply(this, arguments);
6
- throw Error('Dynamic require of "' + x + '" is not supported');
7
- });
8
-
9
- // ../../.yarn/__virtual__/tsup-virtual-dfda26f750/0/cache/tsup-npm-8.3.5-ed25596739-7794953cbc.zip/node_modules/tsup/assets/esm_shims.js
10
- import { fileURLToPath } from "url";
11
- import path from "path";
12
- var getFilename = () => fileURLToPath(import.meta.url);
13
- var getDirname = () => path.dirname(getFilename());
14
- var __dirname = /* @__PURE__ */ getDirname();
15
-
16
- export {
17
- __require,
18
- __dirname
19
- };
@@ -1,38 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
-
3
- // src/config/defineConfig.ts
4
- import { z } from "zod";
5
- var AppsInTossConfigSchema = z.object({
6
- appName: z.string(),
7
- web: z.object({
8
- port: z.number(),
9
- commands: z.object({
10
- dev: z.string(),
11
- build: z.string()
12
- })
13
- })
14
- });
15
- var defineConfig = (config) => {
16
- return AppsInTossConfigSchema.parse(config);
17
- };
18
-
19
- // src/config/loadConfig.ts
20
- import { cosmiconfig } from "cosmiconfig";
21
- import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
22
- var loadConfig = async () => {
23
- const explorer = cosmiconfig("apps-in-toss", {
24
- searchPlaces: ["apps-in-toss.config.web.ts", "apps-in-toss.config.web.mts"],
25
- loaders: {
26
- ".ts": TypeScriptLoader(),
27
- ".mts": TypeScriptLoader()
28
- }
29
- });
30
- const result = await explorer.search(process.cwd());
31
- const config = defineConfig(result?.config ?? {});
32
- return config;
33
- };
34
-
35
- export {
36
- defineConfig,
37
- loadConfig
38
- };