peachsim 0.1.2176 → 0.1.2179
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/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +2205 -1861
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +837 -571
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +1732 -1396
- package/dist-lib/host/fetch-proxy-handler.cjs +2 -2
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +2 -2
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +2 -2
- package/dist-lib/native-app-identity-project.cjs +2 -2
- package/dist-lib/native-app-identity-project.mjs +2 -2
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +24 -24
- package/dist-lib/public-origins-lib.json +59 -54
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +2223 -1876
- package/dist-lib/swift-compile.cjs +2 -2
- package/dist-lib/swift-compile.mjs +2 -2
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +1587 -1319
- package/dist-lib/vite.cjs +2 -2
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/package.json +1 -1
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNChangeHistoryEvent.h +116 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNChangeHistoryFetchRequest.h +79 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNContact+NSItemProvider.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNContact+Predicates.h +60 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNContact.h +169 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNContactFetchRequest.h +72 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNContactFormatter.h +136 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNContactProperty.h +47 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNContactRelation.h +287 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNContactStore.h +242 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNContactVCardSerialization.h +62 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNContactsUserDefaults.h +29 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNContainer+Predicates.h +29 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNContainer.h +44 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNError.h +64 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNFetchRequest.h +17 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNFetchResult.h +26 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNGroup+Predicates.h +28 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNGroup.h +34 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNInstantMessageAddress.h +52 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNLabeledValue.h +69 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNMutableContact.h +74 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNMutableGroup.h +25 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNMutablePostalAddress.h +35 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNPhoneNumber.h +44 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNPostalAddress.h +50 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNPostalAddressFormatter.h +91 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNSaveRequest.h +136 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/CNSocialProfile.h +55 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/Contacts.apinotes +28 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/Contacts.h +42 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Headers/ContactsDefines.h +14 -0
- package/sdk/ios/System/Library/Frameworks/Contacts.framework/Modules/module.modulemap +5 -0
- package/sdk/ios/System/Library/Frameworks/ContactsUI.framework/Headers/CNContactPickerViewController.h +92 -0
- package/sdk/ios/System/Library/Frameworks/ContactsUI.framework/Headers/CNContactViewController.h +157 -0
- package/sdk/ios/System/Library/Frameworks/ContactsUI.framework/Headers/ContactsUI.h +10 -0
- package/sdk/ios/System/Library/Frameworks/ContactsUI.framework/Headers/UIApplicationShortcutIcon+Contacts.h +22 -0
- package/sdk/ios/System/Library/Frameworks/ContactsUI.framework/Modules/module.modulemap +5 -0
- package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/NSFetchedResultsController.h +8 -0
- package/sdk/ios/System/Library/Frameworks/EventKit.framework/Headers/EKAlarm.h +114 -0
- package/sdk/ios/System/Library/Frameworks/EventKit.framework/Headers/EKCalendar.h +134 -0
- package/sdk/ios/System/Library/Frameworks/EventKit.framework/Headers/EKCalendarItem.h +129 -0
- package/sdk/ios/System/Library/Frameworks/EventKit.framework/Headers/EKError.h +105 -0
- package/sdk/ios/System/Library/Frameworks/EventKit.framework/Headers/EKEvent.h +205 -0
- package/sdk/ios/System/Library/Frameworks/EventKit.framework/Headers/EKEventStore.h +477 -0
- package/sdk/ios/System/Library/Frameworks/EventKit.framework/Headers/EKObject.h +34 -0
- package/sdk/ios/System/Library/Frameworks/EventKit.framework/Headers/EKParticipant.h +115 -0
- package/sdk/ios/System/Library/Frameworks/EventKit.framework/Headers/EKRecurrenceDayOfWeek.h +71 -0
- package/sdk/ios/System/Library/Frameworks/EventKit.framework/Headers/EKRecurrenceEnd.h +61 -0
- package/sdk/ios/System/Library/Frameworks/EventKit.framework/Headers/EKRecurrenceRule.h +193 -0
- package/sdk/ios/System/Library/Frameworks/EventKit.framework/Headers/EKReminder.h +80 -0
- package/sdk/ios/System/Library/Frameworks/EventKit.framework/Headers/EKSource.h +47 -0
- package/sdk/ios/System/Library/Frameworks/EventKit.framework/Headers/EKStructuredLocation.h +28 -0
- package/sdk/ios/System/Library/Frameworks/EventKit.framework/Headers/EKTypes.h +253 -0
- package/sdk/ios/System/Library/Frameworks/EventKit.framework/Headers/EKVirtualConferenceDescriptor.h +109 -0
- package/sdk/ios/System/Library/Frameworks/EventKit.framework/Headers/EKVirtualConferenceProvider.h +63 -0
- package/sdk/ios/System/Library/Frameworks/EventKit.framework/Headers/EventKit.apinotes +72 -0
- package/sdk/ios/System/Library/Frameworks/EventKit.framework/Headers/EventKit.h +29 -0
- package/sdk/ios/System/Library/Frameworks/EventKit.framework/Headers/EventKitDefines.h +30 -0
- package/sdk/ios/System/Library/Frameworks/EventKit.framework/Modules/module.modulemap +5 -0
- package/sdk/ios/System/Library/Frameworks/PushKit.framework/Headers/PKDefines.h +26 -0
- package/sdk/ios/System/Library/Frameworks/PushKit.framework/Headers/PKPushCredentials.h +37 -0
- package/sdk/ios/System/Library/Frameworks/PushKit.framework/Headers/PKPushPayload.h +36 -0
- package/sdk/ios/System/Library/Frameworks/PushKit.framework/Headers/PKPushRegistry.h +330 -0
- package/sdk/ios/System/Library/Frameworks/PushKit.framework/Headers/PKVoIPPushMetadata.h +27 -0
- package/sdk/ios/System/Library/Frameworks/PushKit.framework/Headers/PushKit.apinotes +43 -0
- package/sdk/ios/System/Library/Frameworks/PushKit.framework/Headers/PushKit.h +12 -0
- package/sdk/ios/System/Library/Frameworks/PushKit.framework/Modules/module.modulemap +6 -0
- package/sdk/ios/System/Library/Frameworks/QuickLook.framework/Headers/ARQuickLookPreviewItem.h +63 -0
- package/sdk/ios/System/Library/Frameworks/QuickLook.framework/Headers/QLBase.h +34 -0
- package/sdk/ios/System/Library/Frameworks/QuickLook.framework/Headers/QLFilePreviewRequest.h +32 -0
- package/sdk/ios/System/Library/Frameworks/QuickLook.framework/Headers/QLPreviewController.h +174 -0
- package/sdk/ios/System/Library/Frameworks/QuickLook.framework/Headers/QLPreviewItem.h +45 -0
- package/sdk/ios/System/Library/Frameworks/QuickLook.framework/Headers/QLPreviewProvider.h +27 -0
- package/sdk/ios/System/Library/Frameworks/QuickLook.framework/Headers/QLPreviewReply.h +106 -0
- package/sdk/ios/System/Library/Frameworks/QuickLook.framework/Headers/QLPreviewSceneActivationConfiguration.h +41 -0
- package/sdk/ios/System/Library/Frameworks/QuickLook.framework/Headers/QLPreviewingController.h +74 -0
- package/sdk/ios/System/Library/Frameworks/QuickLook.framework/Headers/QLThumbnailProvider.h +37 -0
- package/sdk/ios/System/Library/Frameworks/QuickLook.framework/Headers/QLThumbnailReply.h +67 -0
- package/sdk/ios/System/Library/Frameworks/QuickLook.framework/Headers/QLThumbnailRequest.h +33 -0
- package/sdk/ios/System/Library/Frameworks/QuickLook.framework/Headers/QuickLook.apinotes +35 -0
- package/sdk/ios/System/Library/Frameworks/QuickLook.framework/Headers/QuickLook.h +30 -0
- package/sdk/ios/System/Library/Frameworks/QuickLook.framework/Headers/QuickLookUICore.h +12 -0
- package/sdk/ios/System/Library/Frameworks/QuickLook.framework/Modules/module.modulemap +8 -0
- package/src/core-data-entity-classes.ts +316 -0
- package/src/swift-host.ts +12 -0
- package/src/turbo-source.ts +89 -11
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//
|
|
2
|
+
// QuickLook.h
|
|
3
|
+
// QuickLook
|
|
4
|
+
//
|
|
5
|
+
// Copyright (c) 2008-2015 Apple Inc. All rights reserved.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
#if !defined(__QUICKLOOK_QUICKLOOK__)
|
|
10
|
+
#define __QUICKLOOK_QUICKLOOK__
|
|
11
|
+
|
|
12
|
+
#include <CoreFoundation/CoreFoundation.h>
|
|
13
|
+
#include <QuickLook/QLBase.h>
|
|
14
|
+
|
|
15
|
+
#if __OBJC__
|
|
16
|
+
#import <QuickLook/QLPreviewController.h>
|
|
17
|
+
#import <QuickLook/QLPreviewItem.h>
|
|
18
|
+
#import <QuickLook/ARQuickLookPreviewItem.h>
|
|
19
|
+
#import <QuickLook/QLPreviewingController.h>
|
|
20
|
+
#import <QuickLook/QLThumbnailProvider.h>
|
|
21
|
+
#import <QuickLook/QLThumbnailRequest.h>
|
|
22
|
+
#import <QuickLook/QLThumbnailReply.h>
|
|
23
|
+
#import <QuickLook/QLPreviewProvider.h>
|
|
24
|
+
#import <QuickLook/QLPreviewReply.h>
|
|
25
|
+
#import <QuickLook/QLFilePreviewRequest.h>
|
|
26
|
+
#import <QuickLook/QLPreviewSceneActivationConfiguration.h>
|
|
27
|
+
#import <QuickLook/QuickLookUICore.h>
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
#endif
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//
|
|
2
|
+
// QuickLookUICore.h
|
|
3
|
+
// QuickLookUICore
|
|
4
|
+
//
|
|
5
|
+
// Created by Thomas Deniau on 02/07/2021.
|
|
6
|
+
// Copyright © 2021 com.apple. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import <QuickLook/QLBase.h>
|
|
10
|
+
#import <QuickLook/QLPreviewItem.h>
|
|
11
|
+
#import <QuickLook/QLPreviewingController.h>
|
|
12
|
+
#import <QuickLook/ARQuickLookPreviewItem.h>
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import { parsePlistSource } from './plist'
|
|
4
|
+
|
|
5
|
+
// the entity classes Xcode's momc writes for `codeGenerationType="class"` and
|
|
6
|
+
// `"category"` entities, from the model alone so any host can run it. every
|
|
7
|
+
// rule here was read from momc 27.1 --action generate (swift 5, iOS 17); a model
|
|
8
|
+
// feature whose output was not observed is refused, never guessed.
|
|
9
|
+
|
|
10
|
+
type Tag = { name: string; attrs: Record<string, string>; children: Tag[] }
|
|
11
|
+
|
|
12
|
+
const unescapeXml = (value: string) =>
|
|
13
|
+
value
|
|
14
|
+
.replace(/</g, '<')
|
|
15
|
+
.replace(/>/g, '>')
|
|
16
|
+
.replace(/"/g, '"')
|
|
17
|
+
.replace(/'/g, "'")
|
|
18
|
+
.replace(/&/g, '&')
|
|
19
|
+
|
|
20
|
+
// the model format is plain tags and attributes with no text content.
|
|
21
|
+
function parseModel(xml: string): Tag {
|
|
22
|
+
const root: Tag = { name: '#root', attrs: {}, children: [] }
|
|
23
|
+
const stack = [root]
|
|
24
|
+
for (const match of xml.matchAll(
|
|
25
|
+
/<(\/?)([A-Za-z][\w-]*)((?:\s+[\w:-]+="[^"]*")*)\s*(\/?)>/g,
|
|
26
|
+
)) {
|
|
27
|
+
const [, closing, name, attributes, selfClosing] = match
|
|
28
|
+
if (closing) {
|
|
29
|
+
stack.pop()
|
|
30
|
+
continue
|
|
31
|
+
}
|
|
32
|
+
const attrs: Record<string, string> = {}
|
|
33
|
+
for (const attribute of attributes!.matchAll(/([\w:-]+)="([^"]*)"/g))
|
|
34
|
+
attrs[attribute[1]!] = unescapeXml(attribute[2]!)
|
|
35
|
+
const tag: Tag = { name: name!, attrs, children: [] }
|
|
36
|
+
stack.at(-1)!.children.push(tag)
|
|
37
|
+
if (!selfClosing) stack.push(tag)
|
|
38
|
+
}
|
|
39
|
+
return root
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const scalarTypes: Record<string, [scalar: string, boxed: string]> = {
|
|
43
|
+
'Integer 16': ['Int16', 'NSNumber'],
|
|
44
|
+
'Integer 32': ['Int32', 'NSNumber'],
|
|
45
|
+
'Integer 64': ['Int64', 'NSNumber'],
|
|
46
|
+
Double: ['Double', 'NSNumber'],
|
|
47
|
+
Float: ['Float', 'NSNumber'],
|
|
48
|
+
Boolean: ['Bool', 'NSNumber'],
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const objectTypes: Record<string, string> = {
|
|
52
|
+
Decimal: 'NSDecimalNumber',
|
|
53
|
+
String: 'String',
|
|
54
|
+
Date: 'Date',
|
|
55
|
+
Binary: 'Data',
|
|
56
|
+
UUID: 'UUID',
|
|
57
|
+
URI: 'URL',
|
|
58
|
+
Undefined: 'NSObject',
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const reserved = new Set([
|
|
62
|
+
'class',
|
|
63
|
+
'in',
|
|
64
|
+
'init',
|
|
65
|
+
'self',
|
|
66
|
+
'Type',
|
|
67
|
+
'Protocol',
|
|
68
|
+
'default',
|
|
69
|
+
'repeat',
|
|
70
|
+
'operator',
|
|
71
|
+
'subscript',
|
|
72
|
+
])
|
|
73
|
+
const identifier = (name: string) => (reserved.has(name) ? `\`${name}\`` : name)
|
|
74
|
+
const capitalized = (name: string) => name.charAt(0).toUpperCase() + name.slice(1)
|
|
75
|
+
|
|
76
|
+
type ClassName = { name: string; module: string | null }
|
|
77
|
+
const className = (represented: string): ClassName => {
|
|
78
|
+
const at = represented.lastIndexOf('.')
|
|
79
|
+
return at < 0
|
|
80
|
+
? { name: represented, module: null }
|
|
81
|
+
: { name: represented.slice(at + 1), module: represented.slice(0, at) }
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function refuse(model: string, reason: string): never {
|
|
85
|
+
throw new Error(`Core Data entity classes are unproven for ${model}: ${reason}`)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const generatedNotice = (file: string) => `//
|
|
89
|
+
// ${file}
|
|
90
|
+
//
|
|
91
|
+
// This file was automatically generated and should not be edited.
|
|
92
|
+
//
|
|
93
|
+
`
|
|
94
|
+
|
|
95
|
+
function entityFiles(model: string, entity: Tag, entities: Map<string, Tag>) {
|
|
96
|
+
const entityName = entity.attrs.name!
|
|
97
|
+
const represented = className(entity.attrs.representedClassName!)
|
|
98
|
+
const codegen = entity.attrs.codeGenerationType
|
|
99
|
+
const parent = entity.attrs.parentEntity
|
|
100
|
+
? entities.get(entity.attrs.parentEntity)
|
|
101
|
+
: undefined
|
|
102
|
+
if (entity.attrs.parentEntity && !parent)
|
|
103
|
+
refuse(
|
|
104
|
+
model,
|
|
105
|
+
`${entityName} names the missing parent entity ${entity.attrs.parentEntity}`,
|
|
106
|
+
)
|
|
107
|
+
const files: Record<string, string> = {}
|
|
108
|
+
const base = parent
|
|
109
|
+
? className(parent.attrs.representedClassName ?? parent.attrs.name!).name
|
|
110
|
+
: 'NSManagedObject'
|
|
111
|
+
if (codegen === 'class') {
|
|
112
|
+
const file = `${represented.name}+CoreDataClass.swift`
|
|
113
|
+
files[file] = `${generatedNotice(file)}
|
|
114
|
+
public import Foundation
|
|
115
|
+
public import CoreData
|
|
116
|
+
|
|
117
|
+
public typealias ${represented.name}CoreDataClassSet = NSSet
|
|
118
|
+
|
|
119
|
+
${represented.module ? '\n' : `@objc(${represented.name})\n`}public class ${represented.name}: ${base} {
|
|
120
|
+
|
|
121
|
+
}
|
|
122
|
+
`
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const imports = new Set<string>()
|
|
126
|
+
const properties: string[] = []
|
|
127
|
+
const accessors: string[] = []
|
|
128
|
+
for (const member of entity.children) {
|
|
129
|
+
const name = member.attrs.name
|
|
130
|
+
if (member.name === 'attribute') {
|
|
131
|
+
const type = member.attrs.attributeType!
|
|
132
|
+
let swiftType: string
|
|
133
|
+
const scalar = scalarTypes[type]
|
|
134
|
+
if (scalar)
|
|
135
|
+
swiftType =
|
|
136
|
+
member.attrs.usesScalarValueType === 'NO' ? `${scalar[1]}?` : scalar[0]
|
|
137
|
+
else if (type === 'Transformable' && member.attrs.customClassName) {
|
|
138
|
+
const custom = className(member.attrs.customClassName)
|
|
139
|
+
if (custom.module) imports.add(custom.module)
|
|
140
|
+
swiftType = `${custom.name}?`
|
|
141
|
+
} else if (type === 'Transformable') swiftType = 'NSObject?'
|
|
142
|
+
else if (objectTypes[type]) swiftType = `${objectTypes[type]}?`
|
|
143
|
+
else refuse(model, `${entityName}.${name} has the attribute type ${type}`)
|
|
144
|
+
properties.push(
|
|
145
|
+
` @NSManaged nonisolated public var ${identifier(name!)}: ${swiftType}`,
|
|
146
|
+
)
|
|
147
|
+
} else if (member.name === 'relationship') {
|
|
148
|
+
const destination = entities.get(member.attrs.destinationEntity!)
|
|
149
|
+
if (!destination)
|
|
150
|
+
refuse(
|
|
151
|
+
model,
|
|
152
|
+
`${entityName}.${name} names the missing entity ${member.attrs.destinationEntity}`,
|
|
153
|
+
)
|
|
154
|
+
const target = className(
|
|
155
|
+
destination!.attrs.representedClassName ?? destination!.attrs.name!,
|
|
156
|
+
)
|
|
157
|
+
if (target.module) imports.add(target.module)
|
|
158
|
+
if (member.attrs.toMany !== 'YES') {
|
|
159
|
+
properties.push(
|
|
160
|
+
` @NSManaged nonisolated public var ${identifier(name!)}: ${target.name}?`,
|
|
161
|
+
)
|
|
162
|
+
continue
|
|
163
|
+
}
|
|
164
|
+
const cap = capitalized(name!)
|
|
165
|
+
const ordered = member.attrs.ordered === 'YES'
|
|
166
|
+
properties.push(
|
|
167
|
+
` @NSManaged nonisolated public var ${identifier(name!)}: ${ordered ? 'NSOrderedSet' : 'NSSet'}?`,
|
|
168
|
+
)
|
|
169
|
+
const lines = [
|
|
170
|
+
`// MARK: Generated accessors for ${name}`,
|
|
171
|
+
'extension ' + represented.name + ' {',
|
|
172
|
+
'',
|
|
173
|
+
]
|
|
174
|
+
const add = (selector: string, signature: string) =>
|
|
175
|
+
lines.push(
|
|
176
|
+
` @objc(${selector})`,
|
|
177
|
+
` @NSManaged nonisolated public func ${signature}`,
|
|
178
|
+
'',
|
|
179
|
+
)
|
|
180
|
+
if (ordered) {
|
|
181
|
+
add(
|
|
182
|
+
`insertObject:in${cap}AtIndex:`,
|
|
183
|
+
`insertInto${cap}(_ value: ${target.name}, at idx: Int)`,
|
|
184
|
+
)
|
|
185
|
+
add(`removeObjectFrom${cap}AtIndex:`, `removeFrom${cap}(at idx: Int)`)
|
|
186
|
+
add(
|
|
187
|
+
`insert${cap}:atIndexes:`,
|
|
188
|
+
`insertInto${cap}(_ values: [${target.name}], at indexes: NSIndexSet)`,
|
|
189
|
+
)
|
|
190
|
+
add(`remove${cap}AtIndexes:`, `removeFrom${cap}(at indexes: NSIndexSet)`)
|
|
191
|
+
add(
|
|
192
|
+
`replaceObjectIn${cap}AtIndex:withObject:`,
|
|
193
|
+
`replace${cap}(at idx: Int, with value: ${target.name})`,
|
|
194
|
+
)
|
|
195
|
+
add(
|
|
196
|
+
`replace${cap}AtIndexes:with${cap}:`,
|
|
197
|
+
`replace${cap}(at indexes: NSIndexSet, with values: [${target.name}])`,
|
|
198
|
+
)
|
|
199
|
+
}
|
|
200
|
+
add(`add${cap}Object:`, `addTo${cap}(_ value: ${target.name})`)
|
|
201
|
+
add(`remove${cap}Object:`, `removeFrom${cap}(_ value: ${target.name})`)
|
|
202
|
+
add(`add${cap}:`, `addTo${cap}(_ values: ${ordered ? 'NSOrderedSet' : 'NSSet'})`)
|
|
203
|
+
add(
|
|
204
|
+
`remove${cap}:`,
|
|
205
|
+
`removeFrom${cap}(_ values: ${ordered ? 'NSOrderedSet' : 'NSSet'})`,
|
|
206
|
+
)
|
|
207
|
+
lines.push('}', '')
|
|
208
|
+
accessors.push(lines.join('\n'))
|
|
209
|
+
} else if (
|
|
210
|
+
['fetchedProperty', 'compositeAttribute', 'derivedAttribute'].includes(member.name)
|
|
211
|
+
)
|
|
212
|
+
refuse(model, `${entityName} declares a ${member.name}`)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const file = `${represented.name}+CoreDataProperties.swift`
|
|
216
|
+
files[file] = `${generatedNotice(file)}
|
|
217
|
+
public import Foundation
|
|
218
|
+
public import CoreData
|
|
219
|
+
${
|
|
220
|
+
imports.size > 0
|
|
221
|
+
? [...imports]
|
|
222
|
+
.sort()
|
|
223
|
+
.map((module) => `import ${module}\n`)
|
|
224
|
+
.join('')
|
|
225
|
+
: '\n'
|
|
226
|
+
}
|
|
227
|
+
public typealias ${represented.name}CoreDataPropertiesSet = NSSet
|
|
228
|
+
|
|
229
|
+
extension ${represented.name} {
|
|
230
|
+
|
|
231
|
+
@nonobjc public class func fetchRequest() -> NSFetchRequest<${represented.name}> {
|
|
232
|
+
return NSFetchRequest<${represented.name}>(entityName: "${entityName}")
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
${properties.length > 0 ? `${properties.join('\n')}\n\n` : '\n'}}
|
|
236
|
+
|
|
237
|
+
${accessors.map((block) => `${block}\n`).join('')}${
|
|
238
|
+
parent
|
|
239
|
+
? ''
|
|
240
|
+
: `extension ${represented.name} : Identifiable {
|
|
241
|
+
|
|
242
|
+
}
|
|
243
|
+
`
|
|
244
|
+
}`
|
|
245
|
+
return files
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** the swift files momc writes for one compiled model version, keyed by file name. */
|
|
249
|
+
export function coreDataEntityClasses(
|
|
250
|
+
modelFile: string,
|
|
251
|
+
model = path.basename(path.dirname(modelFile)),
|
|
252
|
+
) {
|
|
253
|
+
const root = parseModel(readFileSync(modelFile, 'utf8'))
|
|
254
|
+
const entities = new Map<string, Tag>()
|
|
255
|
+
const modelTag = root.children.find((tag) => tag.name === 'model')
|
|
256
|
+
if (!modelTag) refuse(model, 'the contents file has no model element')
|
|
257
|
+
for (const tag of modelTag!.children)
|
|
258
|
+
if (tag.name === 'entity') entities.set(tag.attrs.name!, tag)
|
|
259
|
+
const files: Record<string, string> = {}
|
|
260
|
+
for (const entity of entities.values()) {
|
|
261
|
+
const codegen = entity.attrs.codeGenerationType
|
|
262
|
+
if (codegen !== 'class' && codegen !== 'category') continue
|
|
263
|
+
if (!entity.attrs.representedClassName) continue
|
|
264
|
+
Object.assign(files, entityFiles(model, entity, entities))
|
|
265
|
+
}
|
|
266
|
+
return files
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** the current version's contents file of an .xcdatamodeld, or a bare .xcdatamodel's own. */
|
|
270
|
+
export function currentModelContents(modelDirectory: string) {
|
|
271
|
+
if (modelDirectory.endsWith('.xcdatamodel'))
|
|
272
|
+
return path.join(modelDirectory, 'contents')
|
|
273
|
+
const versionFile = path.join(modelDirectory, '.xccurrentversion')
|
|
274
|
+
const versions = readdirSync(modelDirectory).filter((entry) =>
|
|
275
|
+
entry.endsWith('.xcdatamodel'),
|
|
276
|
+
)
|
|
277
|
+
const named = existsSync(versionFile)
|
|
278
|
+
? parsePlistSource(readFileSync(versionFile, 'utf8'))
|
|
279
|
+
: undefined
|
|
280
|
+
const current =
|
|
281
|
+
typeof named === 'object' &&
|
|
282
|
+
named !== null &&
|
|
283
|
+
'_XCCurrentVersionName' in named &&
|
|
284
|
+
typeof named._XCCurrentVersionName === 'string'
|
|
285
|
+
? named._XCCurrentVersionName
|
|
286
|
+
: !existsSync(versionFile) && versions.length === 1
|
|
287
|
+
? versions[0]
|
|
288
|
+
: undefined
|
|
289
|
+
if (current && versions.includes(current))
|
|
290
|
+
return path.join(modelDirectory, current, 'contents')
|
|
291
|
+
// without a named version only a model that generates nothing is safe to skip
|
|
292
|
+
const generating = versions.filter((version) =>
|
|
293
|
+
/codeGenerationType="(?:class|category)"/.test(
|
|
294
|
+
readFileSync(path.join(modelDirectory, version, 'contents'), 'utf8'),
|
|
295
|
+
),
|
|
296
|
+
)
|
|
297
|
+
if (generating.length > 0)
|
|
298
|
+
refuse(path.basename(modelDirectory), 'the current model version is not named')
|
|
299
|
+
return null
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/** the entity class sources for every model directory in a target's files, keyed by `<name>`. */
|
|
303
|
+
export function coreDataSources(files: readonly string[]) {
|
|
304
|
+
const models = new Set<string>()
|
|
305
|
+
for (const file of files) {
|
|
306
|
+
const at = file.search(/\.xcdatamodeld(?:[\\/]|$)/)
|
|
307
|
+
if (at >= 0) models.add(file.slice(0, at + '.xcdatamodeld'.length))
|
|
308
|
+
}
|
|
309
|
+
const sources: Record<string, string> = {}
|
|
310
|
+
for (const directory of [...models].sort()) {
|
|
311
|
+
const contents = currentModelContents(directory)
|
|
312
|
+
if (contents)
|
|
313
|
+
Object.assign(sources, coreDataEntityClasses(contents, path.basename(directory)))
|
|
314
|
+
}
|
|
315
|
+
return sources
|
|
316
|
+
}
|
package/src/swift-host.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
resolveSwiftImageResourceUrls,
|
|
15
15
|
} from '../../sootsim-swift/src/bundleAssets'
|
|
16
16
|
import { compileStringCatalog } from '../../sootsim-swift/src/stringCatalog'
|
|
17
|
+
import { coreDataSources } from './core-data-entity-classes'
|
|
17
18
|
import iosSdk from './ios-sdk-frameworks.json' with { type: 'json' }
|
|
18
19
|
import { type NativeAppIdentity } from './native-app-identity'
|
|
19
20
|
import { readNativeAppIdentityFromXcodeTarget } from './native-app-identity-project'
|
|
@@ -815,6 +816,11 @@ async function buildXcodeLayout(root: string): Promise<XcodeLayout | null> {
|
|
|
815
816
|
}
|
|
816
817
|
const generatedSources: Record<string, string> = {}
|
|
817
818
|
// xcode generates symbols for each target's own catalogs from its own settings
|
|
819
|
+
// xcode compiles the entity classes of each target's own models into it
|
|
820
|
+
const coreDataClasses = (files: readonly string[], dir: string) => {
|
|
821
|
+
for (const [name, text] of Object.entries(coreDataSources(files)))
|
|
822
|
+
generatedSources[path.posix.join(dir, 'GeneratedCoreData', name)] = text
|
|
823
|
+
}
|
|
818
824
|
const targetAssetSymbols = (module: XcodeModuleTarget, dir: string) => {
|
|
819
825
|
const plan = planAssetSymbols(
|
|
820
826
|
module.resources.map((file) => path.relative(root, file)),
|
|
@@ -827,6 +833,7 @@ async function buildXcodeLayout(root: string): Promise<XcodeLayout | null> {
|
|
|
827
833
|
assetSymbolText(plan.plan, root)
|
|
828
834
|
}
|
|
829
835
|
targetAssetSymbols(app, XCODE_APP_DIR)
|
|
836
|
+
coreDataClasses(app.resources, XCODE_APP_DIR)
|
|
830
837
|
for (const framework of app.frameworks) {
|
|
831
838
|
// a framework target that only links products compiles nothing, so it has
|
|
832
839
|
// no module, directory or bundle contents for swiftpm to take as a target
|
|
@@ -862,6 +869,7 @@ async function buildXcodeLayout(root: string): Promise<XcodeLayout | null> {
|
|
|
862
869
|
files.add(file)
|
|
863
870
|
}
|
|
864
871
|
targetAssetSymbols(framework, dir)
|
|
872
|
+
coreDataClasses(framework.resources, dir)
|
|
865
873
|
targets.push({
|
|
866
874
|
name,
|
|
867
875
|
path: dir,
|
|
@@ -1144,6 +1152,10 @@ async function buildXcodeLayout(root: string): Promise<XcodeLayout | null> {
|
|
|
1144
1152
|
)
|
|
1145
1153
|
] = generatePackageAssetSymbols(catalogs, target.packageDir, target.iosDeployment)
|
|
1146
1154
|
}
|
|
1155
|
+
coreDataClasses(
|
|
1156
|
+
target.files,
|
|
1157
|
+
target.remote ? path.posix.join(XCODE_PACKAGES_DIR, posix) : posix,
|
|
1158
|
+
)
|
|
1147
1159
|
}
|
|
1148
1160
|
// swiftpm assigns a file to one target: a target directory nested in
|
|
1149
1161
|
// another's is that one's exclusion
|
package/src/turbo-source.ts
CHANGED
|
@@ -49,7 +49,7 @@ import {
|
|
|
49
49
|
installedRendererDependencyGlobs,
|
|
50
50
|
runInstalledTurboCodegen,
|
|
51
51
|
} from './turbo-codegen-intake'
|
|
52
|
-
import { installedXcodeWorkspace } from './xcode-project'
|
|
52
|
+
import { installedXcodeWorkspace, readXcodeAppTarget } from './xcode-project'
|
|
53
53
|
import type { ReactNativeCoreMode } from './react-native-core'
|
|
54
54
|
import type { SwiftCompileInput } from './swift-compile'
|
|
55
55
|
import type { SwiftPackageTarget } from './swift-package'
|
|
@@ -1198,6 +1198,20 @@ export async function collectTurboSources(options: {
|
|
|
1198
1198
|
// compile key; reading it again is free.
|
|
1199
1199
|
const compiledSources = new Set<string>()
|
|
1200
1200
|
const textualSources = new Set<string>()
|
|
1201
|
+
const workspace = installedXcodeWorkspace(options.projectRoot)
|
|
1202
|
+
const installedTargets =
|
|
1203
|
+
workspace && !options.reactNativeCore && !options.reactNativeProvider
|
|
1204
|
+
? readXcodeAppTarget(workspace, undefined, 'Release', {
|
|
1205
|
+
installedPods: true,
|
|
1206
|
+
}).frameworks
|
|
1207
|
+
: []
|
|
1208
|
+
const fileFlags = new Map(
|
|
1209
|
+
installedTargets.flatMap((target) =>
|
|
1210
|
+
Object.entries(target.objc?.fileFlags ?? {}).map(
|
|
1211
|
+
([file, flags]): [string, string[]] => [fs.realpathSync(file), flags],
|
|
1212
|
+
),
|
|
1213
|
+
),
|
|
1214
|
+
)
|
|
1201
1215
|
const original = (
|
|
1202
1216
|
targetName: string,
|
|
1203
1217
|
label: string,
|
|
@@ -1215,6 +1229,38 @@ export async function collectTurboSources(options: {
|
|
|
1215
1229
|
(compiled ? compiledSources : textualSources).add(key)
|
|
1216
1230
|
if (Object.hasOwn(result.files, key)) return key
|
|
1217
1231
|
const disk = path.join(root, relative)
|
|
1232
|
+
const flags = compiled ? fileFlags.get(fs.realpathSync(disk)) : undefined
|
|
1233
|
+
if (flags?.length) {
|
|
1234
|
+
result.nativeTargets ??= []
|
|
1235
|
+
let native = result.nativeTargets.find(({ name }) => name === targetName)
|
|
1236
|
+
if (!native) {
|
|
1237
|
+
native = {
|
|
1238
|
+
name: targetName,
|
|
1239
|
+
deploymentTarget: null,
|
|
1240
|
+
headers: [],
|
|
1241
|
+
publicHeaders: [],
|
|
1242
|
+
flattensPublicHeaders: false,
|
|
1243
|
+
bridgingHeader: null,
|
|
1244
|
+
prefixHeader: null,
|
|
1245
|
+
headerSearchPaths: [
|
|
1246
|
+
`${targetPath(targetName)}/include`,
|
|
1247
|
+
`${targetPath(TURBO_CORE_TARGET)}/include`,
|
|
1248
|
+
],
|
|
1249
|
+
userHeaderSearchPaths: [],
|
|
1250
|
+
frameworkSearchPaths: [],
|
|
1251
|
+
headerMaps: [],
|
|
1252
|
+
productHeaders: {},
|
|
1253
|
+
flags: [],
|
|
1254
|
+
importerFlags: [],
|
|
1255
|
+
cxxFlags: [],
|
|
1256
|
+
fileFlags: {},
|
|
1257
|
+
sourceDirectories: {},
|
|
1258
|
+
}
|
|
1259
|
+
result.nativeTargets.push(native)
|
|
1260
|
+
}
|
|
1261
|
+
native.fileFlags[key] = flags
|
|
1262
|
+
native.sourceDirectories[key] = path.posix.dirname(key)
|
|
1263
|
+
}
|
|
1218
1264
|
const bytes = readPackageFile(root, disk, Infinity)
|
|
1219
1265
|
const text = bytes.toString('utf8')
|
|
1220
1266
|
if (!Buffer.from(text).equals(bytes))
|
|
@@ -1741,14 +1787,22 @@ export async function collectTurboSources(options: {
|
|
|
1741
1787
|
})
|
|
1742
1788
|
const mappings = podHeaderMappings(pod)
|
|
1743
1789
|
// CocoaPods flattens a pod's headers: `Name.h` and `<pod>/Name.h`
|
|
1790
|
+
const ambiguousHeaders = new Set<string>()
|
|
1744
1791
|
const header = (
|
|
1745
1792
|
names: string[],
|
|
1746
1793
|
entry: { label: string; root: string; relative: string },
|
|
1747
1794
|
) => {
|
|
1748
1795
|
for (const name of names) {
|
|
1796
|
+
if (ambiguousHeaders.has(name)) continue
|
|
1749
1797
|
const prior = headers.get(name)
|
|
1750
|
-
if (prior && prior.relative !== entry.relative)
|
|
1798
|
+
if (prior && (prior.root !== entry.root || prior.relative !== entry.relative)) {
|
|
1799
|
+
if (!name.includes('/') && prior.label !== entry.label) {
|
|
1800
|
+
headers.delete(name)
|
|
1801
|
+
ambiguousHeaders.add(name)
|
|
1802
|
+
continue
|
|
1803
|
+
}
|
|
1751
1804
|
throw new Error(`${label}: two pod headers are named ${name}`)
|
|
1805
|
+
}
|
|
1752
1806
|
headers.set(name, entry)
|
|
1753
1807
|
}
|
|
1754
1808
|
}
|
|
@@ -1838,15 +1892,39 @@ export async function collectTurboSources(options: {
|
|
|
1838
1892
|
const moduleNames = installed ? podspecList(installed.text, 'module_name') : null
|
|
1839
1893
|
if (moduleNames === 'computed')
|
|
1840
1894
|
throw new Error(`${dep.name}: module_name must come from the installed pod`)
|
|
1841
|
-
const
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1895
|
+
const installedTarget = installedTargets.find(
|
|
1896
|
+
(target) => target.name === dep.name && target.podRoot,
|
|
1897
|
+
)
|
|
1898
|
+
const installedRoot = installedTarget?.podRoot
|
|
1899
|
+
? fs.realpathSync(installedTarget.podRoot)
|
|
1900
|
+
: undefined
|
|
1901
|
+
const resolved =
|
|
1902
|
+
installedTarget && installedRoot
|
|
1903
|
+
? {
|
|
1904
|
+
name: installedTarget.name,
|
|
1905
|
+
moduleName: installedTarget.moduleName,
|
|
1906
|
+
root: installedRoot,
|
|
1907
|
+
files: [
|
|
1908
|
+
...new Set([
|
|
1909
|
+
...installedTarget.allSources,
|
|
1910
|
+
...(installedTarget.objc?.headers ?? []),
|
|
1911
|
+
...(installedTarget.objc?.publicHeaders ?? []),
|
|
1912
|
+
]),
|
|
1913
|
+
].flatMap((file) => {
|
|
1914
|
+
const relative = relativeInside(installedRoot, fs.realpathSync(file))
|
|
1915
|
+
return relative === null ? [] : [relative.split(path.sep).join('/')]
|
|
1916
|
+
}),
|
|
1917
|
+
defines: [],
|
|
1918
|
+
}
|
|
1919
|
+
: installed
|
|
1920
|
+
? {
|
|
1921
|
+
name: installed.name,
|
|
1922
|
+
moduleName: moduleNames?.[0] ?? installed.name,
|
|
1923
|
+
root: installed.root,
|
|
1924
|
+
files: podFiles(installed),
|
|
1925
|
+
defines: [],
|
|
1926
|
+
}
|
|
1927
|
+
: await resolveExternalTurboPod(dep.name, dep.requirements, dep.subspecs)
|
|
1850
1928
|
if (!resolved) continue
|
|
1851
1929
|
if (provider.reactModulesOnly && resolved.files.some((f) => f.endsWith('.swift')))
|
|
1852
1930
|
continue
|