one 2.22.0 → 2.23.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.
Files changed (109) hide show
  1. package/dist/cjs/fork/getPathFromState.cjs +2 -1
  2. package/dist/cjs/fork/getPathFromState.native.cjs +4 -1
  3. package/dist/cjs/fork/getPathFromState.native.js +4 -1
  4. package/dist/cjs/fork/getPathFromState.native.js.map +1 -1
  5. package/dist/cjs/platform/streams.cjs +17 -0
  6. package/dist/cjs/platform/streams.native.cjs +19 -0
  7. package/dist/cjs/platform/streams.native.js +21 -0
  8. package/dist/cjs/platform/streams.native.js.map +1 -0
  9. package/dist/cjs/routeTypes.cjs +17 -0
  10. package/dist/cjs/routeTypes.native.cjs +19 -0
  11. package/dist/cjs/routeTypes.native.js +21 -0
  12. package/dist/cjs/routeTypes.native.js.map +1 -0
  13. package/dist/cjs/router/router.cjs +1 -1
  14. package/dist/cjs/router/router.native.cjs +1 -1
  15. package/dist/cjs/router/router.native.js +1 -1
  16. package/dist/cjs/router/router.native.js.map +1 -1
  17. package/dist/cjs/vite/plugins/iosLinkSetPlugin.cjs +22 -6
  18. package/dist/cjs/vite/plugins/iosLinkSetPlugin.native.cjs +100 -25
  19. package/dist/cjs/vite/plugins/iosLinkSetPlugin.native.js +100 -25
  20. package/dist/cjs/vite/plugins/iosLinkSetPlugin.native.js.map +1 -1
  21. package/dist/cjs/vite/plugins/oneNativeMembers.cjs +288 -57
  22. package/dist/cjs/vite/plugins/oneNativeMembers.native.cjs +537 -169
  23. package/dist/cjs/vite/plugins/oneNativeMembers.native.js +537 -169
  24. package/dist/cjs/vite/plugins/oneNativeMembers.native.js.map +1 -1
  25. package/dist/esm/fork/getPathFromState.mjs +2 -1
  26. package/dist/esm/fork/getPathFromState.mjs.map +1 -1
  27. package/dist/esm/fork/getPathFromState.native.js +4 -1
  28. package/dist/esm/fork/getPathFromState.native.js.map +1 -1
  29. package/dist/esm/platform/streams.mjs +0 -0
  30. package/dist/esm/platform/streams.native.js +0 -0
  31. package/dist/esm/routeTypes.mjs +0 -0
  32. package/dist/esm/routeTypes.native.js +0 -0
  33. package/dist/esm/router/router.mjs +2 -2
  34. package/dist/esm/router/router.mjs.map +1 -1
  35. package/dist/esm/router/router.native.js +2 -2
  36. package/dist/esm/router/router.native.js.map +1 -1
  37. package/dist/esm/vite/plugins/iosLinkSetPlugin.mjs +22 -6
  38. package/dist/esm/vite/plugins/iosLinkSetPlugin.mjs.map +1 -1
  39. package/dist/esm/vite/plugins/iosLinkSetPlugin.native.js +100 -25
  40. package/dist/esm/vite/plugins/iosLinkSetPlugin.native.js.map +1 -1
  41. package/dist/esm/vite/plugins/oneNativeMembers.mjs +289 -58
  42. package/dist/esm/vite/plugins/oneNativeMembers.mjs.map +1 -1
  43. package/dist/esm/vite/plugins/oneNativeMembers.native.js +538 -170
  44. package/dist/esm/vite/plugins/oneNativeMembers.native.js.map +1 -1
  45. package/ios/OneNativeSlot.swift +17 -0
  46. package/package.json +13 -13
  47. package/src/Root.tsx +1 -1
  48. package/src/constants.ts +1 -1
  49. package/src/createApp.native.tsx +1 -1
  50. package/src/createApp.tsx +3 -2
  51. package/src/fork/getPathFromState.test.ts +20 -0
  52. package/src/fork/getPathFromState.ts +8 -2
  53. package/src/headless.tsx +1 -1
  54. package/src/interfaces/router.ts +3 -27
  55. package/src/platform/file-system/classes.native.ts +6 -5
  56. package/src/platform/file-system/classes.ts +6 -5
  57. package/src/platform/streams.ts +14 -0
  58. package/src/routeTypes.ts +83 -0
  59. package/src/router/FlagsContext.ts +1 -1
  60. package/src/router/Route.tsx +1 -1
  61. package/src/router/getRoutes.ts +1 -1
  62. package/src/router/linkToColdRoute.test.ts +61 -1
  63. package/src/router/matchers.ts +1 -1
  64. package/src/router/router.ts +3 -8
  65. package/src/router/useInitializeOneRouter.ts +1 -1
  66. package/src/router/useViteRoutes.tsx +1 -1
  67. package/src/router/warmState.ts +1 -1
  68. package/src/types.ts +1 -1
  69. package/src/useMatches.ts +1 -1
  70. package/src/vite/one-server-only.tsx +5 -2
  71. package/src/vite/plugins/iosLinkSetPlugin.ts +39 -6
  72. package/src/vite/plugins/oneNativeMembers.ts +417 -82
  73. package/src/vite/types.ts +12 -51
  74. package/types/Root.d.ts +1 -1
  75. package/types/config.d.ts +1 -2
  76. package/types/config.d.ts.map +1 -1
  77. package/types/constants.d.ts +1 -1
  78. package/types/createApp.d.ts +3 -2
  79. package/types/createApp.d.ts.map +1 -1
  80. package/types/daemon/server.d.ts +1 -1
  81. package/types/fork/getPathFromState.d.ts.map +1 -1
  82. package/types/headless.d.ts +1 -1
  83. package/types/interfaces/router.d.ts +3 -19
  84. package/types/interfaces/router.d.ts.map +1 -1
  85. package/types/platform/file-system/classes.d.ts +4 -3
  86. package/types/platform/file-system/classes.d.ts.map +1 -1
  87. package/types/platform/file-system/classes.native.d.ts +4 -3
  88. package/types/platform/file-system/classes.native.d.ts.map +1 -1
  89. package/types/platform/streams.d.ts +12 -0
  90. package/types/platform/streams.d.ts.map +1 -0
  91. package/types/routeTypes.d.ts +66 -0
  92. package/types/routeTypes.d.ts.map +1 -0
  93. package/types/router/FlagsContext.d.ts +1 -1
  94. package/types/router/Route.d.ts +1 -1
  95. package/types/router/getRoutes.d.ts +1 -1
  96. package/types/router/matchers.d.ts +1 -1
  97. package/types/router/router.d.ts +1 -1
  98. package/types/router/router.d.ts.map +1 -1
  99. package/types/router/useInitializeOneRouter.d.ts +1 -1
  100. package/types/router/useViteRoutes.d.ts +1 -1
  101. package/types/router/warmState.d.ts +1 -1
  102. package/types/types.d.ts +1 -1
  103. package/types/useMatches.d.ts +1 -1
  104. package/types/vite/one-server-only.d.ts +5 -3
  105. package/types/vite/one-server-only.d.ts.map +1 -1
  106. package/types/vite/plugins/oneNativeMembers.d.ts +1 -1
  107. package/types/vite/plugins/oneNativeMembers.d.ts.map +1 -1
  108. package/types/vite/types.d.ts +12 -49
  109. package/types/vite/types.d.ts.map +1 -1
@@ -1,45 +1,171 @@
1
- import { readFileSync } from "node:fs";
1
+ import { readFileSync, statSync } from "node:fs";
2
2
  import { dirname, resolve } from "node:path";
3
3
  import MagicString from "magic-string";
4
4
  import { parseSync } from "oxc-parser";
5
5
 
6
6
  // dist/esm/vite/plugins/oneNativeMembers.js
7
- function nativeOneMembers(file) {
8
- const imports = /* @__PURE__ */ new Map();
9
- const values = /* @__PURE__ */ new Map();
10
- const program = parseSync(file, readFileSync(file, "utf8")).program;
11
- for (const statement of program.body) {
12
- const node = statement.type === "ExportNamedDeclaration" ? statement.declaration : statement;
13
- if (node?.type === "ImportDeclaration") {
14
- for (const item of node.specifiers) {
15
- imports.set(item.local.name, {
16
- source: node.source.value.startsWith(".") ? resolve(dirname(file), node.source.value) : node.source.value,
17
- imported: item.type === "ImportSpecifier" ? String(item.imported.name ?? item.imported.value) : item.type === "ImportDefaultSpecifier" ? "default" : "*"
7
+ function nativeOneMembers(file, platform = "ios") {
8
+ const modules = /* @__PURE__ */ new Map();
9
+ const load = (path) => {
10
+ if (modules.has(path)) return modules.get(path);
11
+ let code;
12
+ try {
13
+ code = readFileSync(path, "utf8");
14
+ } catch {
15
+ modules.set(path, void 0);
16
+ return;
17
+ }
18
+ const module = {
19
+ path,
20
+ imports: /* @__PURE__ */ new Map(),
21
+ values: /* @__PURE__ */ new Map(),
22
+ exports: /* @__PURE__ */ new Map(),
23
+ reexports: /* @__PURE__ */ new Map(),
24
+ stars: []
25
+ };
26
+ modules.set(path, module);
27
+ const from = (specifier) => {
28
+ if (!specifier.startsWith(".")) return specifier;
29
+ const base = resolve(dirname(path), specifier);
30
+ return [
31
+ "",
32
+ `.${platform}.js`,
33
+ ".native.js",
34
+ ".js",
35
+ `/index.${platform}.js`,
36
+ "/index.native.js",
37
+ "/index.js"
38
+ ].map((suffix) => base + suffix).find((candidate) => statSync(candidate, { throwIfNoEntry: false })?.isFile()) ?? base;
39
+ };
40
+ const name = (node) => String(node.name ?? node.value);
41
+ for (const statement of parseSync(path, code).program.body) {
42
+ if (statement.type === "ExportAllDeclaration") {
43
+ if (statement.exported) module.reexports.set(name(statement.exported), {
44
+ source: from(statement.source.value),
45
+ imported: "*"
18
46
  });
47
+ else module.stars.push(from(statement.source.value));
48
+ continue;
19
49
  }
20
- } else if (node?.type === "VariableDeclaration") {
21
- for (const declaration of node.declarations) if (declaration.id.type === "Identifier" && declaration.init) values.set(declaration.id.name, declaration.init);
50
+ if (statement.type === "ExportNamedDeclaration") {
51
+ for (const item of statement.specifiers ?? []) {
52
+ if (statement.source) module.reexports.set(name(item.exported), {
53
+ source: from(statement.source.value),
54
+ imported: name(item.local)
55
+ });
56
+ else module.exports.set(name(item.exported), name(item.local));
57
+ }
58
+ }
59
+ const node = statement.type === "ExportNamedDeclaration" ? statement.declaration : statement;
60
+ if (node?.type === "ImportDeclaration") {
61
+ for (const item of node.specifiers) {
62
+ module.imports.set(item.local.name, {
63
+ source: from(node.source.value),
64
+ imported: item.type === "ImportSpecifier" ? name(item.imported) : item.type === "ImportDefaultSpecifier" ? "default" : "*"
65
+ });
66
+ }
67
+ } else if (node?.type === "VariableDeclaration") {
68
+ for (const declaration of node.declarations) if (declaration.id.type === "Identifier") {
69
+ if (declaration.init) module.values.set(declaration.id.name, declaration.init);
70
+ if (node !== statement) module.exports.set(declaration.id.name, declaration.id.name);
71
+ }
72
+ } else if (node && node !== statement && node.id) {
73
+ module.exports.set(node.id.name, node.id.name);
74
+ }
75
+ }
76
+ return module;
77
+ };
78
+ const resolveExport = (source, name, seen = /* @__PURE__ */ new Set()) => {
79
+ const module = load(source);
80
+ if (!module || seen.has(source)) return;
81
+ seen.add(source);
82
+ const here = {
83
+ source,
84
+ imported: name
85
+ };
86
+ const follow = (binding) => !load(binding.source) ? here : binding.imported === "*" ? binding : resolveExport(binding.source, binding.imported, seen) ?? here;
87
+ const reexport = module.reexports.get(name);
88
+ if (reexport) return follow(reexport);
89
+ const local = module.exports.get(name);
90
+ if (local !== void 0) {
91
+ const imported = module.imports.get(local);
92
+ return imported && !module.values.has(local) ? follow(imported) : here;
93
+ }
94
+ for (const star of module.stars) {
95
+ if (!load(star)) return here;
96
+ const found = resolveExport(star, name, seen);
97
+ if (found) return found;
22
98
  }
23
- }
24
- const member = (expression, path, consumed = 0) => {
99
+ };
100
+ const bind = (imported) => !load(imported.source) ? void 0 : imported.imported === "*" ? imported : resolveExport(imported.source, imported.imported) ?? imported;
101
+ const descend = (binding, path, consumed) => {
102
+ const target = load(binding.source);
103
+ if (!target || !path.length) return {
104
+ binding,
105
+ consumed
106
+ };
107
+ if (binding.imported === "*") {
108
+ const inner = resolveExport(binding.source, path[0]);
109
+ return inner && descend(inner, path.slice(1), consumed + 1);
110
+ }
111
+ const value = target.values.get(target.exports.get(binding.imported) ?? "");
112
+ const found = value && member(target, value, path, consumed);
113
+ if (found) return found;
114
+ const object = value?.type === "CallExpression" && value.callee.property?.name === "freeze" ? value.arguments[0] : value;
115
+ const index = object?.type === "ObjectExpression" ? object.properties.findLastIndex((property) => property.type === "SpreadElement" || !property.computed && (property.key.name ?? property.key.value) === path[0]) : -1;
116
+ return index >= 0 && object.properties[index].type === "Property" ? {
117
+ binding,
118
+ consumed: consumed + 1,
119
+ suffix: [path[0]]
120
+ } : {
121
+ binding,
122
+ consumed
123
+ };
124
+ };
125
+ const member = (module, expression, path, consumed = 0) => {
25
126
  if (expression.type === "Identifier") {
26
- const binding = imports.get(expression.name);
27
- if (binding) return {
28
- binding,
127
+ const imported = module.imports.get(expression.name);
128
+ if (imported) {
129
+ const binding = bind(imported);
130
+ return binding && descend(binding, path, consumed);
131
+ }
132
+ const value = module.values.get(expression.name);
133
+ const found = value && member(module, value, path, consumed);
134
+ if (found || module.path === file) return found;
135
+ for (const [exported, local] of module.exports) if (local === expression.name) return {
136
+ binding: {
137
+ source: module.path,
138
+ imported: exported
139
+ },
29
140
  consumed
30
141
  };
31
- const value = values.get(expression.name);
32
- return value ? member(value, path, consumed) : void 0;
142
+ return;
143
+ }
144
+ if (expression.type === "CallExpression" && expression.callee.type === "MemberExpression" && expression.callee.object.name === "Object" && expression.callee.property.name === "freeze") return member(module, expression.arguments[0], path, consumed);
145
+ if (expression.type === "MemberExpression" && !expression.computed) {
146
+ const found = member(module, expression.object, [expression.property.name, ...path], consumed - 1);
147
+ if (!found || found.consumed >= consumed) return found;
148
+ if (found.call || found.consumed < consumed - 1) return;
149
+ return {
150
+ ...found,
151
+ consumed,
152
+ suffix: [...found.suffix ?? [], expression.property.name]
153
+ };
154
+ }
155
+ if (expression.type === "ConditionalExpression") {
156
+ const test = expression.test;
157
+ if (test.type === "BinaryExpression" && test.left.type === "MemberExpression" && test.left.property.name === "OS" && typeof test.right.value === "string" && ["===", "!=="].includes(test.operator)) return member(module, test.right.value === platform === (test.operator === "===") ? expression.consequent : expression.alternate, path, consumed);
158
+ return;
33
159
  }
34
- if (expression.type === "CallExpression" && expression.callee.type === "MemberExpression" && expression.callee.object.name === "Object" && expression.callee.property.name === "freeze") return member(expression.arguments[0], path, consumed);
35
160
  if (expression.type !== "ObjectExpression" || !path.length) return;
36
161
  for (const property of expression.properties.toReversed()) {
37
162
  if (property.type === "Property" && !property.computed && (property.key.name ?? property.key.value) === path[0]) {
38
- if (property.kind === "init") return member(property.value, path.slice(1), consumed + 1);
163
+ if (property.kind === "init") return member(module, property.value, path.slice(1), consumed + 1);
39
164
  const body = property.value.body.body;
40
165
  const returned = body.length === 1 && body[0].type === "ReturnStatement" ? body[0].argument : void 0;
41
166
  if (property.kind === "get" && returned?.type === "CallExpression" && returned.callee.type === "Identifier" && !returned.arguments.length) {
42
- const binding = imports.get(returned.callee.name);
167
+ const imported = module.imports.get(returned.callee.name);
168
+ const binding = imported && bind(imported);
43
169
  if (binding) return {
44
170
  binding,
45
171
  consumed: consumed + 1,
@@ -49,24 +175,69 @@ function nativeOneMembers(file) {
49
175
  return;
50
176
  }
51
177
  if (property.type === "SpreadElement") {
52
- const found = member(property.argument, path, consumed);
53
- if (found) return found;
178
+ const found = member(module, property.argument, path, consumed);
179
+ if (found && found.consumed > consumed) return found;
54
180
  }
55
181
  }
56
182
  };
57
- return (source, id) => {
183
+ const shared = load(file);
184
+ const one = shared.values.get("One");
185
+ return (source, id, escape = () => {}) => {
186
+ if (/\b(require|import)\s*\(\s*["'`]one["'`]\s*\)/.test(source) || /export\s*(\*(\s*as\s+[\w$]+)?|\{[^}]*\bOne\b[^}]*\})\s*from\s*["']one["']/.test(source)) escape("dynamic or re-exported one");
58
187
  const parsed = parseSync(id, source, { lang: /\.tsx$/.test(id) ? "tsx" : /\.[cm]?ts$/.test(id) ? "ts" : "jsx" });
59
- if (parsed.errors.length) return;
188
+ if (parsed.errors.length) {
189
+ escape("parse error");
190
+ return;
191
+ }
60
192
  const app = parsed.program;
61
193
  const roots = /* @__PURE__ */ new Map();
62
194
  for (const node of app.body) {
63
- if (node.type !== "ImportDeclaration" || node.source.value !== "one") continue;
195
+ if (node.type !== "ImportDeclaration" || node.source.value !== "one" || node.importKind === "type") continue;
64
196
  for (const item of node.specifiers) {
65
- if (item.type === "ImportSpecifier" && (item.imported.name ?? item.imported.value) === "One") roots.set(item.local.name, []);
66
- else if (item.type === "ImportNamespaceSpecifier") roots.set(item.local.name, ["One"]);
197
+ if (item.type === "ImportSpecifier" && item.importKind !== "type" && (item.imported.name ?? item.imported.value) === "One") roots.set(item.local.name, {
198
+ prefix: [],
199
+ base: []
200
+ });
201
+ else if (item.type === "ImportNamespaceSpecifier") roots.set(item.local.name, {
202
+ prefix: ["One"],
203
+ base: []
204
+ });
67
205
  }
68
206
  }
69
207
  if (!roots.size) return;
208
+ const chain = (node) => {
209
+ const path = [];
210
+ const nodes = [];
211
+ let root = node;
212
+ while (root.type === "MemberExpression" && !root.computed || root.type === "JSXMemberExpression") {
213
+ path.unshift(root.property.name);
214
+ nodes.unshift(root);
215
+ root = root.object;
216
+ }
217
+ const read = roots.get(root.name);
218
+ return {
219
+ root,
220
+ path,
221
+ nodes,
222
+ read,
223
+ onePath: read && read.prefix.every((name, index) => path[index] === name) ? [...read.base, ...path.slice(read.prefix.length)] : void 0
224
+ };
225
+ };
226
+ const aliases = /* @__PURE__ */ new Set();
227
+ for (const statement of app.body) {
228
+ if (statement.type !== "VariableDeclaration" || statement.kind !== "const") continue;
229
+ for (const declaration of statement.declarations) {
230
+ if (declaration.id.type !== "Identifier" || !declaration.init) continue;
231
+ const { onePath } = chain(declaration.init);
232
+ if (!onePath?.length) continue;
233
+ if (member(shared, one, onePath)?.consumed === onePath.length) continue;
234
+ roots.set(declaration.id.name, {
235
+ prefix: [],
236
+ base: onePath
237
+ });
238
+ aliases.add(declaration);
239
+ }
240
+ }
70
241
  const children = (node, visit2) => {
71
242
  for (const [key, value] of Object.entries(node)) {
72
243
  if (key === "typeAnnotation" || key === "returnType" || key === "typeParameters" || key === "typeArguments") continue;
@@ -76,11 +247,14 @@ function nativeOneMembers(file) {
76
247
  const pattern = (node) => {
77
248
  if (node.type === "Identifier") roots.delete(node.name);
78
249
  else if (node.type === "Property") pattern(node.value);
79
- else children(node, pattern);
250
+ else if (node.type === "AssignmentPattern") pattern(node.left);
251
+ else if (node.type === "RestElement") pattern(node.argument);
252
+ else if (node.type === "TSParameterProperty") pattern(node.parameter);
253
+ else if (node.type === "ArrayPattern" || node.type === "ObjectPattern") children(node, pattern);
80
254
  };
81
255
  const shadows = (node) => {
82
256
  if (node.type === "ImportDeclaration") return;
83
- if (node.type === "VariableDeclarator") pattern(node.id);
257
+ if (node.type === "VariableDeclarator" && !aliases.has(node)) pattern(node.id);
84
258
  if (node.type === "FunctionDeclaration" || node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression") {
85
259
  if (node.id) pattern(node.id);
86
260
  for (const parameter of node.params) pattern(parameter);
@@ -91,46 +265,103 @@ function nativeOneMembers(file) {
91
265
  if (node.type === "CatchClause" && node.param) pattern(node.param);
92
266
  children(node, shadows);
93
267
  };
268
+ const imported = roots.size;
94
269
  shadows(app);
270
+ if (roots.size < imported) escape("shadowed One");
95
271
  const output = new MagicString(source);
96
272
  const added = /* @__PURE__ */ new Map();
273
+ const rootOf = (node) => node.type === "MemberExpression" ? rootOf(node.object) : node;
274
+ const escaped = /* @__PURE__ */ new Set();
275
+ const kept = (name, reason) => {
276
+ escaped.add(name);
277
+ escape(reason);
278
+ };
279
+ const typeOnly = (node) => node.declare || node.type === "TSTypeAliasDeclaration" || node.type === "TSInterfaceDeclaration" || node.type === "TSDeclareFunction" || node.type.startsWith("TS") && node.type.endsWith("Type");
280
+ let rewritten = 0;
97
281
  const visit = (node) => {
98
- if (node.type === "ImportDeclaration" || node.type.startsWith("TS")) return;
99
- if (node.type === "AssignmentExpression") {
100
- visit(node.right);
282
+ if (node.type === "ImportDeclaration" || aliases.has(node) || typeOnly(node)) return;
283
+ if (node.type === "Identifier") {
284
+ if (roots.has(node.name)) kept(node.name, `One read at ${node.start}`);
285
+ return;
286
+ }
287
+ if ((node.type === "Property" || node.type === "MethodDefinition" || node.type === "PropertyDefinition") && !node.computed) {
288
+ if (node.value) visit(node.value);
289
+ return;
290
+ }
291
+ const target = node.type === "AssignmentExpression" ? node.left : node.type === "UpdateExpression" || node.type === "UnaryExpression" && node.operator === "delete" ? node.argument : void 0;
292
+ if (target) {
293
+ if (roots.has(rootOf(target).name)) kept(rootOf(target).name, `One written at ${node.start}`);
294
+ if (node.type === "AssignmentExpression") visit(node.right);
101
295
  return;
102
296
  }
103
- if (node.type === "UpdateExpression" || node.type === "UnaryExpression" && node.operator === "delete") return;
104
297
  if (node.type === "MemberExpression" || node.type === "JSXMemberExpression") {
105
- const path = [];
106
- const nodes = [];
107
- let root = node;
108
- while (root.type === "MemberExpression" && !root.computed || root.type === "JSXMemberExpression") {
109
- path.unshift(root.property.name);
110
- nodes.unshift(root);
111
- root = root.object;
112
- }
113
- const prefix = roots.get(root.name);
114
- if (prefix && prefix.every((name, index) => path[index] === name)) {
115
- const found = member(values.get("One"), path.slice(prefix.length));
116
- if (found && found.consumed && !(found.call && node.type === "JSXMemberExpression")) {
117
- let alias = added.get(found.binding);
118
- if (!alias) {
119
- alias = `__one_member_${added.size}`;
120
- while (new RegExp(`\\b${alias}\\b`).test(source)) alias += "_";
121
- added.set(found.binding, alias);
122
- }
123
- output.overwrite(root.start, nodes[prefix.length + found.consumed - 1].end, found.call ? `(${alias}())` : alias);
298
+ const { root, nodes, read, onePath } = chain(node);
299
+ if (read) {
300
+ if (!onePath) return;
301
+ const found = member(shared, one, onePath);
302
+ const consumed = (found?.consumed ?? 0) - read.base.length;
303
+ if (!found || consumed < 1 || found.call && node.type === "JSXMemberExpression") {
304
+ kept(root.name, `One.${onePath.join(".")}`);
124
305
  return;
125
306
  }
307
+ const key = `${found.binding.source}\0${found.binding.imported}`;
308
+ let alias = added.get(key)?.alias;
309
+ if (!alias) {
310
+ alias = `__one_member_${added.size}`;
311
+ while (new RegExp(`\\b${alias}\\b`).test(source)) alias += "_";
312
+ added.set(key, {
313
+ binding: found.binding,
314
+ alias
315
+ });
316
+ }
317
+ rewritten++;
318
+ output.overwrite(root.start, nodes[read.prefix.length + consumed - 1].end, found.call ? `(${alias}())` : alias + (found.suffix ?? []).map((name) => `.${name}`).join(""));
319
+ return;
320
+ }
321
+ if (nodes.length) {
322
+ visit(root);
323
+ return;
126
324
  }
127
325
  }
128
326
  children(node, visit);
129
327
  };
130
328
  visit(app);
131
- if (!added.size) return;
329
+ let references = 0;
330
+ const count = (node) => {
331
+ if (node.type === "ImportDeclaration" || aliases.has(node) || typeOnly(node)) return;
332
+ if (node.type === "Identifier" || node.type === "JSXIdentifier") {
333
+ if (roots.has(node.name)) references++;
334
+ return;
335
+ }
336
+ if (node.type === "MemberExpression" || node.type === "JSXMemberExpression") {
337
+ count(node.object);
338
+ if (node.computed) count(node.property);
339
+ return;
340
+ }
341
+ if ((node.type === "Property" || node.type === "MethodDefinition" || node.type === "PropertyDefinition" || node.type === "JSXAttribute") && !node.computed) {
342
+ if (node.value) count(node.value);
343
+ return;
344
+ }
345
+ if (node.type === "LabeledStatement" || node.type === "BreakStatement" || node.type === "ContinueStatement") {
346
+ if (node.body) count(node.body);
347
+ return;
348
+ }
349
+ if (node.type === "ExportSpecifier") {
350
+ count(node.local);
351
+ return;
352
+ }
353
+ children(node, count);
354
+ };
355
+ count(app);
356
+ const complete = references === rewritten && roots.size === imported;
357
+ if (!complete) escape("One reference left unrewritten");
358
+ for (const declaration of [...aliases].toReversed()) {
359
+ if (complete && roots.has(declaration.id.name) && !escaped.has(declaration.id.name)) output.overwrite(declaration.init.start, declaration.init.end, "void 0");
360
+ else escaped.add(chain(declaration.init).root.name);
361
+ }
362
+ if (!added.size && !aliases.size) return;
132
363
  const lastImport = app.body.filter((node) => node.type === "ImportDeclaration").at(-1);
133
- output.appendLeft(lastImport.end, "\n" + [...added].map(([binding, alias]) => `import ${binding.imported === "*" ? `* as ${alias}` : `{ ${binding.imported} as ${alias} }`} from ${JSON.stringify(binding.source)};
364
+ output.appendLeft(lastImport.end, "\n" + [...added.values()].map(({ binding, alias }) => `import ${binding.imported === "*" ? `* as ${alias}` : `{ ${binding.imported} as ${alias} }`} from ${JSON.stringify(binding.source)};
134
365
  `).join(""));
135
366
  return {
136
367
  code: output.toString(),
@@ -1 +1 @@
1
- {"version":3,"file":"oneNativeMembers.js","names":[],"sources":["esm/vite/plugins/oneNativeMembers.js"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport MagicString from \"magic-string\";\nimport { parseSync } from \"oxc-parser\";\nfunction nativeOneMembers(file) {\n const imports = /* @__PURE__ */ new Map();\n const values = /* @__PURE__ */ new Map();\n const program = parseSync(file, readFileSync(file, \"utf8\")).program;\n for (const statement of program.body) {\n const node = statement.type === \"ExportNamedDeclaration\" ? statement.declaration : statement;\n if (node?.type === \"ImportDeclaration\") {\n for (const item of node.specifiers) {\n imports.set(item.local.name, {\n source: node.source.value.startsWith(\".\") ? resolve(dirname(file), node.source.value) : node.source.value,\n imported: item.type === \"ImportSpecifier\" ? String(item.imported.name ?? item.imported.value) : item.type === \"ImportDefaultSpecifier\" ? \"default\" : \"*\"\n });\n }\n } else if (node?.type === \"VariableDeclaration\") {\n for (const declaration of node.declarations)\n if (declaration.id.type === \"Identifier\" && declaration.init)\n values.set(declaration.id.name, declaration.init);\n }\n }\n const member = (expression, path, consumed = 0) => {\n if (expression.type === \"Identifier\") {\n const binding = imports.get(expression.name);\n if (binding) return { binding, consumed };\n const value = values.get(expression.name);\n return value ? member(value, path, consumed) : void 0;\n }\n if (expression.type === \"CallExpression\" && expression.callee.type === \"MemberExpression\" && expression.callee.object.name === \"Object\" && expression.callee.property.name === \"freeze\")\n return member(expression.arguments[0], path, consumed);\n if (expression.type !== \"ObjectExpression\" || !path.length) return;\n for (const property of expression.properties.toReversed()) {\n if (property.type === \"Property\" && !property.computed && (property.key.name ?? property.key.value) === path[0]) {\n if (property.kind === \"init\")\n return member(property.value, path.slice(1), consumed + 1);\n const body = property.value.body.body;\n const returned = body.length === 1 && body[0].type === \"ReturnStatement\" ? body[0].argument : void 0;\n if (property.kind === \"get\" && returned?.type === \"CallExpression\" && returned.callee.type === \"Identifier\" && !returned.arguments.length) {\n const binding = imports.get(returned.callee.name);\n if (binding) return { binding, consumed: consumed + 1, call: true };\n }\n return;\n }\n if (property.type === \"SpreadElement\") {\n const found = member(property.argument, path, consumed);\n if (found) return found;\n }\n }\n };\n return (source, id) => {\n const parsed = parseSync(id, source, {\n lang: /\\.tsx$/.test(id) ? \"tsx\" : /\\.[cm]?ts$/.test(id) ? \"ts\" : \"jsx\"\n });\n if (parsed.errors.length) return;\n const app = parsed.program;\n const roots = /* @__PURE__ */ new Map();\n for (const node of app.body) {\n if (node.type !== \"ImportDeclaration\" || node.source.value !== \"one\") continue;\n for (const item of node.specifiers) {\n if (item.type === \"ImportSpecifier\" && (item.imported.name ?? item.imported.value) === \"One\")\n roots.set(item.local.name, []);\n else if (item.type === \"ImportNamespaceSpecifier\")\n roots.set(item.local.name, [\"One\"]);\n }\n }\n if (!roots.size) return;\n const children = (node, visit2) => {\n for (const [key, value] of Object.entries(node)) {\n if (key === \"typeAnnotation\" || key === \"returnType\" || key === \"typeParameters\" || key === \"typeArguments\")\n continue;\n for (const child of Array.isArray(value) ? value : [value])\n if (child && typeof child === \"object\" && typeof child.type === \"string\")\n visit2(child);\n }\n };\n const pattern = (node) => {\n if (node.type === \"Identifier\") roots.delete(node.name);\n else if (node.type === \"Property\") pattern(node.value);\n else children(node, pattern);\n };\n const shadows = (node) => {\n if (node.type === \"ImportDeclaration\") return;\n if (node.type === \"VariableDeclarator\") pattern(node.id);\n if (node.type === \"FunctionDeclaration\" || node.type === \"FunctionExpression\" || node.type === \"ArrowFunctionExpression\") {\n if (node.id) pattern(node.id);\n for (const parameter of node.params) pattern(parameter);\n }\n if (node.type === \"ClassDeclaration\" || node.type === \"ClassExpression\") {\n if (node.id) pattern(node.id);\n }\n if (node.type === \"CatchClause\" && node.param) pattern(node.param);\n children(node, shadows);\n };\n shadows(app);\n const output = new MagicString(source);\n const added = /* @__PURE__ */ new Map();\n const visit = (node) => {\n if (node.type === \"ImportDeclaration\" || node.type.startsWith(\"TS\")) return;\n if (node.type === \"AssignmentExpression\") {\n visit(node.right);\n return;\n }\n if (node.type === \"UpdateExpression\" || node.type === \"UnaryExpression\" && node.operator === \"delete\")\n return;\n if (node.type === \"MemberExpression\" || node.type === \"JSXMemberExpression\") {\n const path = [];\n const nodes = [];\n let root = node;\n while (root.type === \"MemberExpression\" && !root.computed || root.type === \"JSXMemberExpression\") {\n path.unshift(root.property.name);\n nodes.unshift(root);\n root = root.object;\n }\n const prefix = roots.get(root.name);\n if (prefix && prefix.every((name, index) => path[index] === name)) {\n const found = member(values.get(\"One\"), path.slice(prefix.length));\n if (found && found.consumed && !(found.call && node.type === \"JSXMemberExpression\")) {\n let alias = added.get(found.binding);\n if (!alias) {\n alias = `__one_member_${added.size}`;\n while (new RegExp(`\\\\b${alias}\\\\b`).test(source)) alias += \"_\";\n added.set(found.binding, alias);\n }\n output.overwrite(\n root.start,\n nodes[prefix.length + found.consumed - 1].end,\n found.call ? `(${alias}())` : alias\n );\n return;\n }\n }\n }\n children(node, visit);\n };\n visit(app);\n if (!added.size) return;\n const lastImport = app.body.filter((node) => node.type === \"ImportDeclaration\").at(-1);\n output.appendLeft(\n lastImport.end,\n \"\\n\" + [...added].map(\n ([binding, alias]) => `import ${binding.imported === \"*\" ? `* as ${alias}` : `{ ${binding.imported} as ${alias} }`} from ${JSON.stringify(binding.source)};\n`\n ).join(\"\")\n );\n return {\n code: output.toString(),\n map: output.generateMap({ source: id, includeContent: true, hires: true })\n };\n };\n}\nexport {\n nativeOneMembers\n};\n//# sourceMappingURL=oneNativeMembers.js.map\n"],"mappings":";;;;;;AAIA,SAAS,iBAAiB,MAAM;CAC9B,MAAM,0BAA0B,IAAI,IAAI;CACxC,MAAM,yBAAyB,IAAI,IAAI;CACvC,MAAM,UAAU,UAAU,MAAM,aAAa,MAAM,MAAM,CAAC,CAAC,CAAC;CAC5D,KAAK,MAAM,aAAa,QAAQ,MAAM;EACpC,MAAM,OAAO,UAAU,SAAS,2BAA2B,UAAU,cAAc;EACnF,IAAI,MAAM,SAAS,qBAAqB;GACtC,KAAK,MAAM,QAAQ,KAAK,YAAY;IAClC,QAAQ,IAAI,KAAK,MAAM,MAAM;KAC3B,QAAQ,KAAK,OAAO,MAAM,WAAW,GAAG,IAAI,QAAQ,QAAQ,IAAI,GAAG,KAAK,OAAO,KAAK,IAAI,KAAK,OAAO;KACpG,UAAU,KAAK,SAAS,oBAAoB,OAAO,KAAK,SAAS,QAAQ,KAAK,SAAS,KAAK,IAAI,KAAK,SAAS,2BAA2B,YAAY;IACvJ,CAAC;GACH;EACF,OAAO,IAAI,MAAM,SAAS,uBAAuB;GAC/C,KAAK,MAAM,eAAe,KAAK,cAC7B,IAAI,YAAY,GAAG,SAAS,gBAAgB,YAAY,MACtD,OAAO,IAAI,YAAY,GAAG,MAAM,YAAY,IAAI;EACtD;CACF;CACA,MAAM,UAAU,YAAY,MAAM,WAAW,MAAM;EACjD,IAAI,WAA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AC,KAAK,MAAM,GAAG,SAAS;OAC3D,MAAM,IAAI,MAAM,SAAS,KAAK;MAChC;MACA,OAAO,UACL,KAAK,OACL,MAAM,OAAO,SAAS,MAAM,WAAW,EAAE,CAAC,KAC1C,MAAM,OAAO,IAAI,MAAM,OAAO,KAChC;MACA;KACF;IACF;GACF;GACA,SAAS,MAAM,KAAK;EACtB;EACA,MAAM,GAAG;EACT,IAAI,CAAC,MAAM,MAAM;EACjB,MAAM,aAAa,IAAI,KAAK,QAAQ,SAAS,KAAK,SAAS,mBAAmB,CAAC,CAAC,GAAG,CAAC,CAAC;EACrF,OAAO,WACL,WAAW,KACX,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,KACf,CAAC,SAAS,WAAW,UAAU,QAAQ,aAAa,MAAM,QAAQ,UAAU,KAAK,QAAQ,SAAS,MAAM,MAAM,IAAI,QAAQ,KAAK,UAAU,QAAQ,MAAM,EAAE;CAE5J,CAAC,CAAC,KAAK,EAAE,CACX;EACA,OAAO;GACL,MAAM,OAAO,SAAS;GACtB,KAAK,OAAO,YAAY;IAAE,QAAQ;IAAI,gBAAgB;IAAM,OAAO;GAAK,CAAC;EAC3E;CACF;AACF"}
1
+ {"version":3,"file":"oneNativeMembers.js","names":[],"sources":["esm/vite/plugins/oneNativeMembers.js"],"sourcesContent":["import { readFileSync, statSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport MagicString from \"magic-string\";\nimport { parseSync } from \"oxc-parser\";\nfunction nativeOneMembers(file, platform = \"ios\") {\n const modules = /* @__PURE__ */ new Map();\n const load = (path) => {\n if (modules.has(path)) return modules.get(path);\n let code;\n try {\n code = readFileSync(path, \"utf8\");\n } catch {\n modules.set(path, void 0);\n return;\n }\n const module = {\n path,\n imports: /* @__PURE__ */ new Map(),\n values: /* @__PURE__ */ new Map(),\n exports: /* @__PURE__ */ new Map(),\n reexports: /* @__PURE__ */ new Map(),\n stars: []\n };\n modules.set(path, module);\n const from = (specifier) => {\n if (!specifier.startsWith(\".\")) return specifier;\n const base = resolve(dirname(path), specifier);\n return [\n \"\",\n `.${platform}.js`,\n \".native.js\",\n \".js\",\n `/index.${platform}.js`,\n \"/index.native.js\",\n \"/index.js\"\n ].map((suffix) => base + suffix).find(\n (candidate) => statSync(candidate, { throwIfNoEntry: false })?.isFile()\n ) ?? base;\n };\n const name = (node) => String(node.name ?? node.value);\n for (const statement of parseSync(path, code).program.body) {\n if (statement.type === \"ExportAllDeclaration\") {\n if (statement.exported)\n module.reexports.set(name(statement.exported), {\n source: from(statement.source.value),\n imported: \"*\"\n });\n else module.stars.push(from(statement.source.value));\n continue;\n }\n if (statement.type === \"ExportNamedDeclaration\") {\n for (const item of statement.specifiers ?? []) {\n if (statement.source)\n module.reexports.set(name(item.exported), {\n source: from(statement.source.value),\n imported: name(item.local)\n });\n else module.exports.set(name(item.exported), name(item.local));\n }\n }\n const node = statement.type === \"ExportNamedDeclaration\" ? statement.declaration : statement;\n if (node?.type === \"ImportDeclaration\") {\n for (const item of node.specifiers) {\n module.imports.set(item.local.name, {\n source: from(node.source.value),\n imported: item.type === \"ImportSpecifier\" ? name(item.imported) : item.type === \"ImportDefaultSpecifier\" ? \"default\" : \"*\"\n });\n }\n } else if (node?.type === \"VariableDeclaration\") {\n for (const declaration of node.declarations)\n if (declaration.id.type === \"Identifier\") {\n if (declaration.init) module.values.set(declaration.id.name, declaration.init);\n if (node !== statement)\n module.exports.set(declaration.id.name, declaration.id.name);\n }\n } else if (node && node !== statement && node.id) {\n module.exports.set(node.id.name, node.id.name);\n }\n }\n return module;\n };\n const resolveExport = (source, name, seen = /* @__PURE__ */ new Set()) => {\n const module = load(source);\n if (!module || seen.has(source)) return;\n seen.add(source);\n const here = { source, imported: name };\n const follow = (binding) => !load(binding.source) ? here : binding.imported === \"*\" ? binding : resolveExport(binding.source, binding.imported, seen) ?? here;\n const reexport = module.reexports.get(name);\n if (reexport) return follow(reexport);\n const local = module.exports.get(name);\n if (local !== void 0) {\n const imported = module.imports.get(local);\n return imported && !module.values.has(local) ? follow(imported) : here;\n }\n for (const star of module.stars) {\n if (!load(star)) return here;\n const found = resolveExport(star, name, seen);\n if (found) return found;\n }\n };\n const bind = (imported) => !load(imported.source) ? void 0 : imported.imported === \"*\" ? imported : resolveExport(imported.source, imported.imported) ?? imported;\n const descend = (binding, path, consumed) => {\n const target = load(binding.source);\n if (!target || !path.length) return { binding, consumed };\n if (binding.imported === \"*\") {\n const inner = resolveExport(binding.source, path[0]);\n return inner && descend(inner, path.slice(1), consumed + 1);\n }\n const value = target.values.get(target.exports.get(binding.imported) ?? \"\");\n const found = value && member(target, value, path, consumed);\n if (found) return found;\n const object = value?.type === \"CallExpression\" && value.callee.property?.name === \"freeze\" ? value.arguments[0] : value;\n const index = object?.type === \"ObjectExpression\" ? object.properties.findLastIndex(\n (property) => property.type === \"SpreadElement\" || !property.computed && (property.key.name ?? property.key.value) === path[0]\n ) : -1;\n return index >= 0 && object.properties[index].type === \"Property\" ? { binding, consumed: consumed + 1, suffix: [path[0]] } : { binding, consumed };\n };\n const member = (module, expression, path, consumed = 0) => {\n if (expression.type === \"Identifier\") {\n const imported = module.imports.get(expression.name);\n if (imported) {\n const binding = bind(imported);\n return binding && descend(binding, path, consumed);\n }\n const value = module.values.get(expression.name);\n const found = value && member(module, value, path, consumed);\n if (found || module.path === file) return found;\n for (const [exported, local] of module.exports)\n if (local === expression.name)\n return { binding: { source: module.path, imported: exported }, consumed };\n return;\n }\n if (expression.type === \"CallExpression\" && expression.callee.type === \"MemberExpression\" && expression.callee.object.name === \"Object\" && expression.callee.property.name === \"freeze\")\n return member(module, expression.arguments[0], path, consumed);\n if (expression.type === \"MemberExpression\" && !expression.computed) {\n const found = member(\n module,\n expression.object,\n [expression.property.name, ...path],\n consumed - 1\n );\n if (!found || found.consumed >= consumed) return found;\n if (found.call || found.consumed < consumed - 1) return;\n return {\n ...found,\n consumed,\n suffix: [...found.suffix ?? [], expression.property.name]\n };\n }\n if (expression.type === \"ConditionalExpression\") {\n const test = expression.test;\n if (test.type === \"BinaryExpression\" && test.left.type === \"MemberExpression\" && test.left.property.name === \"OS\" && typeof test.right.value === \"string\" && [\"===\", \"!==\"].includes(test.operator))\n return member(\n module,\n test.right.value === platform === (test.operator === \"===\") ? expression.consequent : expression.alternate,\n path,\n consumed\n );\n return;\n }\n if (expression.type !== \"ObjectExpression\" || !path.length) return;\n for (const property of expression.properties.toReversed()) {\n if (property.type === \"Property\" && !property.computed && (property.key.name ?? property.key.value) === path[0]) {\n if (property.kind === \"init\")\n return member(module, property.value, path.slice(1), consumed + 1);\n const body = property.value.body.body;\n const returned = body.length === 1 && body[0].type === \"ReturnStatement\" ? body[0].argument : void 0;\n if (property.kind === \"get\" && returned?.type === \"CallExpression\" && returned.callee.type === \"Identifier\" && !returned.arguments.length) {\n const imported = module.imports.get(returned.callee.name);\n const binding = imported && bind(imported);\n if (binding) return { binding, consumed: consumed + 1, call: true };\n }\n return;\n }\n if (property.type === \"SpreadElement\") {\n const found = member(module, property.argument, path, consumed);\n if (found && found.consumed > consumed) return found;\n }\n }\n };\n const shared = load(file);\n const one = shared.values.get(\"One\");\n return (source, id, escape = () => {\n }) => {\n if (/\\b(require|import)\\s*\\(\\s*[\"'`]one[\"'`]\\s*\\)/.test(source) || /export\\s*(\\*(\\s*as\\s+[\\w$]+)?|\\{[^}]*\\bOne\\b[^}]*\\})\\s*from\\s*[\"']one[\"']/.test(\n source\n ))\n escape(\"dynamic or re-exported one\");\n const parsed = parseSync(id, source, {\n lang: /\\.tsx$/.test(id) ? \"tsx\" : /\\.[cm]?ts$/.test(id) ? \"ts\" : \"jsx\"\n });\n if (parsed.errors.length) {\n escape(\"parse error\");\n return;\n }\n const app = parsed.program;\n const roots = /* @__PURE__ */ new Map();\n for (const node of app.body) {\n if (node.type !== \"ImportDeclaration\" || node.source.value !== \"one\" || node.importKind === \"type\")\n continue;\n for (const item of node.specifiers) {\n if (item.type === \"ImportSpecifier\" && item.importKind !== \"type\" && (item.imported.name ?? item.imported.value) === \"One\")\n roots.set(item.local.name, { prefix: [], base: [] });\n else if (item.type === \"ImportNamespaceSpecifier\")\n roots.set(item.local.name, { prefix: [\"One\"], base: [] });\n }\n }\n if (!roots.size) return;\n const chain = (node) => {\n const path = [];\n const nodes = [];\n let root = node;\n while (root.type === \"MemberExpression\" && !root.computed || root.type === \"JSXMemberExpression\") {\n path.unshift(root.property.name);\n nodes.unshift(root);\n root = root.object;\n }\n const read = roots.get(root.name);\n return {\n root,\n path,\n nodes,\n read,\n // a namespace import reading another export of one leaves `One` alone\n onePath: read && read.prefix.every((name, index) => path[index] === name) ? [...read.base, ...path.slice(read.prefix.length)] : void 0\n };\n };\n const aliases = /* @__PURE__ */ new Set();\n for (const statement of app.body) {\n if (statement.type !== \"VariableDeclaration\" || statement.kind !== \"const\") continue;\n for (const declaration of statement.declarations) {\n if (declaration.id.type !== \"Identifier\" || !declaration.init) continue;\n const { onePath } = chain(declaration.init);\n if (!onePath?.length) continue;\n if (member(shared, one, onePath)?.consumed === onePath.length) continue;\n roots.set(declaration.id.name, { prefix: [], base: onePath });\n aliases.add(declaration);\n }\n }\n const children = (node, visit2) => {\n for (const [key, value] of Object.entries(node)) {\n if (key === \"typeAnnotation\" || key === \"returnType\" || key === \"typeParameters\" || key === \"typeArguments\")\n continue;\n for (const child of Array.isArray(value) ? value : [value])\n if (child && typeof child === \"object\" && typeof child.type === \"string\")\n visit2(child);\n }\n };\n const pattern = (node) => {\n if (node.type === \"Identifier\") roots.delete(node.name);\n else if (node.type === \"Property\") pattern(node.value);\n else if (node.type === \"AssignmentPattern\") pattern(node.left);\n else if (node.type === \"RestElement\") pattern(node.argument);\n else if (node.type === \"TSParameterProperty\") pattern(node.parameter);\n else if (node.type === \"ArrayPattern\" || node.type === \"ObjectPattern\")\n children(node, pattern);\n };\n const shadows = (node) => {\n if (node.type === \"ImportDeclaration\") return;\n if (node.type === \"VariableDeclarator\" && !aliases.has(node)) pattern(node.id);\n if (node.type === \"FunctionDeclaration\" || node.type === \"FunctionExpression\" || node.type === \"ArrowFunctionExpression\") {\n if (node.id) pattern(node.id);\n for (const parameter of node.params) pattern(parameter);\n }\n if (node.type === \"ClassDeclaration\" || node.type === \"ClassExpression\") {\n if (node.id) pattern(node.id);\n }\n if (node.type === \"CatchClause\" && node.param) pattern(node.param);\n children(node, shadows);\n };\n const imported = roots.size;\n shadows(app);\n if (roots.size < imported) escape(\"shadowed One\");\n const output = new MagicString(source);\n const added = /* @__PURE__ */ new Map();\n const rootOf = (node) => node.type === \"MemberExpression\" ? rootOf(node.object) : node;\n const escaped = /* @__PURE__ */ new Set();\n const kept = (name, reason) => {\n escaped.add(name);\n escape(reason);\n };\n const typeOnly = (node) => node.declare || node.type === \"TSTypeAliasDeclaration\" || node.type === \"TSInterfaceDeclaration\" || node.type === \"TSDeclareFunction\" || node.type.startsWith(\"TS\") && node.type.endsWith(\"Type\");\n let rewritten = 0;\n const visit = (node) => {\n if (node.type === \"ImportDeclaration\" || aliases.has(node) || typeOnly(node)) return;\n if (node.type === \"Identifier\") {\n if (roots.has(node.name)) kept(node.name, `One read at ${node.start}`);\n return;\n }\n if ((node.type === \"Property\" || node.type === \"MethodDefinition\" || node.type === \"PropertyDefinition\") && !node.computed) {\n if (node.value) visit(node.value);\n return;\n }\n const target = node.type === \"AssignmentExpression\" ? node.left : node.type === \"UpdateExpression\" || node.type === \"UnaryExpression\" && node.operator === \"delete\" ? node.argument : void 0;\n if (target) {\n if (roots.has(rootOf(target).name))\n kept(rootOf(target).name, `One written at ${node.start}`);\n if (node.type === \"AssignmentExpression\") visit(node.right);\n return;\n }\n if (node.type === \"MemberExpression\" || node.type === \"JSXMemberExpression\") {\n const { root, nodes, read, onePath } = chain(node);\n if (read) {\n if (!onePath) return;\n const found = member(shared, one, onePath);\n const consumed = (found?.consumed ?? 0) - read.base.length;\n if (!found || consumed < 1 || found.call && node.type === \"JSXMemberExpression\") {\n kept(root.name, `One.${onePath.join(\".\")}`);\n return;\n }\n const key = `${found.binding.source}\\0${found.binding.imported}`;\n let alias = added.get(key)?.alias;\n if (!alias) {\n alias = `__one_member_${added.size}`;\n while (new RegExp(`\\\\b${alias}\\\\b`).test(source)) alias += \"_\";\n added.set(key, { binding: found.binding, alias });\n }\n rewritten++;\n output.overwrite(\n root.start,\n nodes[read.prefix.length + consumed - 1].end,\n found.call ? `(${alias}())` : alias + (found.suffix ?? []).map((name) => `.${name}`).join(\"\")\n );\n return;\n }\n if (nodes.length) {\n visit(root);\n return;\n }\n }\n children(node, visit);\n };\n visit(app);\n let references = 0;\n const count = (node) => {\n if (node.type === \"ImportDeclaration\" || aliases.has(node) || typeOnly(node)) return;\n if (node.type === \"Identifier\" || node.type === \"JSXIdentifier\") {\n if (roots.has(node.name)) references++;\n return;\n }\n if (node.type === \"MemberExpression\" || node.type === \"JSXMemberExpression\") {\n count(node.object);\n if (node.computed) count(node.property);\n return;\n }\n if ((node.type === \"Property\" || node.type === \"MethodDefinition\" || node.type === \"PropertyDefinition\" || node.type === \"JSXAttribute\") && !node.computed) {\n if (node.value) count(node.value);\n return;\n }\n if (node.type === \"LabeledStatement\" || node.type === \"BreakStatement\" || node.type === \"ContinueStatement\") {\n if (node.body) count(node.body);\n return;\n }\n if (node.type === \"ExportSpecifier\") {\n count(node.local);\n return;\n }\n children(node, count);\n };\n count(app);\n const complete = references === rewritten && roots.size === imported;\n if (!complete) escape(\"One reference left unrewritten\");\n for (const declaration of [...aliases].toReversed()) {\n if (complete && roots.has(declaration.id.name) && !escaped.has(declaration.id.name))\n output.overwrite(declaration.init.start, declaration.init.end, \"void 0\");\n else escaped.add(chain(declaration.init).root.name);\n }\n if (!added.size && !aliases.size) return;\n const lastImport = app.body.filter((node) => node.type === \"ImportDeclaration\").at(-1);\n output.appendLeft(\n lastImport.end,\n \"\\n\" + [...added.values()].map(\n ({ binding, alias }) => `import ${binding.imported === \"*\" ? `* as ${alias}` : `{ ${binding.imported} as ${alias} }`} from ${JSON.stringify(binding.source)};\n`\n ).join(\"\")\n );\n return {\n code: output.toString(),\n map: output.generateMap({ source: id, includeContent: true, hires: true })\n };\n };\n}\nexport {\n nativeOneMembers\n};\n//# sourceMappingURL=oneNativeMembers.js.map\n"],"mappings":";;;;;;AAIA,SAAS,iBAAiB,MAAM,WAAW,OAAO;CAChD,MAAM,0BAA0B,IAAI,IAAI;CACxC,MAAM,QAAQ,SAAS;EACrB,IAAI,QAAQ,IAAI,IAAI,GAAG,OAAO,QAAQ,IAAI,IAAI;EAC9C,IAAI;EACJ,IAAI;GACF,OAAO,aAAa,MAAM,MAAM;EAClC,QAAQ;GACN,QAAQ,IAAI,MAAM,KAAK,CAAC;GACxB;EACF;EACA,MAAM,SAAS;GACb;GACA,yBAAyB,IAAI,IAAI;GACjC,wBAAwB,IAAI,IAAI;GAChC,yBAAyB,IAAI,IAAI;GACjC,2BAA2B,IAAI,IAAI;GACnC,OAAO,CAAC;EACV;EACA,QAAQ,IAAI,MAAM,MAAM;EACxB,MAAM,QAAQ,cAAc;GAC1B,IAAI,CAAC,UAAU,WAAW,GAAG,GAAG,OAAO;GACvC,MAAM,OAAO,QAAQ,QAAQ,IAAI,GAAG,SAAS;GAC7C,OAAO;IACL;IACA,IAAI,SAAS;IACb;IACA;IACA,UAAU,SAAS;IACnB;IACA;GACF,CAAC,CAAC,KAAK,WAAW,OAAO,MAAM,CAAC,CAAC,MAC9B,cAAc,SAAS,WAAW,EAAE,gBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,CACxE,KAAK;EACP;EACA,MAAM,QAAQ,SAAS,OAAO,KAAK,QAAQ,KAAK,KAAK;EACrD,KAAK,MAAM,aAAa,UAAU,MAAM,IAAI,CAAC,CAAC,QAAQ,MAAM;GAC1D,IAAI,UAAU,SAAS,wBAAwB;IAC7C,IAAI,UAAU,UACZ,OAAO,UAAU,IAAI,KAAK,UAAU,QAAQ,GAAG;KAC7C,QAAQ,KAAK,UAAU,OAAO,KAAK;KACnC,UAAU;IACZ,CAAC;SACE,OAAO,MAAM,KAAK,KAAK,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